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
25876600
Commit
25876600
authored
Jul 20, 2023
by
clabby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`FaultDisputeGame` `loadLocalData` func
parent
f43e8cd4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
138 additions
and
70 deletions
+138
-70
faultdisputegame.go
op-bindings/bindings/faultdisputegame.go
+23
-2
faultdisputegame_more.go
op-bindings/bindings/faultdisputegame_more.go
+1
-1
preimageoracle.go
op-bindings/bindings/preimageoracle.go
+12
-12
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+29
-30
PreimageOracle.sol
packages/contracts-bedrock/src/cannon/PreimageOracle.sol
+38
-13
FaultDisputeGame.sol
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
+30
-1
IBigStepper.sol
.../contracts-bedrock/src/dispute/interfaces/IBigStepper.sol
+1
-11
IFaultDisputeGame.sol
...acts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
+4
-0
No files found.
op-bindings/bindings/faultdisputegame.go
View file @
25876600
This diff is collapsed.
Click to expand it.
op-bindings/bindings/faultdisputegame_more.go
View file @
25876600
This diff is collapsed.
Click to expand it.
op-bindings/bindings/preimageoracle.go
View file @
25876600
...
...
@@ -381,23 +381,23 @@ func (_PreimageOracle *PreimageOracleTransactorSession) LoadKeccak256PreimagePar
return
_PreimageOracle
.
Contract
.
LoadKeccak256PreimagePart
(
&
_PreimageOracle
.
TransactOpts
,
_partOffset
,
_preimage
)
}
// LoadLocal
Part is a paid mutator transaction binding the contract method 0x90fbc1e2
.
// LoadLocal
Data is a paid mutator transaction binding the contract method 0xe52f0937
.
//
// Solidity: function loadLocal
Part(uint256 _partOffset, uint256 _ident, bytes32 _part, uint256
_size) returns()
func
(
_PreimageOracle
*
PreimageOracleTransactor
)
LoadLocal
Part
(
opts
*
bind
.
TransactOpts
,
_partOffset
*
big
.
Int
,
_ident
*
big
.
Int
,
_part
[
32
]
byte
,
_size
*
big
.
Int
)
(
*
types
.
Transaction
,
error
)
{
return
_PreimageOracle
.
contract
.
Transact
(
opts
,
"loadLocal
Part"
,
_partOffset
,
_ident
,
_part
,
_size
)
// Solidity: function loadLocal
Data(uint256 _ident, bytes32 _word, uint8
_size) returns()
func
(
_PreimageOracle
*
PreimageOracleTransactor
)
LoadLocal
Data
(
opts
*
bind
.
TransactOpts
,
_ident
*
big
.
Int
,
_word
[
32
]
byte
,
_size
uint8
)
(
*
types
.
Transaction
,
error
)
{
return
_PreimageOracle
.
contract
.
Transact
(
opts
,
"loadLocal
Data"
,
_ident
,
_word
,
_size
)
}
// LoadLocal
Part is a paid mutator transaction binding the contract method 0x90fbc1e2
.
// LoadLocal
Data is a paid mutator transaction binding the contract method 0xe52f0937
.
//
// Solidity: function loadLocal
Part(uint256 _partOffset, uint256 _ident, bytes32 _part, uint256
_size) returns()
func
(
_PreimageOracle
*
PreimageOracleSession
)
LoadLocal
Part
(
_partOffset
*
big
.
Int
,
_ident
*
big
.
Int
,
_part
[
32
]
byte
,
_size
*
big
.
Int
)
(
*
types
.
Transaction
,
error
)
{
return
_PreimageOracle
.
Contract
.
LoadLocal
Part
(
&
_PreimageOracle
.
TransactOpts
,
_partOffset
,
_ident
,
_part
,
_size
)
// Solidity: function loadLocal
Data(uint256 _ident, bytes32 _word, uint8
_size) returns()
func
(
_PreimageOracle
*
PreimageOracleSession
)
LoadLocal
Data
(
_ident
*
big
.
Int
,
_word
[
32
]
byte
,
_size
uint8
)
(
*
types
.
Transaction
,
error
)
{
return
_PreimageOracle
.
Contract
.
LoadLocal
Data
(
&
_PreimageOracle
.
TransactOpts
,
_ident
,
_word
,
_size
)
}
// LoadLocal
Part is a paid mutator transaction binding the contract method 0x90fbc1e2
.
// LoadLocal
Data is a paid mutator transaction binding the contract method 0xe52f0937
.
//
// Solidity: function loadLocal
Part(uint256 _partOffset, uint256 _ident, bytes32 _part, uint256
_size) returns()
func
(
_PreimageOracle
*
PreimageOracleTransactorSession
)
LoadLocal
Part
(
_partOffset
*
big
.
Int
,
_ident
*
big
.
Int
,
_part
[
32
]
byte
,
_size
*
big
.
Int
)
(
*
types
.
Transaction
,
error
)
{
return
_PreimageOracle
.
Contract
.
LoadLocal
Part
(
&
_PreimageOracle
.
TransactOpts
,
_partOffset
,
_ident
,
_part
,
_size
)
// Solidity: function loadLocal
Data(uint256 _ident, bytes32 _word, uint8
_size) returns()
func
(
_PreimageOracle
*
PreimageOracleTransactorSession
)
LoadLocal
Data
(
_ident
*
big
.
Int
,
_word
[
32
]
byte
,
_size
uint8
)
(
*
types
.
Transaction
,
error
)
{
return
_PreimageOracle
.
Contract
.
LoadLocal
Data
(
&
_PreimageOracle
.
TransactOpts
,
_ident
,
_word
,
_size
)
}
packages/contracts-bedrock/.gas-snapshot
View file @
25876600
...
...
@@ -85,36 +85,36 @@ 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: 50
2252
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 50
9098
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 505
795
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 508
974
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
8291
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 50
1017
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 507
863
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 504
560
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 505
739
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
5056
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 174
04
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 50
1901
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 50
8725
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 505
444
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 508
601
)
FaultDisputeGame_ResolvesCorrectly_CorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
7940
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot1:test_resolvesCorrectly_succeeds() (gas: 50
0666
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeeds() (gas: 507
490
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 504
209
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 505
366
)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 50
4705
)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 174
49
)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 17917)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10
315
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
60
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 176
69
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 419
317
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 263
99
)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 133
60
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1040
76
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 411
436
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 109
68
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
55
)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 1081
78
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 22646
7
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9
657
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 110
598
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 214
37
)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27
266
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 3987
93
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 82
25
)
FaultDisputeGame_Test:test_gameStart_succeeds() (gas: 10
293
)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 82
38
)
FaultDisputeGame_Test:test_initialRootClaimData_succeeds() (gas: 176
47
)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 419
119
)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 263
77
)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 133
38
)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 1040
32
)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 411
304
)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 109
46
)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 246
11
)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 1081
12
)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 22646
8
)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9
702
)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 110
621
)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 214
82
)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 27
311
)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 3987
50
)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 82
03
)
FeeVault_Test:test_constructor_succeeds() (gas: 18185)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 352113)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2950320)
...
...
@@ -575,4 +575,3 @@ TransactorTest:test_constructor_succeeds() (gas: 9739)
TransactorTest:test_delegateCall_succeeds() (gas: 20909)
TransactorTest:test_delegateCall_unauthorized_reverts() (gas: 16550)
TransferOnionTest:test_constructor_succeeds() (gas: 564855)
TransferOnionTest:test_unwrap_succeeds() (gas: 724955)
\ No newline at end of file
packages/contracts-bedrock/src/cannon/PreimageOracle.sol
View file @
25876600
...
...
@@ -53,24 +53,49 @@ contract PreimageOracle {
preimageLengths[key] = size;
}
/// @notice Loads a local data part into the preimage oracle.
/// @param _partOffset The offset of the local data part.
/// @notice Loads a word of local data into the preimage oracle in two separate parts.
/// @param _ident The identifier of the local data.
/// @param _
part The local data part
.
/// @param _size The
size of the local data
.
/// @dev The local data part
is
loaded into the preimage oracle under the context
/// @param _
word The local data word
.
/// @param _size The
number of bytes in `_word` to load
.
/// @dev The local data part
s are
loaded into the preimage oracle under the context
/// of the caller - no other account can write to the caller's context
/// specific data.
function loadLocalPart(
uint256 _partOffset,
uint256 _ident,
bytes32 _part,
uint256 _size
) external {
///
/// There are 5 local data identifiers:
/// ┌────────────┬─────────────────┐
/// │ Identifier │ Data │
/// ├────────────┼─────────────────┤
/// │ 1 │ L1 Head Hash │
/// │ 2 │ Output Root │
/// │ 3 │ Root Claim │
/// │ 4 │ L2 Block Number │
/// │ 5 │ Chain ID │
/// └────────────┴─────────────────┘
function loadLocalData(uint256 _ident, bytes32 _word, uint8 _size) external {
// Compute the localized key from the given local identifier.
bytes32 key = PreimageKeyLib.localizeIdent(_ident);
preimagePartOk[key][_partOffset] = true;
preimageParts[key][_partOffset] = _part;
// Load both parts of the local data word into storage for future
// reads.
bytes32 part1;
assembly {
// The first part is prepended with an 8 byte length prefix and contains
// the first 24 bytes of the passed word.
part1 := or(shl(192, _size), shr(64, _word))
}
// Store the first part with offset 0.
preimagePartOk[key][0] = true;
preimageParts[key][0] = part1;
// If the size is greater than 24, we need to store a second part as well.
if (_size > 24) {
bytes32 part2 = _word << 192;
preimagePartOk[key][32] = true;
preimageParts[key][32] = part2;
}
// Assign the length of the preimage at the localized key.
preimageLengths[key] = _size;
}
...
...
packages/contracts-bedrock/src/dispute/FaultDisputeGame.sol
View file @
25876600
...
...
@@ -5,7 +5,7 @@ import { IDisputeGame } from "./interfaces/IDisputeGame.sol";
import { IFaultDisputeGame } from "./interfaces/IFaultDisputeGame.sol";
import { IInitializable } from "./interfaces/IInitializable.sol";
import { IBondManager } from "./interfaces/IBondManager.sol";
import { IBigStepper } from "./interfaces/IBigStepper.sol";
import { IBigStepper
, IPreimageOracle
} from "./interfaces/IBigStepper.sol";
import { Clone } from "../libraries/Clone.sol";
import { Semver } from "../universal/Semver.sol";
...
...
@@ -244,6 +244,35 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, Semver {
move(_parentIndex, _claim, false);
}
/// @inheritdoc IFaultDisputeGame
function addLocalData(uint256 _ident) external {
// INVARIANT: Local data can only be added if the game is currently in progress.
if (status != GameStatus.IN_PROGRESS) revert GameNotInProgress();
IPreimageOracle oracle = VM.oracle();
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);
} else if (_ident == 2) {
// Load the earliest output root that commits to the passed L2 block number
// into the game's local context in the preimage oracle.
// TODO(clabby): Add an immutable for the L2OO.
} else if (_ident == 3) {
// Load the root claim into the game's local context in the preimage oracle.
oracle.loadLocalData(_ident, Claim.unwrap(rootClaim()), 32);
} else if (_ident == 4) {
// Load the L2 block number into the game's local context in the preimage oracle.
// The L2 block number is stored as a big-endian uint64 in the upper 8 bytes of the
// passed word.
oracle.loadLocalData(_ident, bytes32(l2BlockNumber() << 192), 8);
} else if (_ident == 5) {
// Load the chain ID into the game's local context in the preimage oracle.
// The chain ID is stored as a big-endian uint64 in the upper 8 bytes of the
// passed word.
oracle.loadLocalData(_ident, bytes32(block.chainid << 192), 8);
}
}
/// @inheritdoc IFaultDisputeGame
function l2BlockNumber() public pure returns (uint256 l2BlockNumber_) {
l2BlockNumber_ = _getArgUint256(0x20);
...
...
packages/contracts-bedrock/src/dispute/interfaces/IBigStepper.sol
View file @
25876600
...
...
@@ -39,15 +39,5 @@ interface IBigStepper {
/// @notice Temporary interface for the `IPreimageOracle`. Remove once we've upgraded
/// the cannon contracts to a newer version of solc.
interface IPreimageOracle {
/// @notice Loads a local data part into the preimage oracle.
/// @param _partOffset The offset of the local data part.
/// @param _ident The identifier of the local data.
/// @param _part The local data part.
/// @param _size The size of the local data.
function loadLocalPart(
uint256 _partOffset,
uint256 _ident,
bytes32 _part,
uint256 _size
) external;
function loadLocalData(uint256 _ident, bytes32 _word, uint8 _size) external;
}
packages/contracts-bedrock/src/dispute/interfaces/IFaultDisputeGame.sol
View file @
25876600
...
...
@@ -53,6 +53,10 @@ interface IFaultDisputeGame is IDisputeGame {
bytes calldata _proof
) external;
/// @notice Posts the requested local data to the VM's `PreimageOralce`.
/// @param _ident The local identifier of the data to post.
function addLocalData(uint256 _ident) external;
/// @notice Returns the L1 block hash at the time of the game's creation.
function l1Head() external view returns (Hash l1Head_);
...
...
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