Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e1038d3
Started standardizing contracts
smartcontracts Jul 27, 2020
82b0853
Updated all function signatures
smartcontracts Jul 27, 2020
e55abdf
Added some function comments
smartcontracts Jul 27, 2020
50fda75
Added remaining function comments
smartcontracts Jul 27, 2020
ad4883c
Added SolPP support
smartcontracts Jul 27, 2020
c7d09b9
Linted files
smartcontracts Jul 27, 2020
3d8de8d
Fixed merge conflict
smartcontracts Jul 27, 2020
ac0e280
Converted libraries to real libraries
smartcontracts Jul 27, 2020
1797677
Fixed FraudVerifier deploy config
smartcontracts Jul 27, 2020
410bcc9
Made MockRLPWriter functions public
smartcontracts Jul 28, 2020
a0ceba2
Added coverage scripts
smartcontracts Jul 28, 2020
38061b3
Removed duplicated test helpers
smartcontracts Jul 28, 2020
4f80674
Linted files
smartcontracts Jul 28, 2020
b960c28
Started adding empty testts
smartcontracts Jul 28, 2020
f00ea24
Added comment to debug CI
smartcontracts Jul 28, 2020
a6ef6b4
Added a few more tests
smartcontracts Jul 28, 2020
fd71cea
Updated buidler config
smartcontracts Jul 28, 2020
0c75d47
Merge branch 'YAS-539/contracts/standards' of github.com:ethereum-opt…
smartcontracts Jul 28, 2020
6a4de09
Added last basic tests
smartcontracts Jul 28, 2020
6194777
Modifications to fix tests
smartcontracts Jul 28, 2020
ae8ac35
Filled in remaining tests
smartcontracts Jul 30, 2020
d3bc120
Various small changes as per comments
smartcontracts Jul 30, 2020
ea795ea
Matching standards PR
smartcontracts Jul 30, 2020
a9c4540
Merge branch 'master' of github.com:ethereum-optimism/optimism-monore…
smartcontracts Jul 30, 2020
fcc9140
Minor fix to add CHAINID back to unsafe opcodes
smartcontracts Jul 30, 2020
be845f2
Fixed linting error
smartcontracts Jul 30, 2020
4ef6abc
Removed duplicate deploy logic
smartcontracts Jul 31, 2020
7ca8127
Minor bugfix for getWallets
smartcontracts Jul 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;

/* Contract Imports */
Expand Down Expand Up @@ -31,20 +32,20 @@ contract PartialStateManager is ContractResolver {

StateTransitioner private stateTransitioner;

mapping(address => mapping(bytes32 => bytes32)) private ovmContractStorage;
mapping(address => uint) private ovmContractNonces;
mapping(address => address) private ovmAddressToCodeContractAddress;
mapping(address => mapping(bytes32 => bytes32)) public ovmContractStorage;
mapping(address => uint) public ovmContractNonces;
mapping(address => address) public ovmAddressToCodeContractAddress;

bool public existsInvalidStateAccessFlag;

mapping(address => mapping(bytes32 => bool)) public isVerifiedStorage;
mapping(address => bool) public isVerifiedContract;
mapping(uint => bytes32) private updatedStorageSlotContract;
mapping(uint => bytes32) private updatedStorageSlotKey;
mapping(address => mapping(bytes32 => bool)) private storageSlotTouched;
mapping(uint => bytes32) public updatedStorageSlotContract;
mapping(uint => bytes32) public updatedStorageSlotKey;
mapping(address => mapping(bytes32 => bool)) public storageSlotTouched;
uint public updatedStorageSlotCounter;
mapping(uint => address) private updatedContracts;
mapping(address => bool) private contractTouched;
mapping(uint => address) public updatedContracts;
mapping(address => bool) public contractTouched;
uint public updatedContractsCounter;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ contract StateTransitioner is IStateTransitioner, ContractResolver {
{
require(
stateManager.updatedStorageSlotCounter() == 0,
"There's still updated storage to account for!"
"All storage updates must be proven to complete the transition."
);
require(
stateManager.updatedStorageSlotCounter() == 0,
"There's still updated contracts to account for!"
stateManager.updatedContractsCounter() == 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"All contract updates must be proven to complete the transition."
);

currentTransitionPhase = TransitionPhases.Complete;
Expand Down
108 changes: 108 additions & 0 deletions packages/contracts/contracts/test-helpers/ContextContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@ contract ContextContract {
}
}

function staticCallThroughExecutionManager() public {
// bitwise right shift 28 * 8 bits so the 4 method ID bytes are in the right-most bytes
bytes32 methodId = keccak256("ovmSTATICCALL()") >> 224;
address addr = executionManagerAddress;

assembly {
let callBytes := mload(0x40)
calldatacopy(callBytes, 0, calldatasize)

// replace the first 4 bytes with the right methodID
mstore8(callBytes, shr(24, methodId))
mstore8(add(callBytes, 1), shr(16, methodId))
mstore8(add(callBytes, 2), shr(8, methodId))
mstore8(add(callBytes, 3), methodId)

// overwrite call params
let result := mload(0x40)
let success := call(gas, addr, 0, callBytes, calldatasize, result, 32)

if eq(success, 0) {
revert(0, 0)
}

return(result, returndatasize)
}
}

function getCALLER() public {
// bitwise right shift 28 * 8 bits so the 4 method ID bytes are in the right-most bytes
bytes32 methodId = keccak256("ovmCALLER()") >> 224;
Expand Down Expand Up @@ -228,4 +255,85 @@ contract ContextContract {
return(result, returndatasize)
}
}

function ovmBlockGasLimit() public {
// bitwise right shift 28 * 8 bits so the 4 method ID bytes are in the right-most bytes
bytes32 methodId = keccak256("ovmBlockGasLimit()") >> 224;
address addr = executionManagerAddress;

assembly {
let callBytes := mload(0x40)
calldatacopy(callBytes, 0, calldatasize)

// replace the first 4 bytes with the right methodID
mstore8(callBytes, shr(24, methodId))
mstore8(add(callBytes, 1), shr(16, methodId))
mstore8(add(callBytes, 2), shr(8, methodId))
mstore8(add(callBytes, 3), methodId)

// overwrite call params
let result := mload(0x40)
let success := call(gas, addr, 0, callBytes, calldatasize, result, 32)

if eq(success, 0) {
revert(0, 0)
}

return(result, returndatasize)
}
}

function isStaticContext() public {
// bitwise right shift 28 * 8 bits so the 4 method ID bytes are in the right-most bytes
bytes32 methodId = keccak256("isStaticContext()") >> 224;
address addr = executionManagerAddress;

assembly {
let callBytes := mload(0x40)
calldatacopy(callBytes, 0, calldatasize)

// replace the first 4 bytes with the right methodID
mstore8(callBytes, shr(24, methodId))
mstore8(add(callBytes, 1), shr(16, methodId))
mstore8(add(callBytes, 2), shr(8, methodId))
mstore8(add(callBytes, 3), methodId)

// overwrite call params
let result := mload(0x40)
let success := call(gas, addr, 0, callBytes, calldatasize, result, 32)

if eq(success, 0) {
revert(0, 0)
}

return(result, returndatasize)
}
}

function ovmORIGIN() public {
// bitwise right shift 28 * 8 bits so the 4 method ID bytes are in the right-most bytes
bytes32 methodId = keccak256("ovmORIGIN()") >> 224;
address addr = executionManagerAddress;

assembly {
let callBytes := mload(0x40)
calldatacopy(callBytes, 0, calldatasize)

// replace the first 4 bytes with the right methodID
mstore8(callBytes, shr(24, methodId))
mstore8(add(callBytes, 1), shr(16, methodId))
mstore8(add(callBytes, 2), shr(8, methodId))
mstore8(add(callBytes, 3), methodId)

// overwrite call params
let result := mload(0x40)
let success := call(gas, addr, 0, callBytes, calldatasize, result, 32)

if eq(success, 0) {
revert(0, 0)
}

return(result, returndatasize)
}
}
}
4 changes: 4 additions & 0 deletions packages/contracts/contracts/test-helpers/FraudTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pragma solidity ^0.5.0;
contract BaseFraudTester {
mapping (bytes32 => bytes32) public builtInStorage;

function doRevert() public {
revert("Performing a revert for testing.");
}

function setStorage(bytes32 key, bytes32 value) public {
builtInStorage[key] = value;
}
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dependencies": {
"@eth-optimism/core-db": "^0.0.1-alpha.25",
"@eth-optimism/core-utils": "^0.0.1-alpha.25",
"@eth-optimism/rollup-core": "^0.0.1-alpha.28",
"@eth-optimism/solc-transpiler": "^0.0.1-alpha.27",
"@nomiclabs/buidler": "^1.3.8",
"@nomiclabs/buidler-ethers": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/src/deployment/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './contract-deploy'
export { AddressResolverMapping, RollupDeployConfig } from './types'
Loading