Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
5ab0c536
Commit
5ab0c536
authored
Jul 20, 2023
by
Andreas Bigger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port merkle contracts to triple slash natspec styling
parent
609662bb
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
187 deletions
+126
-187
optimismportal.go
op-bindings/bindings/optimismportal.go
+1
-1
optimismportal_more.go
op-bindings/bindings/optimismportal_more.go
+1
-1
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+36
-36
MerkleTrie.sol
...contracts-bedrock/contracts/libraries/trie/MerkleTrie.sol
+62
-108
SecureMerkleTrie.sol
...cts-bedrock/contracts/libraries/trie/SecureMerkleTrie.sol
+26
-41
No files found.
op-bindings/bindings/optimismportal.go
View file @
5ab0c536
This diff is collapsed.
Click to expand it.
op-bindings/bindings/optimismportal_more.go
View file @
5ab0c536
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/.gas-snapshot
View file @
5ab0c536
...
@@ -124,7 +124,7 @@ GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (g
...
@@ -124,7 +124,7 @@ GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (g
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 88513)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 88513)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 75225)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 75225)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 75662)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 75662)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 1430
87
)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 1430
66
)
GasPriceOracle_Test:test_baseFee_succeeds() (gas: 8325)
GasPriceOracle_Test:test_baseFee_succeeds() (gas: 8325)
GasPriceOracle_Test:test_decimals_succeeds() (gas: 6167)
GasPriceOracle_Test:test_decimals_succeeds() (gas: 6167)
GasPriceOracle_Test:test_gasPrice_succeeds() (gas: 8294)
GasPriceOracle_Test:test_gasPrice_succeeds() (gas: 8294)
...
@@ -288,26 +288,26 @@ LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12957)
...
@@ -288,26 +288,26 @@ LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12957)
LegacyERC20ETH_Test:test_transfer_doesNotExist_reverts() (gas: 10755)
LegacyERC20ETH_Test:test_transfer_doesNotExist_reverts() (gas: 10755)
LegacyMessagePasser_Test:test_passMessageToL1_succeeds() (gas: 34524)
LegacyMessagePasser_Test:test_passMessageToL1_succeeds() (gas: 34524)
LibPosition_Test:test_pos_correctness_succeeds() (gas: 38689)
LibPosition_Test:test_pos_correctness_succeeds() (gas: 38689)
MerkleTrie_get_Test:test_get_corruptedProof_reverts() (gas: 573
6
)
MerkleTrie_get_Test:test_get_corruptedProof_reverts() (gas: 573
3
)
MerkleTrie_get_Test:test_get_extraProofElements_reverts() (gas: 58
907
)
MerkleTrie_get_Test:test_get_extraProofElements_reverts() (gas: 58
889
)
MerkleTrie_get_Test:test_get_invalidDataRemainder_reverts() (gas: 3584
8
)
MerkleTrie_get_Test:test_get_invalidDataRemainder_reverts() (gas: 3584
5
)
MerkleTrie_get_Test:test_get_invalidInternalNodeHash_reverts() (gas: 496
6
4)
MerkleTrie_get_Test:test_get_invalidInternalNodeHash_reverts() (gas: 496
5
4)
MerkleTrie_get_Test:test_get_nonexistentKey1_reverts() (gas: 547
85
)
MerkleTrie_get_Test:test_get_nonexistentKey1_reverts() (gas: 547
70
)
MerkleTrie_get_Test:test_get_nonexistentKey2_reverts() (gas: 16
70
9)
MerkleTrie_get_Test:test_get_nonexistentKey2_reverts() (gas: 16
69
9)
MerkleTrie_get_Test:test_get_smallerPathThanKey1_reverts() (gas: 514
18
)
MerkleTrie_get_Test:test_get_smallerPathThanKey1_reverts() (gas: 514
03
)
MerkleTrie_get_Test:test_get_smallerPathThanKey2_reverts() (gas: 528
99
)
MerkleTrie_get_Test:test_get_smallerPathThanKey2_reverts() (gas: 528
84
)
MerkleTrie_get_Test:test_get_validProof10_succeeds() (gas: 488
71
)
MerkleTrie_get_Test:test_get_validProof10_succeeds() (gas: 488
45
)
MerkleTrie_get_Test:test_get_validProof1_succeeds() (gas: 559
96
)
MerkleTrie_get_Test:test_get_validProof1_succeeds() (gas: 559
70
)
MerkleTrie_get_Test:test_get_validProof2_succeeds() (gas: 658
87
)
MerkleTrie_get_Test:test_get_validProof2_succeeds() (gas: 658
61
)
MerkleTrie_get_Test:test_get_validProof3_succeeds() (gas: 273
30
)
MerkleTrie_get_Test:test_get_validProof3_succeeds() (gas: 273
09
)
MerkleTrie_get_Test:test_get_validProof4_succeeds() (gas: 181
26
)
MerkleTrie_get_Test:test_get_validProof4_succeeds() (gas: 181
05
)
MerkleTrie_get_Test:test_get_validProof5_succeeds() (gas: 807
22
)
MerkleTrie_get_Test:test_get_validProof5_succeeds() (gas: 807
01
)
MerkleTrie_get_Test:test_get_validProof6_succeeds() (gas: 694
81
)
MerkleTrie_get_Test:test_get_validProof6_succeeds() (gas: 694
60
)
MerkleTrie_get_Test:test_get_validProof7_succeeds() (gas: 761
79
)
MerkleTrie_get_Test:test_get_validProof7_succeeds() (gas: 761
58
)
MerkleTrie_get_Test:test_get_validProof8_succeeds() (gas: 488
28
)
MerkleTrie_get_Test:test_get_validProof8_succeeds() (gas: 488
02
)
MerkleTrie_get_Test:test_get_validProof9_succeeds() (gas: 488
28
)
MerkleTrie_get_Test:test_get_validProof9_succeeds() (gas: 488
02
)
MerkleTrie_get_Test:test_get_wrongKeyProof_reverts() (gas: 507
4
0)
MerkleTrie_get_Test:test_get_wrongKeyProof_reverts() (gas: 507
3
0)
MerkleTrie_get_Test:test_get_zeroBranchValueLength_reverts() (gas: 416
97
)
MerkleTrie_get_Test:test_get_zeroBranchValueLength_reverts() (gas: 416
84
)
MerkleTrie_get_Test:test_get_zeroLengthKey_reverts() (gas: 3632)
MerkleTrie_get_Test:test_get_zeroLengthKey_reverts() (gas: 3632)
MintManager_constructor_Test:test_constructor_succeeds() (gas: 10579)
MintManager_constructor_Test:test_constructor_succeeds() (gas: 10579)
MintManager_mint_Test:test_mint_afterPeriodElapsed_succeeds() (gas: 148117)
MintManager_mint_Test:test_mint_afterPeriodElapsed_succeeds() (gas: 148117)
...
@@ -346,26 +346,26 @@ OptimismPortalUpgradeable_Test:test_initialize_cannotInitImpl_reverts() (gas: 10
...
@@ -346,26 +346,26 @@ OptimismPortalUpgradeable_Test:test_initialize_cannotInitImpl_reverts() (gas: 10
OptimismPortalUpgradeable_Test:test_initialize_cannotInitProxy_reverts() (gas: 15918)
OptimismPortalUpgradeable_Test:test_initialize_cannotInitProxy_reverts() (gas: 15918)
OptimismPortalUpgradeable_Test:test_params_initValuesOnProxy_succeeds() (gas: 21774)
OptimismPortalUpgradeable_Test:test_params_initValuesOnProxy_succeeds() (gas: 21774)
OptimismPortalUpgradeable_Test:test_upgradeToAndCall_upgrading_succeeds() (gas: 180547)
OptimismPortalUpgradeable_Test:test_upgradeToAndCall_upgrading_succeeds() (gas: 180547)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputRootChanges_reverts() (gas: 1778
72
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputRootChanges_reverts() (gas: 1778
51
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 1813
25
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 1813
04
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41731)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41731)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 1732
69
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 1732
48
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 1796
98
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 1796
77
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 1540
34
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 1540
13
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 2176
73
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 2176
52
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 219
411
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 219
390
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_paused_reverts() (gas: 53510)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_paused_reverts() (gas: 53510)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 2088
46
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 2088
25
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_targetFails_fails() (gas: 87977466876961626
60
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_targetFails_fails() (gas: 87977466876961626
59
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_timestampLessThanL2OracleStart_reverts() (gas: 1708
47
)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_timestampLessThanL2OracleStart_reverts() (gas: 1708
26
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidOutputRootProof_reverts() (gas: 85690)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidOutputRootProof_reverts() (gas: 85690)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidWithdrawalProof_reverts() (gas: 1112
1
2)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onInvalidWithdrawalProof_reverts() (gas: 1112
0
2)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onSelfCall_reverts() (gas: 52947)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_onSelfCall_reverts() (gas: 52947)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_paused_reverts() (gas: 73673)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_paused_reverts() (gas: 73673)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProveChangedOutputRootAndOutputIndex_succeeds() (gas: 294
439
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProveChangedOutputRootAndOutputIndex_succeeds() (gas: 294
397
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProveChangedOutputRoot_succeeds() (gas: 2272
71
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProveChangedOutputRoot_succeeds() (gas: 2272
29
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProve_reverts() (gas: 1663
98
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_replayProve_reverts() (gas: 1663
77
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_validWithdrawalProof_succeeds() (gas: 1543
36
)
OptimismPortal_FinalizeWithdrawal_Test:test_proveWithdrawalTransaction_validWithdrawalProof_succeeds() (gas: 1543
15
)
OptimismPortal_Test:test_constructor_succeeds() (gas: 19402)
OptimismPortal_Test:test_constructor_succeeds() (gas: 19402)
OptimismPortal_Test:test_depositTransaction_contractCreation_reverts() (gas: 14320)
OptimismPortal_Test:test_depositTransaction_contractCreation_reverts() (gas: 14320)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForContract_succeeds() (gas: 76791)
OptimismPortal_Test:test_depositTransaction_createWithZeroValueForContract_succeeds() (gas: 76791)
...
...
packages/contracts-bedrock/contracts/libraries/trie/MerkleTrie.sol
View file @
5ab0c536
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/contracts/libraries/trie/SecureMerkleTrie.sol
View file @
5ab0c536
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity ^0.8.0;
/* Library Imports */
import { MerkleTrie } from "./MerkleTrie.sol";
import { MerkleTrie } from "./MerkleTrie.sol";
/**
/// @title SecureMerkleTrie
* @title SecureMerkleTrie
/// @notice SecureMerkleTrie is a thin wrapper around the MerkleTrie library that hashes the input
* @notice SecureMerkleTrie is a thin wrapper around the MerkleTrie library that hashes the input
/// keys. Ethereum's state trie hashes input keys before storing them.
* keys. Ethereum's state trie hashes input keys before storing them.
*/
library SecureMerkleTrie {
library SecureMerkleTrie {
/**
/// @notice Verifies a proof that a given key/value pair is present in the Merkle trie.
* @notice Verifies a proof that a given key/value pair is present in the Merkle trie.
/// @param _key Key of the node to search for, as a hex string.
*
/// @param _value Value of the node to search for, as a hex string.
* @param _key Key of the node to search for, as a hex string.
/// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle
* @param _value Value of the node to search for, as a hex string.
/// trees, this proof is executed top-down and consists of a list of RLP-encoded
* @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle
/// nodes that make a path down to the target node.
* trees, this proof is executed top-down and consists of a list of RLP-encoded
/// @param _root Known root of the Merkle trie. Used to verify that the included proof is
* nodes that make a path down to the target node.
/// correctly constructed.
* @param _root Known root of the Merkle trie. Used to verify that the included proof is
/// @return valid_ Whether or not the proof is valid.
* correctly constructed.
*
* @return Whether or not the proof is valid.
*/
function verifyInclusionProof(
function verifyInclusionProof(
bytes memory _key,
bytes memory _key,
bytes memory _value,
bytes memory _value,
bytes[] memory _proof,
bytes[] memory _proof,
bytes32 _root
bytes32 _root
) internal pure returns (bool) {
) internal pure returns (bool
valid_
) {
bytes memory key = _getSecureKey(_key);
bytes memory key = _getSecureKey(_key);
return
MerkleTrie.verifyInclusionProof(key, _value, _proof, _root);
valid_ =
MerkleTrie.verifyInclusionProof(key, _value, _proof, _root);
}
}
/**
/// @notice Retrieves the value associated with a given key.
* @notice Retrieves the value associated with a given key.
/// @param _key Key to search for, as hex bytes.
*
/// @param _proof Merkle trie inclusion proof for the key.
* @param _key Key to search for, as hex bytes.
/// @param _root Known root of the Merkle trie.
* @param _proof Merkle trie inclusion proof for the key.
/// @return value_ Value of the key if it exists.
* @param _root Known root of the Merkle trie.
*
* @return Value of the key if it exists.
*/
function get(
function get(
bytes memory _key,
bytes memory _key,
bytes[] memory _proof,
bytes[] memory _proof,
bytes32 _root
bytes32 _root
) internal pure returns (bytes memory) {
) internal pure returns (bytes memory
value_
) {
bytes memory key = _getSecureKey(_key);
bytes memory key = _getSecureKey(_key);
return
MerkleTrie.get(key, _proof, _root);
value_ =
MerkleTrie.get(key, _proof, _root);
}
}
/**
/// @notice Computes the hashed version of the input key.
* @notice Computes the hashed version of the input key.
/// @param _key Key to hash.
*
/// @return hash_ Hashed version of the key.
* @param _key Key to hash.
function _getSecureKey(bytes memory _key) private pure returns (bytes memory hash_) {
*
hash_ = abi.encodePacked(keccak256(_key));
* @return Hashed version of the key.
*/
function _getSecureKey(bytes memory _key) private pure returns (bytes memory) {
return abi.encodePacked(keccak256(_key));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment