Skip to content

Commit

Permalink
Merge branch 'evm-equivalence-yul' into vv-lazy-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
0xVolosnikov committed Aug 20, 2024
2 parents e68fbc8 + 74767c1 commit 0fbab9b
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 18 deletions.
31 changes: 25 additions & 6 deletions system-contracts/contracts/EvmInterpreterFunctions.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -897,8 +897,15 @@ function performStaticCall(oldSp, evmGasLeft, oldStackHead) -> extraCost, sp, st
}
}

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}

stackHead := success
}
function capGas(evmGasLeft,oldGasToPass) -> gasToPass {
Expand Down Expand Up @@ -1020,8 +1027,14 @@ function performCall(oldSp, evmGasLeft, isStatic, oldStackHead) -> extraCost, sp
isStatic
)

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}
stackHead := success
}

Expand Down Expand Up @@ -1083,8 +1096,14 @@ function delegateCall(oldSp, oldIsStatic, evmGasLeft, oldStackHead) -> sp, isSta

_popEVMFrame()

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}
stackHead := success
}

Expand Down
62 changes: 50 additions & 12 deletions system-contracts/contracts/EvmInterpreterPreprocessed.yul
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,15 @@ object "EVMInterpreter" {
}
}

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}

stackHead := success
}
function capGas(evmGasLeft,oldGasToPass) -> gasToPass {
Expand Down Expand Up @@ -1091,8 +1098,14 @@ object "EVMInterpreter" {
isStatic
)

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}
stackHead := success
}

Expand Down Expand Up @@ -1154,8 +1167,14 @@ object "EVMInterpreter" {

_popEVMFrame()

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}
stackHead := success
}

Expand Down Expand Up @@ -3897,8 +3916,15 @@ object "EVMInterpreter" {
}
}

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}

stackHead := success
}
function capGas(evmGasLeft,oldGasToPass) -> gasToPass {
Expand Down Expand Up @@ -4020,8 +4046,14 @@ object "EVMInterpreter" {
isStatic
)

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}
stackHead := success
}

Expand Down Expand Up @@ -4083,8 +4115,14 @@ object "EVMInterpreter" {

_popEVMFrame()

extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
extraCost := add(extraCost, getGasForPrecompiles(addr, argsOffset, argsSize))
let precompileCost := getGasForPrecompiles(addr, argsOffset, argsSize)
switch iszero(precompileCost)
case 1 {
extraCost := add(extraCost,sub(gasToPass,frameGasLeft))
}
default {
extraCost := add(extraCost, precompileCost)
}
stackHead := success
}

Expand Down

0 comments on commit 0fbab9b

Please sign in to comment.