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
da9bcf53
Commit
da9bcf53
authored
Aug 03, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add event to block oracle checkpoint
parent
9beb8626
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
192 additions
and
8 deletions
+192
-8
blockoracle.go
op-bindings/bindings/blockoracle.go
+164
-2
blockoracle_more.go
op-bindings/bindings/blockoracle_more.go
+1
-1
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+1
-1
BlockOracle.sol
packages/contracts-bedrock/src/dispute/BlockOracle.sol
+13
-4
BlockOracle.t.sol
packages/contracts-bedrock/test/BlockOracle.t.sol
+13
-0
No files found.
op-bindings/bindings/blockoracle.go
View file @
da9bcf53
This diff is collapsed.
Click to expand it.
op-bindings/bindings/blockoracle_more.go
View file @
da9bcf53
...
@@ -13,7 +13,7 @@ const BlockOracleStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\"
...
@@ -13,7 +13,7 @@ const BlockOracleStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\"
var
BlockOracleStorageLayout
=
new
(
solc
.
StorageLayout
)
var
BlockOracleStorageLayout
=
new
(
solc
.
StorageLayout
)
var
BlockOracleDeployedBin
=
"0x608060405234801561001057600080fd5b50600436106100365760003560e01c806399d548aa1461003b578063c2c4c5c114610078575b600080fd5b61004e6100493660046101
84565b61008e565b604080518251815260209283015167ffffffffffffffff1692810192909252015b60405180910390f35b61008061010d565b60405190815260200161006f565b604080518082018252600080825260209182018190528381528082528281208351808501909452805480855260019091015467ffffffffffffffff169284019290925203610108576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b600061011a60014361019d565b604080518082018252824081524267ffffffffffffffff908116602080840191825260008681529081905293909320915182559151600190910180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001691909216179055919050565b60006020828403121561019657600080fd5b5035919050565b6000828210156101d6
577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50039056fea164736f6c634300080f000a"
var
BlockOracleDeployedBin
=
"0x608060405234801561001057600080fd5b50600436106100365760003560e01c806399d548aa1461003b578063c2c4c5c114610078575b600080fd5b61004e6100493660046101
b8565b61008e565b604080518251815260209283015167ffffffffffffffff1692810192909252015b60405180910390f35b61008061010d565b60405190815260200161006f565b604080518082018252600080825260209182018190528381528082528281208351808501909452805480855260019091015467ffffffffffffffff169284019290925203610108576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b600061011a6001436101d1565b60408051808201825282408082524267ffffffffffffffff81811660208086018281526000898152918290528782209651875551600190960180547fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000016969093169590951790915593519495509093909291849186917fb67ff58b33060fd371a35ae2d9f1c3cdaec9b8197969f6efe2594a1ff4ba68c691a4505090565b6000602082840312156101ca57600080fd5b5035919050565b60008282101561020a
577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50039056fea164736f6c634300080f000a"
func
init
()
{
func
init
()
{
if
err
:=
json
.
Unmarshal
([]
byte
(
BlockOracleStorageLayoutJSON
),
BlockOracleStorageLayout
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
BlockOracleStorageLayoutJSON
),
BlockOracleStorageLayout
);
err
!=
nil
{
...
...
packages/contracts-bedrock/.gas-snapshot
View file @
da9bcf53
...
@@ -16,7 +16,7 @@ AssetReceiverTest:test_withdrawETHwithAmount_unauthorized_reverts() (gas: 10738)
...
@@ -16,7 +16,7 @@ AssetReceiverTest:test_withdrawETHwithAmount_unauthorized_reverts() (gas: 10738)
AttestationStationTest:test_attest_bulk_succeeds() (gas: 703740)
AttestationStationTest:test_attest_bulk_succeeds() (gas: 703740)
AttestationStationTest:test_attest_individual_succeeds() (gas: 632078)
AttestationStationTest:test_attest_individual_succeeds() (gas: 632078)
AttestationStationTest:test_attest_single_succeeds() (gas: 651316)
AttestationStationTest:test_attest_single_succeeds() (gas: 651316)
BlockOracle_Test:test_checkpointAndLoad_succeeds() (gas: 5
1465
)
BlockOracle_Test:test_checkpointAndLoad_succeeds() (gas: 5
8341
)
BlockOracle_Test:test_load_noBlockHash_reverts() (gas: 12805)
BlockOracle_Test:test_load_noBlockHash_reverts() (gas: 12805)
Bytes_slice_Test:test_slice_acrossMultipleWords_works() (gas: 9413)
Bytes_slice_Test:test_slice_acrossMultipleWords_works() (gas: 9413)
Bytes_slice_Test:test_slice_acrossWords_works() (gas: 1430)
Bytes_slice_Test:test_slice_acrossWords_works() (gas: 1430)
...
...
packages/contracts-bedrock/src/dispute/BlockOracle.sol
View file @
da9bcf53
...
@@ -13,6 +13,13 @@ contract BlockOracle {
...
@@ -13,6 +13,13 @@ contract BlockOracle {
Timestamp childTimestamp;
Timestamp childTimestamp;
}
}
/// @notice Emitted when a block is checkpointed.
event Checkpoint(
uint256 indexed blockNumber,
Hash indexed blockHash,
Timestamp indexed childTimestamp
);
/// @notice Maps block numbers to block hashes and timestamps
/// @notice Maps block numbers to block hashes and timestamps
mapping(uint256 => BlockInfo) internal blocks;
mapping(uint256 => BlockInfo) internal blocks;
...
@@ -33,9 +40,11 @@ contract BlockOracle {
...
@@ -33,9 +40,11 @@ contract BlockOracle {
// and in the case of `block.number = 0`, we'll underflow.
// and in the case of `block.number = 0`, we'll underflow.
// Persist the block information.
// Persist the block information.
blockNumber_ = block.number - 1;
blockNumber_ = block.number - 1;
blocks[blockNumber_] = BlockInfo({
Hash blockHash = Hash.wrap(blockhash(blockNumber_));
hash: Hash.wrap(blockhash(blockNumber_)),
Timestamp childTimestamp = Timestamp.wrap(uint64(block.timestamp));
childTimestamp: Timestamp.wrap(uint64(block.timestamp))
});
blocks[blockNumber_] = BlockInfo({ hash: blockHash, childTimestamp: childTimestamp });
emit Checkpoint(blockNumber_, blockHash, childTimestamp);
}
}
}
}
packages/contracts-bedrock/test/BlockOracle.t.sol
View file @
da9bcf53
...
@@ -9,6 +9,13 @@ import "src/libraries/DisputeErrors.sol";
...
@@ -9,6 +9,13 @@ import "src/libraries/DisputeErrors.sol";
contract BlockOracle_Test is Test {
contract BlockOracle_Test is Test {
BlockOracle oracle;
BlockOracle oracle;
/// @notice Emitted when a block is checkpointed.
event Checkpoint(
uint256 indexed blockNumber,
Hash indexed blockHash,
Timestamp indexed childTimestamp
);
function setUp() public {
function setUp() public {
oracle = new BlockOracle();
oracle = new BlockOracle();
// Roll the chain forward 1 block.
// Roll the chain forward 1 block.
...
@@ -18,6 +25,12 @@ contract BlockOracle_Test is Test {
...
@@ -18,6 +25,12 @@ contract BlockOracle_Test is Test {
/// @notice Tests that checkpointing a block and loading its information succeeds.
/// @notice Tests that checkpointing a block and loading its information succeeds.
function test_checkpointAndLoad_succeeds() public {
function test_checkpointAndLoad_succeeds() public {
vm.expectEmit(true, true, true, false);
emit Checkpoint(
block.number - 1,
Hash.wrap(blockhash(block.number - 1)),
Timestamp.wrap(uint64(block.timestamp))
);
oracle.checkpoint();
oracle.checkpoint();
uint256 blockNumber = block.number - 1;
uint256 blockNumber = block.number - 1;
BlockOracle.BlockInfo memory res = oracle.load(blockNumber);
BlockOracle.BlockInfo memory res = oracle.load(blockNumber);
...
...
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