Commit eabd6a95 authored by ben-chain's avatar ben-chain Committed by GitHub

Integrations Updates (#49)

* workinggit status

* most up to date

* stub safety checker

* fix mockOVM_ECDSA, stub safety check

* fix nonce ordering, remove failing gas metering config

* fix safety checker shift with extra byte of code

* remove unused test util

* bad semicolon

* remove unused vars and import

* fix comment

* fix mockACCT comment

* revert EOA acocunt changes as they are unused in jsvm
Co-authored-by: default avatarB T <oliphant@Bs-MacBook-Pro.local>
parent 78c42283
......@@ -106,8 +106,8 @@ contract OVM_SafetyChecker is iOVM_SafetyChecker {
assembly {
firstOps := mload(_pc)
// 32 - 4 bytes = 28 bytes = 224 bits
secondOps := shr(224, mload(add(_pc, 0x20)))
// 37 bytes total, 5 left over --> 32 - 5 bytes = 27 bytes = 216 bits
secondOps := shr(216, mload(add(_pc, 0x20)))
}
// Call identity precompile
......@@ -116,9 +116,9 @@ contract OVM_SafetyChecker is iOVM_SafetyChecker {
if ((firstOps >> 192) == 0x3350600060045af1) {
_pc += 8;
// Call EM and abort execution if instructed
// CALLER PUSH1 0x00 SWAP1 GAS CALL PC PUSH1 0x1d ADD JUMPI RETURNDATASIZE PUSH1 0x01 EQ PC PUSH1 0x0c ADD JUMPI RETURNDATASIZE PUSH1 0x00 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x00 REVERT JUMPDEST PUSH1 0x01 PUSH1 0x00 RETURN JUMPDEST
} else if (firstOps == 0x336000905af158601d01573d60011458600c01573d6000803e3d6000FD5b6001 && secondOps == 0x6000f35b) {
_pc += 36;
// CALLER PUSH1 0x00 SWAP1 GAS CALL PC PUSH1 0x0E ADD JUMPI RETURNDATASIZE PUSH1 0x00 DUP1 RETURNDATACOPY RETURNDATASIZE PUSH1 0x00 REVERT JUMPDEST RETURNDATASIZE PUSH1 0x01 EQ ISZERO PC PUSH1 0x0a ADD JUMPI PUSH1 0x01 PUSH1 0x00 RETURN JUMPDEST
} else if (firstOps == 0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760 && secondOps == 0x016000f35b) {
_pc += 37;
} else {
return false;
}
......
......@@ -56,11 +56,11 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
decodedTx.data
);
// EVM doesn't tell us whether a contract creation failed, even if it reverted during
// initialization. Always return `true` for our success value here.
return (true, abi.encode(created));
// If the created address is the ZERO_ADDRESS then we know the deployment failed, though not why
return (created != address(0), abi.encode(created));
} else {
return Lib_SafeExecutionManagerWrapper.safeCALL(
_incrementNonce();
(_success, _returndata) = Lib_SafeExecutionManagerWrapper.safeCALL(
ovmExecutionManager,
decodedTx.gasLimit,
decodedTx.target,
......@@ -68,4 +68,12 @@ contract mockOVM_ECDSAContractAccount is iOVM_ECDSAContractAccount {
);
}
}
function _incrementNonce()
internal
{
address ovmExecutionManager = msg.sender;
uint nonce = Lib_SafeExecutionManagerWrapper.safeGETNONCE(ovmExecutionManager) + 1;
Lib_SafeExecutionManagerWrapper.safeSETNONCE(ovmExecutionManager, nonce);
}
}
......@@ -44,7 +44,7 @@ const getStorageDump = async (
const stream = trie.createReadStream()
stream.on('data', (val: any) => {
storage[val.key.toString('hex')] = val.value.toString('hex')
storage[val.key.toString('hex')] = val.value.toString('hex').slice(2)
})
stream.on('end', () => {
......@@ -113,7 +113,7 @@ export const makeStateDump = async (): Promise<any> => {
minTransactionGasLimit: 0,
maxTransactionGasLimit: 1_000_000_000,
maxGasPerQueuePerEpoch: 1_000_000_000_000,
secondsPerEpoch: 600,
secondsPerEpoch: 0,
},
ovmGlobalContext: {
ovmCHAINID: 420,
......
......@@ -1073,7 +1073,7 @@
"out": false
},
"valid EM call": {
"in": "0x336000905af158601d01573d60011458600c01573d6000803e3d6000FD5b60016000f35b",
"in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b",
"out": true
},
"valid identity precompile call": {
......@@ -1081,15 +1081,15 @@
"out": true
},
"valid EM call, then valid identity precompile call": {
"in": "0x336000905af158601d01573d60011458600c01573d6000803e3d6000FD5b60016000f35b3350600060045af1",
"in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b3350600060045af1",
"out": true
},
"valid EM call, then invalid identity precompile call": {
"in": "0x336000905af158601d01573d60011458600c01573d6000803e3d6000FD5b60016000f35b3350600060035af1",
"in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b3350600060035af1",
"out": false
},
"valid EM call, then invalid opcode (SLOAD)": {
"in": "0x336000905af158601d01573d60011458600c01573d6000803e3d6000FD5b60016000f35b54",
"in": "0x336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b54",
"out": false
},
"valid identity precompile call, then invalid opcode (SLOAD)": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment