Skip to content

Commit

Permalink
Fix broken stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jrchatruc committed Apr 29, 2024
1 parent ec6b179 commit 4d29430
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 40 deletions.
38 changes: 0 additions & 38 deletions system-contracts/contracts/EvmInterpreter.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,6 @@ object "EVMInterpreter" {
}
}

function loadCalldataIntoActivePtr() {
verbatim_1i_0o("active_ptr_data_load", 0xFFFF)
}

function getActivePtrDataSize() -> size {
size := verbatim_0i_1o("active_ptr_data_size")
}

function copyActivePtrData(_dest, _source, _size) {
verbatim_3i_0o("active_ptr_data_copy", _dest, _source, _size)
}

function GAS_CONSTANTS() -> divisor, stipend, overhead {
divisor := 5
stipend := shl(30, 1)
overhead := 2000
}

function getEVMGas() -> evmGas {
let GAS_DIVISOR, EVM_GAS_STIPEND, OVERHEAD := GAS_CONSTANTS()

let gasLeft := gas()
let requiredGas := add(EVM_GAS_STIPEND, OVERHEAD)

evmGas := div(sub(gasLeft, requiredGas), GAS_DIVISOR)

if lt(gasLeft, requiredGas) {
evmGas := 0
}
}

function validateCorrectBytecode(offset, len, gasToReturn) -> returnGas {
if len {
// let firstByte := shr(mload(offset), 248)
Expand Down Expand Up @@ -162,13 +131,6 @@ object "EVMInterpreter" {
// segment of memory.
getDeployedBytecode()

// stack pointer - index to first stack element; empty stack = -1
let sp := sub(STACK_OFFSET(), 32)
// instruction pointer - index to next instruction. Not called pc because it's an
// actual yul/evm instruction.
let ip := add(BYTECODE_OFFSET(), 32)
let opcode

let returnOffset := MEM_OFFSET_INNER()
let returnLen := 0

Expand Down
26 changes: 24 additions & 2 deletions system-contracts/contracts/EvmInterpreterFunctions.template.yul
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,6 @@ function incrementNonce(addr) {
if iszero(result) {
revert(0, 0)
}

isEVM := mload(0)
}

function _pushEVMFrame(_passGas, _isStatic) {
Expand Down Expand Up @@ -822,6 +820,30 @@ function getMessageCallGas (
}
}

function _isEVM(_addr) -> isEVM {
// bytes4 selector = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.isAccountEVM.selector;
// function isAccountEVM(address _addr) external view returns (bool);
let selector := 0x8c040477
// IAccountCodeStorage constant ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT = IAccountCodeStorage(
// address(SYSTEM_CONTRACTS_OFFSET + 0x02)
// );

mstore8(0, 0x8c)
mstore8(1, 0x04)
mstore8(2, 0x04)
mstore8(3, 0x77)
mstore(4, _addr)

let success := staticcall(gas(), ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT(), 0, 36, 0, 32)

if iszero(success) {
// This error should never happen
revert(0, 0)
}

isEVM := mload(0)
}

function _performStaticCall(
_calleeIsEVM,
_calleeGas,
Expand Down

0 comments on commit 4d29430

Please sign in to comment.