Skip to content

Commit

Permalink
feat(keccak256-opcode): Add KECCAK256 opcode
Browse files Browse the repository at this point in the history
Pending: calculate dynamic gas
  • Loading branch information
fborello-lambda committed Apr 10, 2024
1 parent 6eb9ced commit 1b9d961
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions system-contracts/contracts/EvmInterpreter.yul
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,21 @@ object "EVMInterpreter" {

sp := pushStackItem(sp, mulmod(a, b, N))
}
case 0x20 { // OP_KECCAK256
let offset, size

offset, sp := popStackItem(sp)
size, sp := popStackItem(sp)

sp := pushStackItem(sp, keccak256(add(MEM_OFFSET(), offset), size))

// TODO: Handle dynamicGas for gas costs.
// dynamic_gas = 6 * minimum_word_size + memory_expansion_cost
let dynamicGas = 0
let staticGas = 30
let usedGas = add(staticGas, dynamicGas)
evmGasLeft := chargeGas(evmGasLeft, usedGas)
}
case 0x55 { // OP_SSTORE
let key, value

Expand Down

0 comments on commit 1b9d961

Please sign in to comment.