Commit 7f5936a8 authored by Maurelian's avatar Maurelian Committed by GitHub

More consistent style for Constant values (#991)

* chore(contracts): make container addresses be constants
chore(contracts): consistent style for constant vars

* chore(contracts): add internal on predeploy constants
parent e29fab10
---
'@eth-optimism/contracts': patch
---
Apply consistent styling to constants
......@@ -98,7 +98,7 @@ contract OVM_ProxyEOA {
address implementation = Lib_Bytes32Utils.toAddress(addr32);
if (implementation == address(0)) {
return Lib_PredeployAddresses.ovmECDSAContractAccount;
return Lib_PredeployAddresses.ECDSA_CONTRACT_ACCOUNT;
} else {
return implementation;
}
......
......@@ -408,7 +408,7 @@ contract OVM_L1CrossDomainMessenger is
bool exists,
bytes memory encodedMessagePassingAccount
) = Lib_SecureMerkleTrie.get(
abi.encodePacked(Lib_PredeployAddresses.ovmL2ToL1MessagePasser),
abi.encodePacked(Lib_PredeployAddresses.L2_TO_L1_MESSAGE_PASSER),
_proof.stateTrieWitness,
_proof.stateRoot
);
......
......@@ -73,6 +73,17 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
uint256 constant DEFAULT_UINT256 = 0xdefa017defa017defa017defa017defa017defa017defa017defa017defa017d;
address constant DEFAULT_ADDRESS = 0xdEfa017defA017DeFA017DEfa017DeFA017DeFa0;
/*************************************
* Container Contract Address Prefix *
*************************************/
/**
* @dev The Execution Manager and State Manager each have this 30 byte prefix, and are uncallable.
*/
address constant CONTAINER_CONTRACT_PREFIX = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
/***************
* Constructor *
***************/
......@@ -552,9 +563,9 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
address proxyEOA = Lib_EthUtils.createContract(abi.encodePacked(
hex"600D380380600D6000396000f3",
ovmEXTCODECOPY(
Lib_PredeployAddresses.ovmProxyEOA,
Lib_PredeployAddresses.PROXY_EOA,
0,
ovmEXTCODESIZE(Lib_PredeployAddresses.ovmProxyEOA)
ovmEXTCODESIZE(Lib_PredeployAddresses.PROXY_EOA)
)
));
......@@ -830,7 +841,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
// the deployer ovmCALLing the whitelist. This is fine--in a sense, we are forcing them to.
(bool success, bytes memory data) = ovmCALL(
gasleft(),
Lib_PredeployAddresses.ovmDeployerWhitelist,
Lib_PredeployAddresses.DEPLOYER_WHITELIST,
abi.encodeWithSignature("isDeployerAllowed(address)", _deployerAddress)
);
bool isAllowed = abi.decode(data, (bool));
......@@ -912,7 +923,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
// 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)
== uint256(CONTAINER_CONTRACT_PREFIX)
) {
// EVM does not return data in the success case, see: https://github.com/ethereum/go-ethereum/blob/aae7660410f0ef90279e14afaaf2f429fdc2a186/core/vm/instructions.go#L600-L604
return (true, hex'');
......
......@@ -5,14 +5,14 @@ pragma solidity >0.5.0 <0.8.0;
* @title Lib_PredeployAddresses
*/
library Lib_PredeployAddresses {
address public constant ovmL2ToL1MessagePasser = 0x4200000000000000000000000000000000000000;
address public constant ovmL1MessageSender = 0x4200000000000000000000000000000000000001;
address public constant ovmDeployerWhitelist = 0x4200000000000000000000000000000000000002;
address public constant ovmECDSAContractAccount = 0x4200000000000000000000000000000000000003;
address public constant ovmSequencerEntrypoint = 0x4200000000000000000000000000000000000005;
address public constant ovmETH = 0x4200000000000000000000000000000000000006;
address public constant ovmL2CrossDomainMessenger = 0x4200000000000000000000000000000000000007;
address public constant libAddressManager = 0x4200000000000000000000000000000000000008;
address public constant ovmProxyEOA = 0x4200000000000000000000000000000000000009;
address public constant ERC1820Registry = 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24;
address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
address internal constant ECDSA_CONTRACT_ACCOUNT = 0x4200000000000000000000000000000000000003;
address internal constant SEQUENCER_ENTRYPOINT = 0x4200000000000000000000000000000000000005;
address internal constant OVM_ETH = 0x4200000000000000000000000000000000000006;
address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007;
address internal constant LIB_ADDRESS_MANAGER = 0x4200000000000000000000000000000000000008;
address internal constant PROXY_EOA = 0x4200000000000000000000000000000000000009;
address internal constant ERC1820_REGISTRY = 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24;
}
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