Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.

Commit 1ca8f48

Browse files
maurelianben-chain
andauthored
Improving comments and some names (#211)
* Add missing interface function, and reorder funcs to match impl * Replace '@inheritdoc' with actual docs * Rename FraudContributor file with Abs prefix * fix imports and interface visibility * uncomment function to fix build process * Update contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol Co-authored-by: ben-chain <[email protected]> * rename BaseCrossDomainManager to indicate abstract status * fix return comment * Add missing override kw Co-authored-by: ben-chain <[email protected]>
1 parent 13b7dee commit 1ca8f48

15 files changed

+110
-59
lines changed

contracts/optimistic-ethereum/OVM/bridge/OVM_BaseCrossDomainMessenger.sol renamed to contracts/optimistic-ethereum/OVM/bridge/Abs_BaseCrossDomainMessenger.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ pragma solidity >0.5.0 <0.8.0;
33
pragma experimental ABIEncoderV2;
44

55
/* Interface Imports */
6-
import { iOVM_BaseCrossDomainMessenger } from "../../iOVM/bridge/iOVM_BaseCrossDomainMessenger.sol";
6+
import { iAbs_BaseCrossDomainMessenger } from "../../iOVM/bridge/iAbs_BaseCrossDomainMessenger.sol";
77

88
/* Library Imports */
99
import { Lib_ReentrancyGuard } from "../../libraries/utils/Lib_ReentrancyGuard.sol";
1010

1111
/**
12-
* @title OVM_BaseCrossDomainMessenger
12+
* @title Abs_BaseCrossDomainMessenger
1313
* @dev The Base Cross Domain Messenger is an abstract contract providing the interface and common functionality used in the
1414
* L1 and L2 Cross Domain Messengers. It can also serve as a template for developers wishing to implement a custom bridge
1515
* contract to suit their needs.
1616
*
1717
* Compiler used: defined by child contract
1818
* Runtime target: defined by child contract
1919
*/
20-
abstract contract OVM_BaseCrossDomainMessenger is iOVM_BaseCrossDomainMessenger, Lib_ReentrancyGuard {
20+
abstract contract Abs_BaseCrossDomainMessenger is iAbs_BaseCrossDomainMessenger, Lib_ReentrancyGuard {
2121

2222
/**********************
2323
* Contract Variables *

contracts/optimistic-ethereum/OVM/bridge/OVM_L1CrossDomainMessenger.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalT
1515
import { iOVM_StateCommitmentChain } from "../../iOVM/chain/iOVM_StateCommitmentChain.sol";
1616

1717
/* Contract Imports */
18-
import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol";
18+
import { Abs_BaseCrossDomainMessenger } from "./Abs_BaseCrossDomainMessenger.sol";
1919

2020
/**
2121
* @title OVM_L1CrossDomainMessenger
@@ -26,7 +26,7 @@ import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol
2626
* Compiler used: solc
2727
* Runtime target: EVM
2828
*/
29-
contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver {
29+
contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, Abs_BaseCrossDomainMessenger, Lib_AddressResolver {
3030

3131
/***************
3232
* Constructor *

contracts/optimistic-ethereum/OVM/bridge/OVM_L2CrossDomainMessenger.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ import { iOVM_L1MessageSender } from "../../iOVM/precompiles/iOVM_L1MessageSende
1212
import { iOVM_L2ToL1MessagePasser } from "../../iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol";
1313

1414
/* Contract Imports */
15-
import { OVM_BaseCrossDomainMessenger } from "./OVM_BaseCrossDomainMessenger.sol";
15+
import { Abs_BaseCrossDomainMessenger } from "./Abs_BaseCrossDomainMessenger.sol";
1616

1717
/**
1818
* @title OVM_L2CrossDomainMessenger
19-
* @dev The L2 Cross Domain Messenger contract sends messages from L2 to L1, and is the entry point for L2 messages sent via the L1 Cross Domain Messenger.
19+
* @dev The L2 Cross Domain Messenger contract sends messages from L2 to L1, and is the entry point
20+
* for L2 messages sent via the L1 Cross Domain Messenger.
2021
*
2122
* Compiler used: optimistic-solc
2223
* Runtime target: OVM
2324
*/
24-
contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, OVM_BaseCrossDomainMessenger, Lib_AddressResolver {
25+
contract OVM_L2CrossDomainMessenger is iOVM_L2CrossDomainMessenger, Abs_BaseCrossDomainMessenger, Lib_AddressResolver {
2526

2627
/***************
2728
* Constructor *

contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
8686
* @return Reference to the batch storage container.
8787
*/
8888
function batches()
89+
override
8990
public
9091
view
9192
returns (
@@ -102,6 +103,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
102103
* @return Reference to the queue storage container.
103104
*/
104105
function queue()
106+
override
105107
public
106108
view
107109
returns (
@@ -114,7 +116,8 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
114116
}
115117

116118
/**
117-
* @inheritdoc iOVM_CanonicalTransactionChain
119+
* Retrieves the total number of elements submitted.
120+
* @return _totalElements Total submitted elements.
118121
*/
119122
function getTotalElements()
120123
override
@@ -129,7 +132,8 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
129132
}
130133

131134
/**
132-
* @inheritdoc iOVM_CanonicalTransactionChain
135+
* Retrieves the total number of batches submitted.
136+
* @return _totalBatches Total submitted batches.
133137
*/
134138
function getTotalBatches()
135139
override
@@ -143,7 +147,8 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
143147
}
144148

145149
/**
146-
* @inheritdoc iOVM_CanonicalTransactionChain
150+
* Returns the index of the next element to be enqueued.
151+
* @return Index for the next queue element.
147152
*/
148153
function getNextQueueIndex()
149154
override
@@ -158,7 +163,9 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
158163
}
159164

160165
/**
161-
* @inheritdoc iOVM_CanonicalTransactionChain
166+
* Gets the queue element at a particular index.
167+
* @param _index Index of the queue element to access.
168+
* @return _element Queue element at the given index.
162169
*/
163170
function getQueueElement(
164171
uint256 _index
@@ -189,7 +196,8 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
189196
}
190197

191198
/**
192-
* @inheritdoc iOVM_CanonicalTransactionChain
199+
* Get the number of queue elements which have not yet been included.
200+
* @return Number of pending queue elements.
193201
*/
194202
function getNumPendingQueueElements()
195203
override
@@ -202,8 +210,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
202210
return getQueueLength() - getNextQueueIndex();
203211
}
204212

205-
/**
206-
* @inheritdoc iOVM_CanonicalTransactionChain
213+
/**
214+
* Retrieves the length of the queue, including
215+
* both pending and canonical transactions.
216+
* @return Length of the queue.
207217
*/
208218
function getQueueLength()
209219
override
@@ -220,7 +230,10 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
220230
}
221231

222232
/**
223-
* @inheritdoc iOVM_CanonicalTransactionChain
233+
* Adds a transaction to the queue.
234+
* @param _target Target L2 contract to send the transaction to.
235+
* @param _gasLimit Gas limit for the enqueued L2 transaction.
236+
* @param _data Transaction data.
224237
*/
225238
function enqueue(
226239
address _target,
@@ -297,7 +310,8 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
297310
}
298311

299312
/**
300-
* @inheritdoc iOVM_CanonicalTransactionChain
313+
* Appends a given number of queued transactions as a single batch.
314+
* @param _numQueuedTransactions Number of transactions to append.
301315
*/
302316
function appendQueueBatch(
303317
uint256 _numQueuedTransactions
@@ -347,7 +361,12 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
347361
}
348362

349363
/**
350-
* @inheritdoc iOVM_CanonicalTransactionChain
364+
* Allows the sequencer to append a batch of transactions.
365+
* @dev This function uses a custom encoding scheme for efficiency reasons.
366+
* .param _shouldStartAtElement Specific batch we expect to start appending to.
367+
* .param _totalElementsToAppend Total number of batch elements we expect to append.
368+
* .param _contexts Array of batch contexts.
369+
* .param _transactionDataFields Array of raw transaction data.
351370
*/
352371
function appendSequencerBatch()
353372
override
@@ -480,7 +499,12 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
480499
}
481500

482501
/**
483-
* @inheritdoc iOVM_CanonicalTransactionChain
502+
* Verifies whether a transaction is included in the chain.
503+
* @param _transaction Transaction to verify.
504+
* @param _txChainElement Transaction chain element corresponding to the transaction.
505+
* @param _batchHeader Header of the batch the transaction was included in.
506+
* @param _inclusionProof Inclusion proof for the provided transaction chain element.
507+
* @return True if the transaction exists in the CTC, false if not.
484508
*/
485509
function verifyTransaction(
486510
Lib_OVMCodec.Transaction memory _transaction,

contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ import { OVM_DeployerWhitelist } from "../precompiles/OVM_DeployerWhitelist.sol"
2020

2121
/**
2222
* @title OVM_ExecutionManager
23-
* @dev The Execution Manager (EM) is the core of our OVM implementation, and provides a sandboxed
24-
* environment allowing us to execute OVM transactions deterministically on either Layer 1 or
25-
* Layer 2.
23+
* @dev The Execution Manager (EM) is the core of our OVM implementation, and provides a sandboxed
24+
* environment allowing us to execute OVM transactions deterministically on either Layer 1 or
25+
* Layer 2.
2626
* The EM's run() function is the first function called during the execution of any
27-
* transaction on L2.
28-
* For each context-dependent EVM operation the EM has a function which implements a corresponding
27+
* transaction on L2.
28+
* For each context-dependent EVM operation the EM has a function which implements a corresponding
2929
* OVM operation, which will read state from the State Manager contract.
30-
* The EM relies on the Safety Checker to verify that code deployed to Layer 2 does not contain any
30+
* The EM relies on the Safety Checker to verify that code deployed to Layer 2 does not contain any
3131
* context-dependent operations.
32-
*
32+
*
3333
* Compiler used: solc
3434
* Runtime target: EVM
3535
*/

contracts/optimistic-ethereum/OVM/execution/OVM_StateManager.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol";
1010

1111
/**
1212
* @title OVM_StateManager
13-
* @dev The State Manager contract holds all storage values for contracts in the OVM. It can only be written to by the
13+
* @dev The State Manager contract holds all storage values for contracts in the OVM. It can only be written to by the
1414
* the Execution Manager and State Transitioner. It runs on L1 during the setup and execution of a fraud proof.
15-
* The same logic runs on L2, but has been implemented as a precompile in the L2 go-ethereum client
16-
* (see https://github.com/ethereum-optimism/go-ethereum/blob/master/core/vm/ovm_state_manager.go)
15+
* The same logic runs on L2, but has been implemented as a precompile in the L2 go-ethereum client
16+
* (see https://github.com/ethereum-optimism/go-ethereum/blob/master/core/vm/ovm_state_manager.go).
1717
*
1818
* Compiler used: solc
1919
* Runtime target: EVM

contracts/optimistic-ethereum/OVM/precompiles/OVM_ETH.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve
66

77
/* Interface Imports */
88
import { iOVM_ERC20 } from "../../iOVM/precompiles/iOVM_ERC20.sol";
9-
import { iOVM_BaseCrossDomainMessenger } from "../../iOVM/bridge/iOVM_BaseCrossDomainMessenger.sol";
109

1110
/**
1211
* @title OVM_ETH

contracts/optimistic-ethereum/OVM/verification/OVM_FraudContributor.sol renamed to contracts/optimistic-ethereum/OVM/verification/Abs_FraudContributor.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve
66

77
/// Minimal contract to be inherited by contracts consumed by users that provide
88
/// data for fraud proofs
9-
abstract contract OVM_FraudContributor is Lib_AddressResolver {
9+
abstract contract Abs_FraudContributor is Lib_AddressResolver {
1010
/// Decorate your functions with this modifier to store how much total gas was
1111
/// consumed by the sender, to reward users fairly
1212
modifier contributesToFraudProof(bytes32 preStateRoot, bytes32 txHash) {

contracts/optimistic-ethereum/OVM/verification/OVM_FraudVerifier.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { iOVM_StateCommitmentChain } from "../../iOVM/chain/iOVM_StateCommitment
1515
import { iOVM_CanonicalTransactionChain } from "../../iOVM/chain/iOVM_CanonicalTransactionChain.sol";
1616

1717
/* Contract Imports */
18-
import { OVM_FraudContributor } from "./OVM_FraudContributor.sol";
18+
import { Abs_FraudContributor } from "./Abs_FraudContributor.sol";
1919

2020

2121

@@ -28,7 +28,7 @@ import { OVM_FraudContributor } from "./OVM_FraudContributor.sol";
2828
* Compiler used: solc
2929
* Runtime target: EVM
3030
*/
31-
contract OVM_FraudVerifier is Lib_AddressResolver, OVM_FraudContributor, iOVM_FraudVerifier {
31+
contract OVM_FraudVerifier is Lib_AddressResolver, Abs_FraudContributor, iOVM_FraudVerifier {
3232

3333
/*******************************************
3434
* Contract Variables: Internal Accounting *

contracts/optimistic-ethereum/OVM/verification/OVM_StateTransitioner.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import { iOVM_StateManager } from "../../iOVM/execution/iOVM_StateManager.sol";
2121
import { iOVM_StateManagerFactory } from "../../iOVM/execution/iOVM_StateManagerFactory.sol";
2222

2323
/* Contract Imports */
24-
import { OVM_FraudContributor } from "./OVM_FraudContributor.sol";
24+
import { Abs_FraudContributor } from "./Abs_FraudContributor.sol";
2525

2626
/**
2727
* @title OVM_StateTransitioner
28-
* @dev The State Transitioner coordinates the execution of a state transition during the evaluation of a
29-
* fraud proof. It feeds verified input to the Execution Manager's run(), and controls a State Manager (which is
28+
* @dev The State Transitioner coordinates the execution of a state transition during the evaluation of a
29+
* fraud proof. It feeds verified input to the Execution Manager's run(), and controls a State Manager (which is
3030
* uniquely created for each fraud proof).
3131
* Once a fraud proof has been initialized, this contract is provided with the pre-state root and verifies
3232
* that the OVM storage slots committed to the State Mangager are contained in that state
@@ -37,7 +37,7 @@ import { OVM_FraudContributor } from "./OVM_FraudContributor.sol";
3737
* Compiler used: solc
3838
* Runtime target: EVM
3939
*/
40-
contract OVM_StateTransitioner is Lib_AddressResolver, OVM_FraudContributor, iOVM_StateTransitioner {
40+
contract OVM_StateTransitioner is Lib_AddressResolver, Abs_FraudContributor, iOVM_StateTransitioner {
4141

4242
/*******************
4343
* Data Structures *

0 commit comments

Comments
 (0)