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
652732fc
Commit
652732fc
authored
Aug 03, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify proposal storage
parent
e89bb46d
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
101 additions
and
88 deletions
+101
-88
blockoracle.go
op-bindings/bindings/blockoracle.go
+1
-1
blockoracle_more.go
op-bindings/bindings/blockoracle_more.go
+1
-1
faultdisputegame.go
op-bindings/bindings/faultdisputegame.go
+31
-29
faultdisputegame_more.go
op-bindings/bindings/faultdisputegame_more.go
+2
-2
deploy.go
op-e2e/e2eutils/disputegame/deploy.go
+1
-1
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+24
-24
BlockOracle.sol
packages/contracts-bedrock/src/dispute/BlockOracle.sol
+2
-1
FaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
+24
-19
IFaultDisputeGame.sol
...acts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
+6
-0
FaultDisputeGame.t.sol
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
+9
-10
No files found.
op-bindings/bindings/blockoracle.go
View file @
652732fc
...
...
@@ -37,7 +37,7 @@ type BlockOracleBlockInfo struct {
// BlockOracleMetaData contains all meta data concerning the BlockOracle contract.
var
BlockOracleMetaData
=
&
bind
.
MetaData
{
ABI
:
"[{
\"
inputs
\"
:[],
\"
name
\"
:
\"
BlockHashNotPresent
\"
,
\"
type
\"
:
\"
error
\"
},{
\"
inputs
\"
:[],
\"
name
\"
:
\"
checkpoint
\"
,
\"
outputs
\"
:[{
\"
internalType
\"
:
\"
uint256
\"
,
\"
name
\"
:
\"
blockNumber_
\"
,
\"
type
\"
:
\"
uint256
\"
}],
\"
stateMutability
\"
:
\"
nonpayable
\"
,
\"
type
\"
:
\"
function
\"
},{
\"
inputs
\"
:[{
\"
internalType
\"
:
\"
uint256
\"
,
\"
name
\"
:
\"
_blockNumber
\"
,
\"
type
\"
:
\"
uint256
\"
}],
\"
name
\"
:
\"
load
\"
,
\"
outputs
\"
:[{
\"
components
\"
:[{
\"
internalType
\"
:
\"
Hash
\"
,
\"
name
\"
:
\"
hash
\"
,
\"
type
\"
:
\"
bytes32
\"
},{
\"
internalType
\"
:
\"
Timestamp
\"
,
\"
name
\"
:
\"
childTimestamp
\"
,
\"
type
\"
:
\"
uint64
\"
}],
\"
internalType
\"
:
\"
structBlockOracle.BlockInfo
\"
,
\"
name
\"
:
\"
blockInfo_
\"
,
\"
type
\"
:
\"
tuple
\"
}],
\"
stateMutability
\"
:
\"
view
\"
,
\"
type
\"
:
\"
function
\"
}]"
,
Bin
:
"0x608060405234801561001057600080fd5b506101e
f806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806399d548aa1461003b578063c2c4c5c114610078575b600080fd5b61004e61004936600461018b565b61008e565b604080518251815260209283015167ffffffffffffffff1692810192909252015b60405180910390f35b61008061010d565b60405190815260200161006f565b604080518082018252600080825260209182018190528381528082528281208351808501909452805480855260019091015467ffffffffffffffff169284019290925203610108576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000604051806040016040528060014361012791906101a4565b804082524267ffffffffffffffff908116602093840152600082815280845260409020845181559390920151600190930180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001693909216929092179055919050565b60006020828403121561019d57600080fd5b5035919050565b6000828210156101dd
577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50039056fea164736f6c634300080f000a"
,
Bin
:
"0x608060405234801561001057600080fd5b506101e
8806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806399d548aa1461003b578063c2c4c5c114610078575b600080fd5b61004e610049366004610184565b61008e565b604080518251815260209283015167ffffffffffffffff1692810192909252015b60405180910390f35b61008061010d565b60405190815260200161006f565b604080518082018252600080825260209182018190528381528082528281208351808501909452805480855260019091015467ffffffffffffffff169284019290925203610108576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b600061011a60014361019d565b604080518082018252824081524267ffffffffffffffff908116602080840191825260008681529081905293909320915182559151600190910180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001691909216179055919050565b60006020828403121561019657600080fd5b5035919050565b6000828210156101d6
577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50039056fea164736f6c634300080f000a"
,
}
// BlockOracleABI is the input ABI used to generate the binding from.
...
...
op-bindings/bindings/blockoracle_more.go
View file @
652732fc
...
...
@@ -13,7 +13,7 @@ const BlockOracleStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\"
var
BlockOracleStorageLayout
=
new
(
solc
.
StorageLayout
)
var
BlockOracleDeployedBin
=
"0x608060405234801561001057600080fd5b50600436106100365760003560e01c806399d548aa1461003b578063c2c4c5c114610078575b600080fd5b61004e61004936600461018
b565b61008e565b604080518251815260209283015167ffffffffffffffff1692810192909252015b60405180910390f35b61008061010d565b60405190815260200161006f565b604080518082018252600080825260209182018190528381528082528281208351808501909452805480855260019091015467ffffffffffffffff169284019290925203610108576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000604051806040016040528060014361012791906101a4565b804082524267ffffffffffffffff908116602093840152600082815280845260409020845181559390920151600190930180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001693909216929092179055919050565b60006020828403121561019d57600080fd5b5035919050565b6000828210156101dd
577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50039056fea164736f6c634300080f000a"
var
BlockOracleDeployedBin
=
"0x608060405234801561001057600080fd5b50600436106100365760003560e01c806399d548aa1461003b578063c2c4c5c114610078575b600080fd5b61004e61004936600461018
4565b61008e565b604080518251815260209283015167ffffffffffffffff1692810192909252015b60405180910390f35b61008061010d565b60405190815260200161006f565b604080518082018252600080825260209182018190528381528082528281208351808501909452805480855260019091015467ffffffffffffffff169284019290925203610108576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b600061011a60014361019d565b604080518082018252824081524267ffffffffffffffff908116602080840191825260008681529081905293909320915182559151600190910180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001691909216179055919050565b60006020828403121561019657600080fd5b5035919050565b6000828210156101d6
577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b50039056fea164736f6c634300080f000a"
func
init
()
{
if
err
:=
json
.
Unmarshal
([]
byte
(
BlockOracleStorageLayoutJSON
),
BlockOracleStorageLayout
);
err
!=
nil
{
...
...
op-bindings/bindings/faultdisputegame.go
View file @
652732fc
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame_more.go
View file @
652732fc
This diff is collapsed.
Click to expand it.
op-e2e/e2eutils/disputegame/deploy.go
View file @
652732fc
...
...
@@ -73,7 +73,7 @@ func deployDisputeGameContracts(require *require.Assertions, ctx context.Context
big
.
NewInt
(
alphabetGameDepth
),
gameDuration
,
alphaVMAddr
,
config
.
L1Deployments
.
L2OutputOracle
,
config
.
L1Deployments
.
L2OutputOracle
Proxy
,
blockHashOracleAddr
,
)
require
.
NoError
(
err
)
...
...
packages/contracts-bedrock/.gas-snapshot
View file @
652732fc
...
...
@@ -16,7 +16,7 @@ AssetReceiverTest:test_withdrawETHwithAmount_unauthorized_reverts() (gas: 10738)
AttestationStationTest:test_attest_bulk_succeeds() (gas: 703740)
AttestationStationTest:test_attest_individual_succeeds() (gas: 632078)
AttestationStationTest:test_attest_single_succeeds() (gas: 651316)
BlockOracle_Test:test_checkpointAndLoad_succeeds() (gas: 514
77
)
BlockOracle_Test:test_checkpointAndLoad_succeeds() (gas: 514
65
)
BlockOracle_Test:test_load_noBlockHash_reverts() (gas: 12805)
Bytes_slice_Test:test_slice_acrossMultipleWords_works() (gas: 9413)
Bytes_slice_Test:test_slice_acrossWords_works() (gas: 1430)
...
...
@@ -87,37 +87,37 @@ FaucetTest:test_nonAdmin_drip_fails() (gas: 262520)
FaucetTest:test_receive_succeeds() (gas: 17401)
FaucetTest:test_withdraw_nonAdmin_reverts() (gas: 13145)
FaucetTest:test_withdraw_succeeds() (gas: 78359)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 4988
66
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 505
60
8)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 5023
43
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 5055
50
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 5048
39
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 4976
31
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 504
37
3)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 5011
08
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 5023
15
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 5016
04
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 4988
44
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 505
71
8)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 5023
87
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 5055
94
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 5048
83
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 4976
09
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 504
48
3)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 5011
52
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 5023
59
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 5016
48
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 32354)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 32806)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10
410
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10
388
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8266)
FaultDisputeGame_Test:test_initialize_correctData_succeeds() (gas: 5
822
6)
FaultDisputeGame_Test:test_initialize_correctData_succeeds() (gas: 5
771
6)
FaultDisputeGame_Test:test_initialize_firstOutput_reverts() (gas: 210532)
FaultDisputeGame_Test:test_initialize_l1HeadTooOld_reverts() (gas: 228
357
)
FaultDisputeGame_Test:test_initialize_l1HeadTooOld_reverts() (gas: 228
402
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 415921)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 26428)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 133
22
)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 133
88
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 103377)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 408
316
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 110
46
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
23
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 408
294
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 110
24
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
89
)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 107300)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 2248
47
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 96
86
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 1098
82
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 214
65
)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27
322
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 395
519
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 2248
69
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 96
64
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 1098
38
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 214
43
)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27
278
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 395
607
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8253)
FeeVault_Test:test_constructor_succeeds() (gas: 18185)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352113)
...
...
packages/contracts-bedrock/src/dispute/BlockOracle.sol
View file @
652732fc
...
...
@@ -32,8 +32,9 @@ contract BlockOracle {
// SAFETY: This block hash will always be accessible by the `BLOCKHASH` opcode,
// and in the case of `block.number = 0`, we'll underflow.
// Persist the block information.
blockNumber_ = block.number - 1;
blocks[blockNumber_] = BlockInfo({
hash: Hash.wrap(blockhash(blockNumber_
= block.number - 1
)),
hash: Hash.wrap(blockhash(blockNumber_)),
childTimestamp: Timestamp.wrap(uint64(block.timestamp))
});
}
...
...
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
View file @
652732fc
...
...
@@ -67,7 +67,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
/// @notice The starting and disputed output proposal for the game. Includes information about
/// the output indexes in the `L2OutputOracle` and the output roots at the time of
/// game creation.
OutputProposal
[2]
public proposals;
OutputProposal
s
public proposals;
/// @notice An internal mapping to allow for constant-time lookups of existing claims.
mapping(ClaimHash => bool) internal claims;
...
...
@@ -281,18 +281,21 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
if (_ident == 1) {
// Load the L1 head hash into the game's local context in the preimage oracle.
oracle.loadLocalData(_ident, Hash.unwrap(l1Head), 32, _partOffset);
} else if (_ident < 4) {
// Grab the index of the proposal to load at the given ident.
// Ident 2 loads the starting output root, and ident 3 loads the disputed output root.
uint256 proposal;
assembly {
proposal := iszero(mod(_ident, 2))
}
} else if (_ident == 2) {
// Load the starting or disputed output root into the game's local context in the
// preimage oracle.
oracle.loadLocalData(
_ident,
Hash.unwrap(proposals.starting.outputRoot),
32,
_partOffset
);
} else if (_ident == 3) {
// Load the starting or disputed output root into the game's local context in the
// preimage oracle.
oracle.loadLocalData(
_ident,
Hash.unwrap(proposals
[proposal]
.outputRoot),
Hash.unwrap(proposals
.disputed
.outputRoot),
32,
_partOffset
);
...
...
@@ -302,7 +305,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
// of the passed word.
oracle.loadLocalData(
_ident,
bytes32(uint256(proposals
[0]
.l2BlockNumber) << 192),
bytes32(uint256(proposals
.starting
.l2BlockNumber) << 192),
8,
_partOffset
);
...
...
@@ -496,15 +499,17 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
// for loading local data into the preimage oracle as well as to authenticate the game's
// resolution. If the disputed output has changed in the oracle, the game cannot be
// resolved.
proposals[0] = OutputProposal({
index: uint128(proposalIdx - 1),
l2BlockNumber: starting.l2BlockNumber,
outputRoot: Hash.wrap(starting.outputRoot)
});
proposals[1] = OutputProposal({
index: uint128(proposalIdx),
l2BlockNumber: disputed.l2BlockNumber,
outputRoot: Hash.wrap(disputed.outputRoot)
proposals = OutputProposals({
starting: OutputProposal({
index: uint128(proposalIdx - 1),
l2BlockNumber: starting.l2BlockNumber,
outputRoot: Hash.wrap(starting.outputRoot)
}),
disputed: OutputProposal({
index: uint128(proposalIdx),
l2BlockNumber: disputed.l2BlockNumber,
outputRoot: Hash.wrap(disputed.outputRoot)
})
});
// Persist the L1 head hash of the L1 block number provided.
...
...
packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
View file @
652732fc
...
...
@@ -26,6 +26,12 @@ interface IFaultDisputeGame is IDisputeGame {
Hash outputRoot;
}
/// @notice A container for two consecutive `OutputProposal`s.
struct OutputProposals {
OutputProposal starting;
OutputProposal disputed;
}
/// @notice Emitted when a new claim is added to the DAG by `claimant`
/// @param parentIndex The index within the `claimData` array of the parent claim
/// @param claim The claim being added
...
...
packages/contracts-bedrock/test/FaultDisputeGame.t.sol
View file @
652732fc
...
...
@@ -148,17 +148,16 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
/// @dev Tests that the game is initialized with the correct data.
function test_initialize_correctData_succeeds() public {
// Starting
(
uint128 index, uint128 l2BlockNumber, Hash outputRoot) = gameProxy.proposals(0
);
Types.OutputProposal memory starting = oracle.getL2Output(index);
assertEq(index, 0);
assertEq(l2BlockNumber, starting.l2BlockNumber);
assertEq(Hash.unwrap(outputRoot), starting.outputRoot);
(
FaultDisputeGame.OutputProposal memory startingProp, FaultDisputeGame.OutputProposal memory disputedProp) = gameProxy.proposals(
);
Types.OutputProposal memory starting = oracle.getL2Output(
startingProp.
index);
assertEq(
startingProp.
index, 0);
assertEq(
startingProp.
l2BlockNumber, starting.l2BlockNumber);
assertEq(Hash.unwrap(
startingProp.
outputRoot), starting.outputRoot);
// Disputed
(uint128 _index, uint128 _l2BlockNumber, Hash _outputRoot) = gameProxy.proposals(1);
Types.OutputProposal memory disputed = oracle.getL2Output(_index);
assertEq(_index, 1);
assertEq(_l2BlockNumber, disputed.l2BlockNumber);
assertEq(Hash.unwrap(_outputRoot), disputed.outputRoot);
Types.OutputProposal memory disputed = oracle.getL2Output(disputedProp.index);
assertEq(disputedProp.index, 1);
assertEq(disputedProp.l2BlockNumber, disputed.l2BlockNumber);
assertEq(Hash.unwrap(disputedProp.outputRoot), disputed.outputRoot);
// L1 head
(, uint256 l1HeadNumber) = abi.decode(gameProxy.extraData(), (uint256, uint256));
...
...
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