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

Ban Dead Addresses (#143)

* add check and test

* uint->uint256
parent e9d41069
......@@ -894,7 +894,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
* Calls the deployed contract associated with a given address.
* @param _nextMessageContext Message context to be used for the call.
* @param _gasLimit Amount of gas to be passed into this call.
* @param _contract Address used to resolve the deployed contract.
* @param _contract OVM address to be called.
* @param _calldata Data to send along with the call.
* @return _success Whether or not the call returned (rather than reverted).
* @return _returndata Data returned by the call.
......@@ -911,6 +911,14 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
bytes memory _returndata
)
{
// We reserve addresses of the form 0xdeaddeaddead...NNNN for the container contracts in L2 geth.
// So, we block calls to these addresses since they are not safe to run as an OVM contract itself.
if (
(uint256(_contract) & uint256(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000))
== uint256(0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000)
) {
return (true, hex'');
}
// Both 0x0000... and the EVM precompiles have the same address on L1 and L2 --> no trie lookup needed.
address codeContractAddress =
......
......@@ -11,6 +11,8 @@ import {
const DUMMY_REVERT_DATA =
'0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420'
const DEAD_ADDRESS = '0xdeaddeaddeaddeaddeaddeaddeaddeaddead1234'
const test_ovmCALL: TestDefinition = {
name: 'Basic tests for ovmCALL',
preState: {
......@@ -241,6 +243,24 @@ const test_ovmCALL: TestDefinition = {
},
],
},
{
name: 'ovmCALL(0xdeaddeaddead...) returns (true, 0x)',
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: OVM_TX_GAS_LIMIT,
target: DEAD_ADDRESS,
subSteps: []
},
expectedReturnStatus: true,
expectedReturnValue: {
ovmSuccess: true,
returnData: '0x'
},
},
],
},
],
}
......
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