Commit e52ce890 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

feat: no proxy (#47)

* rebased to master

* Fixed resolve in ctc

* contracts: remove require statement

* Fix broken tests

* Fix broken FraudContributor
Co-authored-by: default avatarKelvin Fichter <kelvinfichter@gmail.com>
Co-authored-by: default avatarKarl Floersch <karl@karlfloersch.com>
parent 47bf1dfd
...@@ -22,7 +22,7 @@ const config: BuidlerConfig = { ...@@ -22,7 +22,7 @@ const config: BuidlerConfig = {
timeout: 50000, timeout: 50000,
}, },
solc: { solc: {
version: '0.7.0', version: '0.7.4',
optimizer: { enabled: true, runs: 200 }, optimizer: { enabled: true, runs: 200 },
}, },
typechain: { typechain: {
......
...@@ -19,14 +19,6 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol ...@@ -19,14 +19,6 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol
* @title OVM_L1CrossDomainMessenger * @title OVM_L1CrossDomainMessenger
*/ */
contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver { contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
iOVM_CanonicalTransactionChain internal ovmCanonicalTransactionChain;
iOVM_StateCommitmentChain internal ovmStateCommitmentChain;
/*************** /***************
* Constructor * * Constructor *
...@@ -37,12 +29,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros ...@@ -37,12 +29,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
*/ */
constructor( constructor(
address _libAddressManager address _libAddressManager
) ) Lib_AddressResolver(_libAddressManager) {}
Lib_AddressResolver(_libAddressManager)
{
ovmCanonicalTransactionChain = iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain"));
ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain"));
}
/******************** /********************
...@@ -174,6 +161,8 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros ...@@ -174,6 +161,8 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
bool bool
) )
{ {
iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain"));
return ( return (
ovmStateCommitmentChain.insideFraudProofWindow(_proof.stateRootBatchHeader) == false ovmStateCommitmentChain.insideFraudProofWindow(_proof.stateRootBatchHeader) == false
&& ovmStateCommitmentChain.verifyStateCommitment( && ovmStateCommitmentChain.verifyStateCommitment(
...@@ -250,7 +239,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros ...@@ -250,7 +239,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCros
override override
internal internal
{ {
ovmCanonicalTransactionChain.enqueue( iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")).enqueue(
resolve("OVM_L2CrossDomainMessenger"), resolve("OVM_L2CrossDomainMessenger"),
_gasLimit, _gasLimit,
_message _message
......
...@@ -19,14 +19,6 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol ...@@ -19,14 +19,6 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol
*/ */
contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver { contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
iOVM_L1MessageSender internal ovmL1MessageSender;
iOVM_L2ToL1MessagePasser internal ovmL2ToL1MessagePasser;
/*************** /***************
* Constructor * * Constructor *
***************/ ***************/
...@@ -36,12 +28,7 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros ...@@ -36,12 +28,7 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros
*/ */
constructor( constructor(
address _libAddressManager address _libAddressManager
) ) Lib_AddressResolver(_libAddressManager) {}
Lib_AddressResolver(_libAddressManager)
{
ovmL1MessageSender = iOVM_L1MessageSender(resolve("OVM_L1MessageSender"));
ovmL2ToL1MessagePasser = iOVM_L2ToL1MessagePasser(resolve("OVM_L2ToL1MessagePasser"));
}
/******************** /********************
...@@ -115,7 +102,7 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros ...@@ -115,7 +102,7 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros
) )
{ {
return ( return (
ovmL1MessageSender.getL1MessageSender() == resolve("OVM_L1CrossDomainMessenger") iOVM_L1MessageSender(resolve("OVM_L1MessageSender")).getL1MessageSender() == resolve("OVM_L1CrossDomainMessenger")
); );
} }
...@@ -131,6 +118,6 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros ...@@ -131,6 +118,6 @@ contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCros
override override
internal internal
{ {
ovmL2ToL1MessagePasser.passMessageToL1(_message); iOVM_L2ToL1MessagePasser(resolve("OVM_L2ToL1MessagePasser")).passMessageToL1(_message);
} }
} }
...@@ -51,11 +51,9 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -51,11 +51,9 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
/************* /*************
* Variables * * Variables *
*************/ *************/
uint256 internal forceInclusionPeriodSeconds; uint256 internal forceInclusionPeriodSeconds;
uint256 internal lastOVMTimestamp; uint256 internal lastOVMTimestamp;
address internal sequencer;
address internal decompressionPrecompileAddress;
Lib_RingBuffer.RingBuffer internal batches; Lib_RingBuffer.RingBuffer internal batches;
Lib_RingBuffer.RingBuffer internal queue; Lib_RingBuffer.RingBuffer internal queue;
...@@ -63,17 +61,28 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -63,17 +61,28 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
/*************** /***************
* Constructor * * Constructor *
***************/ ***************/
constructor( constructor(
address _libAddressManager, address _libAddressManager,
uint256 _forceInclusionPeriodSeconds uint256 _forceInclusionPeriodSeconds
) )
Lib_AddressResolver(_libAddressManager) Lib_AddressResolver(_libAddressManager)
{ {
sequencer = resolve("OVM_Sequencer");
decompressionPrecompileAddress = resolve("OVM_DecompressionPrecompileAddress");
forceInclusionPeriodSeconds = _forceInclusionPeriodSeconds; forceInclusionPeriodSeconds = _forceInclusionPeriodSeconds;
}
/********************
* Public Functions *
********************/
/**
* @inheritdoc iOVM_CanonicalTransactionChain
*/
function init()
override
public
{
batches.init( batches.init(
16, 16,
Lib_OVMCodec.RING_BUFFER_CTC_BATCHES, Lib_OVMCodec.RING_BUFFER_CTC_BATCHES,
...@@ -87,11 +96,6 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -87,11 +96,6 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
); );
} }
/********************
* Public Functions *
********************/
/** /**
* @inheritdoc iOVM_CanonicalTransactionChain * @inheritdoc iOVM_CanonicalTransactionChain
*/ */
...@@ -272,7 +276,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -272,7 +276,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
uint40 nextQueueIndex = getNextQueueIndex(); uint40 nextQueueIndex = getNextQueueIndex();
for (uint256 i = 0; i < _numQueuedTransactions; i++) { for (uint256 i = 0; i < _numQueuedTransactions; i++) {
if (msg.sender != sequencer) { if (msg.sender != resolve("OVM_Sequencer")) {
Lib_OVMCodec.QueueElement memory el = getQueueElement(nextQueueIndex); Lib_OVMCodec.QueueElement memory el = getQueueElement(nextQueueIndex);
require( require(
el.timestamp + forceInclusionPeriodSeconds < block.timestamp, el.timestamp + forceInclusionPeriodSeconds < block.timestamp,
...@@ -318,7 +322,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -318,7 +322,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
); );
require( require(
msg.sender == sequencer, msg.sender == resolve("OVM_Sequencer"),
"Function can only be called by the Sequencer." "Function can only be called by the Sequencer."
); );
...@@ -603,7 +607,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -603,7 +607,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
mstore(add(chainElementStart, 33), ctxBlockNumber) mstore(add(chainElementStart, 33), ctxBlockNumber)
calldatacopy(add(chainElementStart, BYTES_TILL_TX_DATA), add(_nextTransactionPtr, 3), _txDataLength) calldatacopy(add(chainElementStart, BYTES_TILL_TX_DATA), add(_nextTransactionPtr, 3), _txDataLength)
leafHash := keccak256(chainElementStart, add(BYTES_TILL_TX_DATA, _txDataLength)) leafHash := keccak256(chainElementStart, add(BYTES_TILL_TX_DATA, _txDataLength))
} }
...@@ -779,7 +783,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -779,7 +783,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
require( require(
_transaction.blockNumber == _txChainElement.blockNumber _transaction.blockNumber == _txChainElement.blockNumber
&& _transaction.timestamp == _txChainElement.timestamp && _transaction.timestamp == _txChainElement.timestamp
&& _transaction.entrypoint == decompressionPrecompileAddress && _transaction.entrypoint == resolve("OVM_DecompressionPrecompileAddress")
&& _transaction.gasLimit == gasLimit && _transaction.gasLimit == gasLimit
&& _transaction.l1TxOrigin == address(0) && _transaction.l1TxOrigin == address(0)
&& _transaction.l1QueueOrigin == Lib_OVMCodec.QueueOrigin.SEQUENCER_QUEUE && _transaction.l1QueueOrigin == Lib_OVMCodec.QueueOrigin.SEQUENCER_QUEUE
......
...@@ -36,9 +36,6 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -36,9 +36,6 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
uint256 internal lastDeletableIndex; uint256 internal lastDeletableIndex;
uint256 internal lastDeletableTimestamp; uint256 internal lastDeletableTimestamp;
Lib_RingBuffer.RingBuffer internal batches; Lib_RingBuffer.RingBuffer internal batches;
iOVM_CanonicalTransactionChain internal ovmCanonicalTransactionChain;
iOVM_FraudVerifier internal ovmFraudVerifier;
iOVM_BondManager internal ovmBondManager;
/*************** /***************
...@@ -50,13 +47,20 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -50,13 +47,20 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
*/ */
constructor( constructor(
address _libAddressManager address _libAddressManager
) ) Lib_AddressResolver(_libAddressManager) {}
Lib_AddressResolver(_libAddressManager)
{
ovmCanonicalTransactionChain = iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain"));
ovmFraudVerifier = iOVM_FraudVerifier(resolve("OVM_FraudVerifier"));
ovmBondManager = iOVM_BondManager(resolve("OVM_BondManager"));
/********************
* Public Functions *
********************/
/**
* @inheritdoc iOVM_StateCommitmentChain
*/
function init()
override
public
{
batches.init( batches.init(
16, 16,
Lib_OVMCodec.RING_BUFFER_SCC_BATCHES, Lib_OVMCodec.RING_BUFFER_SCC_BATCHES,
...@@ -64,11 +68,6 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -64,11 +68,6 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
); );
} }
/********************
* Public Functions *
********************/
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc iOVM_StateCommitmentChain
*/ */
...@@ -132,7 +131,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -132,7 +131,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
// Proposers must have previously staked at the BondManager // Proposers must have previously staked at the BondManager
require( require(
ovmBondManager.isCollateralized(msg.sender), iOVM_BondManager(resolve("OVM_BondManager")).isCollateralized(msg.sender),
"Proposer does not have enough collateral posted" "Proposer does not have enough collateral posted"
); );
...@@ -142,7 +141,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -142,7 +141,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
); );
require( require(
getTotalElements() + _batch.length <= ovmCanonicalTransactionChain.getTotalElements(), getTotalElements() + _batch.length <= iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")).getTotalElements(),
"Number of state roots cannot exceed the number of canonical transactions." "Number of state roots cannot exceed the number of canonical transactions."
); );
...@@ -164,7 +163,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -164,7 +163,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
public public
{ {
require( require(
msg.sender == address(ovmFraudVerifier), msg.sender == resolve("OVM_FraudVerifier"),
"State batches can only be deleted by the OVM_FraudVerifier." "State batches can only be deleted by the OVM_FraudVerifier."
); );
...@@ -269,7 +268,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -269,7 +268,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
); );
require( require(
ovmCanonicalTransactionChain.verifyTransaction( iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")).verifyTransaction(
_transaction, _transaction,
_txChainElement, _txChainElement,
_txBatchHeader, _txBatchHeader,
...@@ -297,7 +296,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw ...@@ -297,7 +296,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, iRingBufferOverw
) )
{ {
if (_id == Lib_OVMCodec.RING_BUFFER_CTC_QUEUE) { if (_id == Lib_OVMCodec.RING_BUFFER_CTC_QUEUE) {
return ovmCanonicalTransactionChain.getQueueElement(_index / 2).timestamp < lastDeletableTimestamp; return iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")).getQueueElement(_index / 2).timestamp < lastDeletableTimestamp;
} else { } else {
return _index < lastDeletableIndex; return _index < lastDeletableIndex;
} }
......
...@@ -64,7 +64,6 @@ contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver { ...@@ -64,7 +64,6 @@ contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver {
{ {
owner = msg.sender; owner = msg.sender;
token = _token; token = _token;
ovmFraudVerifier = resolve("OVM_FraudVerifier");
} }
...@@ -75,7 +74,7 @@ contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver { ...@@ -75,7 +74,7 @@ contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver {
/// Adds `who` to the list of witnessProviders for the provided `preStateRoot`. /// Adds `who` to the list of witnessProviders for the provided `preStateRoot`.
function recordGasSpent(bytes32 _preStateRoot, address who, uint256 gasSpent) override public { function recordGasSpent(bytes32 _preStateRoot, address who, uint256 gasSpent) override public {
// The sender must be the transitioner that corresponds to the claimed pre-state root // The sender must be the transitioner that corresponds to the claimed pre-state root
address transitioner = address(iOVM_FraudVerifier(ovmFraudVerifier).getStateTransitioner(_preStateRoot)); address transitioner = address(iOVM_FraudVerifier(resolve("OVM_FraudVerifier")).getStateTransitioner(_preStateRoot));
require(transitioner == msg.sender, Errors.ONLY_TRANSITIONER); require(transitioner == msg.sender, Errors.ONLY_TRANSITIONER);
witnessProviders[_preStateRoot].total += gasSpent; witnessProviders[_preStateRoot].total += gasSpent;
...@@ -85,7 +84,7 @@ contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver { ...@@ -85,7 +84,7 @@ contract OVM_BondManager is iOVM_BondManager, Lib_AddressResolver {
/// Slashes + distributes rewards or frees up the sequencer's bond, only called by /// Slashes + distributes rewards or frees up the sequencer's bond, only called by
/// `FraudVerifier.finalizeFraudVerification` /// `FraudVerifier.finalizeFraudVerification`
function finalize(bytes32 _preStateRoot, uint256 batchIndex, address publisher, uint256 timestamp) override public { function finalize(bytes32 _preStateRoot, uint256 batchIndex, address publisher, uint256 timestamp) override public {
require(msg.sender == ovmFraudVerifier, Errors.ONLY_FRAUD_VERIFIER); require(msg.sender == resolve("OVM_FraudVerifier"), Errors.ONLY_FRAUD_VERIFIER);
require(witnessProviders[_preStateRoot].canClaim == false, Errors.ALREADY_FINALIZED); require(witnessProviders[_preStateRoot].canClaim == false, Errors.ALREADY_FINALIZED);
// allow users to claim from that state root's // allow users to claim from that state root's
......
...@@ -2,18 +2,17 @@ ...@@ -2,18 +2,17 @@
pragma solidity ^0.7.0; pragma solidity ^0.7.0;
import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol"; import { iOVM_BondManager } from "../../iOVM/verification/iOVM_BondManager.sol";
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
/// Minimal contract to be inherited by contracts consumed by users that provide /// Minimal contract to be inherited by contracts consumed by users that provide
/// data for fraud proofs /// data for fraud proofs
contract OVM_FraudContributor { abstract contract OVM_FraudContributor is Lib_AddressResolver {
iOVM_BondManager internal ovmBondManager;
/// Decorate your functions with this modifier to store how much total gas was /// Decorate your functions with this modifier to store how much total gas was
/// consumed by the sender, to reward users fairly /// consumed by the sender, to reward users fairly
modifier contributesToFraudProof(bytes32 preStateRoot) { modifier contributesToFraudProof(bytes32 preStateRoot) {
uint startGas = gasleft(); uint startGas = gasleft();
_; _;
uint gasSpent = startGas - gasleft(); uint gasSpent = startGas - gasleft();
ovmBondManager.recordGasSpent(preStateRoot, msg.sender, gasSpent); iOVM_BondManager(resolve('OVM_BondManager')).recordGasSpent(preStateRoot, msg.sender, gasSpent);
} }
} }
...@@ -19,16 +19,8 @@ import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalT ...@@ -19,16 +19,8 @@ import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalT
/* Contract Imports */ /* Contract Imports */
import { OVM_FraudContributor } from "./OVM_FraudContributor.sol"; import { OVM_FraudContributor } from "./OVM_FraudContributor.sol";
contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_AddressResolver { contract OVM_FraudVerifier is Lib_AddressResolver, OVM_FraudContributor, iOVM_FraudVerifier {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
iOVM_StateCommitmentChain internal ovmStateCommitmentChain;
iOVM_CanonicalTransactionChain internal ovmCanonicalTransactionChain;
/******************************************* /*******************************************
* Contract Variables: Internal Accounting * * Contract Variables: Internal Accounting *
*******************************************/ *******************************************/
...@@ -47,11 +39,7 @@ contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_Addr ...@@ -47,11 +39,7 @@ contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_Addr
address _libAddressManager address _libAddressManager
) )
Lib_AddressResolver(_libAddressManager) Lib_AddressResolver(_libAddressManager)
{ {}
ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain"));
ovmCanonicalTransactionChain = iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain"));
ovmBondManager = iOVM_BondManager(resolve("OVM_BondManager"));
}
/*************************************** /***************************************
...@@ -107,6 +95,9 @@ contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_Addr ...@@ -107,6 +95,9 @@ contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_Addr
if (_hasStateTransitioner(_preStateRoot)) { if (_hasStateTransitioner(_preStateRoot)) {
return; return;
} }
iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain"));
iOVM_CanonicalTransactionChain ovmCanonicalTransactionChain = iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain"));
require( require(
ovmStateCommitmentChain.verifyStateCommitment( ovmStateCommitmentChain.verifyStateCommitment(
...@@ -159,6 +150,8 @@ contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_Addr ...@@ -159,6 +150,8 @@ contract OVM_FraudVerifier is OVM_FraudContributor, iOVM_FraudVerifier, Lib_Addr
contributesToFraudProof(_preStateRoot) contributesToFraudProof(_preStateRoot)
{ {
iOVM_StateTransitioner transitioner = transitioners[_preStateRoot]; iOVM_StateTransitioner transitioner = transitioners[_preStateRoot];
iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain(resolve("OVM_StateCommitmentChain"));
iOVM_BondManager ovmBondManager = iOVM_BondManager(resolve("OVM_BondManager"));
require( require(
transitioner.isComplete() == true, transitioner.isComplete() == true,
......
...@@ -21,7 +21,7 @@ import { OVM_FraudContributor } from "./OVM_FraudContributor.sol"; ...@@ -21,7 +21,7 @@ import { OVM_FraudContributor } from "./OVM_FraudContributor.sol";
/** /**
* @title OVM_StateTransitioner * @title OVM_StateTransitioner
*/ */
contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner, Lib_AddressResolver { contract OVM_StateTransitioner is Lib_AddressResolver, OVM_FraudContributor, iOVM_StateTransitioner {
/******************* /*******************
* Data Structures * * Data Structures *
...@@ -38,7 +38,6 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner, ...@@ -38,7 +38,6 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner,
* Contract Variables: Contract References * * Contract Variables: Contract References *
*******************************************/ *******************************************/
iOVM_ExecutionManager internal ovmExecutionManager;
iOVM_StateManager internal ovmStateManager; iOVM_StateManager internal ovmStateManager;
...@@ -76,9 +75,7 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner, ...@@ -76,9 +75,7 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner,
postStateRoot = _preStateRoot; postStateRoot = _preStateRoot;
transactionHash = _transactionHash; transactionHash = _transactionHash;
ovmExecutionManager = iOVM_ExecutionManager(resolve("OVM_ExecutionManager"));
ovmStateManager = iOVM_StateManagerFactory(resolve("OVM_StateManagerFactory")).create(address(this)); ovmStateManager = iOVM_StateManagerFactory(resolve("OVM_StateManagerFactory")).create(address(this));
ovmBondManager = iOVM_BondManager(resolve("OVM_BondManager"));
} }
...@@ -100,7 +97,7 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner, ...@@ -100,7 +97,7 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner,
_; _;
} }
/********************************** /**********************************
* Public Functions: State Access * * Public Functions: State Access *
**********************************/ **********************************/
...@@ -317,10 +314,12 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner, ...@@ -317,10 +314,12 @@ contract OVM_StateTransitioner is OVM_FraudContributor, iOVM_StateTransitioner,
"Invalid transaction provided." "Invalid transaction provided."
); );
iOVM_ExecutionManager ovmExecutionManager = iOVM_ExecutionManager(resolve("OVM_ExecutionManager"));
// We call `setExecutionManager` right before `run` (and not earlier) just in case the // We call `setExecutionManager` right before `run` (and not earlier) just in case the
// OVM_ExecutionManager address was updated between the time when this contract was created // OVM_ExecutionManager address was updated between the time when this contract was created
// and when `applyTransaction` was called. // and when `applyTransaction` was called.
ovmStateManager.setExecutionManager(resolve("OVM_ExecutionManager")); ovmStateManager.setExecutionManager(address(ovmExecutionManager));
// `run` always succeeds *unless* the user hasn't provided enough gas to `applyTransaction` // `run` always succeeds *unless* the user hasn't provided enough gas to `applyTransaction`
// or an INVALID_STATE_ACCESS flag was triggered. Either way, we won't get beyond this line // or an INVALID_STATE_ACCESS flag was triggered. Either way, we won't get beyond this line
......
...@@ -52,6 +52,11 @@ interface iOVM_CanonicalTransactionChain { ...@@ -52,6 +52,11 @@ interface iOVM_CanonicalTransactionChain {
* Public Functions * * Public Functions *
********************/ ********************/
/**
* Initializes this contract.
*/
function init() external;
/** /**
* Retrieves the total number of elements submitted. * Retrieves the total number of elements submitted.
* @return _totalElements Total submitted elements. * @return _totalElements Total submitted elements.
......
...@@ -14,6 +14,11 @@ interface iOVM_StateCommitmentChain { ...@@ -14,6 +14,11 @@ interface iOVM_StateCommitmentChain {
* Public Functions * * Public Functions *
********************/ ********************/
/**
* Initializes this contract.
*/
function init() external;
/** /**
* Retrieves the total number of elements submitted. * Retrieves the total number of elements submitted.
* @return _totalElements Total submitted elements. * @return _totalElements Total submitted elements.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"all": "yarn clean && yarn build && yarn test && yarn lint:fix && yarn lint", "all": "yarn clean && yarn build && yarn test && yarn lint:fix && yarn lint",
"build": "yarn run build:contracts && yarn run build:typescript && yarn run build:copy && yarn run build:dump && yarn run build:typechain", "build": "yarn run build:contracts && yarn run build:typescript && yarn run build:copy && yarn run build:dump && yarn run build:typechain",
"build:typescript": "tsc -p tsconfig.prod.json", "build:typescript": "tsc -p tsconfig.prod.json",
"build:contracts": "buidler compile", "build:contracts": "buidler compile --show-stack-traces",
"build:dump": "ts-node \"bin/take-dump.ts\"", "build:dump": "ts-node \"bin/take-dump.ts\"",
"build:copy": "copyfiles -u 2 \"contracts/optimistic-ethereum/**/*.sol\" \"build/contracts\"", "build:copy": "copyfiles -u 2 \"contracts/optimistic-ethereum/**/*.sol\" \"build/contracts\"",
"build:typechain": "buidler typechain", "build:typechain": "buidler typechain",
......
...@@ -55,18 +55,23 @@ export const makeContractDeployConfig = async ( ...@@ -55,18 +55,23 @@ export const makeContractDeployConfig = async (
AddressManager.address, AddressManager.address,
config.transactionChainConfig.forceInclusionPeriodSeconds, config.transactionChainConfig.forceInclusionPeriodSeconds,
], ],
afterDeploy: async (): Promise<void> => { afterDeploy: async (contracts): Promise<void> => {
const sequencer = config.transactionChainConfig.sequencer const sequencer = config.transactionChainConfig.sequencer
const sequencerAddress = const sequencerAddress =
typeof sequencer === 'string' typeof sequencer === 'string'
? sequencer ? sequencer
: await sequencer.getAddress() : await sequencer.getAddress()
await AddressManager.setAddress('OVM_Sequencer', sequencerAddress) await AddressManager.setAddress('OVM_Sequencer', sequencerAddress)
await AddressManager.setAddress('Sequencer', sequencerAddress)
await contracts.OVM_CanonicalTransactionChain.init()
}, },
}, },
OVM_StateCommitmentChain: { OVM_StateCommitmentChain: {
factory: getContractFactory('OVM_StateCommitmentChain'), factory: getContractFactory('OVM_StateCommitmentChain'),
params: [AddressManager.address], params: [AddressManager.address],
afterDeploy: async (contracts): Promise<void> => {
await contracts.OVM_StateCommitmentChain.init()
},
}, },
OVM_DeployerWhitelist: { OVM_DeployerWhitelist: {
factory: getContractFactory('OVM_DeployerWhitelist'), factory: getContractFactory('OVM_DeployerWhitelist'),
......
...@@ -16,10 +16,6 @@ export interface DeployResult { ...@@ -16,10 +16,6 @@ export interface DeployResult {
export const deploy = async ( export const deploy = async (
config: RollupDeployConfig config: RollupDeployConfig
): Promise<DeployResult> => { ): Promise<DeployResult> => {
const Factory__SimpleProxy: ContractFactory = getContractFactory(
'Helper_SimpleProxy',
config.deploymentSigner
)
const AddressManager: Contract = await getContractFactory( const AddressManager: Contract = await getContractFactory(
'Lib_AddressManager', 'Lib_AddressManager',
config.deploymentSigner config.deploymentSigner
...@@ -42,16 +38,11 @@ export const deploy = async ( ...@@ -42,16 +38,11 @@ export const deploy = async (
continue continue
} }
const SimpleProxy = await Factory__SimpleProxy.deploy()
await AddressManager.setAddress(name, SimpleProxy.address)
contracts[`Proxy__${name}`] = SimpleProxy
try { try {
contracts[name] = await contractDeployParameters.factory contracts[name] = await contractDeployParameters.factory
.connect(config.deploymentSigner) .connect(config.deploymentSigner)
.deploy(...(contractDeployParameters.params || [])) .deploy(...(contractDeployParameters.params || []))
await SimpleProxy.setTarget(contracts[name].address) await AddressManager.setAddress(name, contracts[name].address)
} catch (err) { } catch (err) {
failedDeployments.push(name) failedDeployments.push(name)
} }
......
...@@ -206,6 +206,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -206,6 +206,7 @@ describe('OVM_CanonicalTransactionChain', () => {
AddressManager.address, AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS FORCE_INCLUSION_PERIOD_SECONDS
) )
await OVM_CanonicalTransactionChain.init()
}) })
describe('enqueue', () => { describe('enqueue', () => {
......
...@@ -73,6 +73,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -73,6 +73,7 @@ describe('OVM_StateCommitmentChain', () => {
OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy( OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy(
AddressManager.address AddressManager.address
) )
await OVM_StateCommitmentChain.init()
}) })
describe('appendStateBatch', () => { describe('appendStateBatch', () => {
......
...@@ -53,6 +53,7 @@ describe('OVM_FraudVerifier', () => { ...@@ -53,6 +53,7 @@ describe('OVM_FraudVerifier', () => {
Mock__OVM_StateTransitionerFactory = smockit( Mock__OVM_StateTransitionerFactory = smockit(
await ethers.getContractFactory('OVM_StateTransitionerFactory') await ethers.getContractFactory('OVM_StateTransitionerFactory')
) )
Mock__OVM_BondManager = smockit( Mock__OVM_BondManager = smockit(
await ethers.getContractFactory('OVM_BondManager') await ethers.getContractFactory('OVM_BondManager')
) )
......
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