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
ab6e51d0
Unverified
Commit
ab6e51d0
authored
Feb 01, 2024
by
clabby
Committed by
GitHub
Feb 02, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add status byte to final digest (#9310)
parent
0872e3ed
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
5 deletions
+15
-5
alphabetvm.go
op-bindings/bindings/alphabetvm.go
+1
-1
preimageoracle.go
op-bindings/bindings/preimageoracle.go
+1
-1
preimageoracle_more.go
op-bindings/bindings/preimageoracle_more.go
+1
-1
PreimageOracle.sol
packages/contracts-bedrock/src/cannon/PreimageOracle.sol
+3
-0
PreimageOracle.t.sol
packages/contracts-bedrock/test/cannon/PreimageOracle.t.sol
+9
-2
No files found.
op-bindings/bindings/alphabetvm.go
View file @
ab6e51d0
This diff is collapsed.
Click to expand it.
op-bindings/bindings/preimageoracle.go
View file @
ab6e51d0
This diff is collapsed.
Click to expand it.
op-bindings/bindings/preimageoracle_more.go
View file @
ab6e51d0
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/src/cannon/PreimageOracle.sol
View file @
ab6e51d0
...
@@ -595,6 +595,9 @@ contract PreimageOracle is IPreimageOracle {
...
@@ -595,6 +595,9 @@ contract PreimageOracle is IPreimageOracle {
LibKeccak.absorb(_stateMatrix, _postState.input);
LibKeccak.absorb(_stateMatrix, _postState.input);
LibKeccak.permutation(_stateMatrix);
LibKeccak.permutation(_stateMatrix);
bytes32 finalDigest = LibKeccak.squeeze(_stateMatrix);
bytes32 finalDigest = LibKeccak.squeeze(_stateMatrix);
assembly {
finalDigest := or(and(finalDigest, not(shl(248, 0xFF))), shl(248, 0x02))
}
// Write the preimage part to the authorized preimage parts mapping.
// Write the preimage part to the authorized preimage parts mapping.
uint256 partOffset = metaData.partOffset();
uint256 partOffset = metaData.partOffset();
...
...
packages/contracts-bedrock/test/cannon/PreimageOracle.t.sol
View file @
ab6e51d0
...
@@ -411,7 +411,7 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
...
@@ -411,7 +411,7 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
_postStateProof: postProof
_postStateProof: postProof
});
});
bytes32 finalDigest =
keccak256(data
);
bytes32 finalDigest =
_setStatusByte(keccak256(data), 2
);
bytes32 expectedPart = bytes32((~uint256(0) & ~(uint256(type(uint64).max) << 192)) | (data.length << 192));
bytes32 expectedPart = bytes32((~uint256(0) & ~(uint256(type(uint64).max) << 192)) | (data.length << 192));
assertTrue(oracle.preimagePartOk(finalDigest, 0));
assertTrue(oracle.preimagePartOk(finalDigest, 0));
assertEq(oracle.preimageLengths(finalDigest), data.length);
assertEq(oracle.preimageLengths(finalDigest), data.length);
...
@@ -727,7 +727,7 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
...
@@ -727,7 +727,7 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
// Validate the preimage part
// Validate the preimage part
{
{
bytes32 finalDigest =
keccak256(data
);
bytes32 finalDigest =
_setStatusByte(keccak256(data), 2
);
bytes32 expectedPart;
bytes32 expectedPart;
assembly {
assembly {
switch lt(_partOffset, 0x08)
switch lt(_partOffset, 0x08)
...
@@ -1269,3 +1269,10 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
...
@@ -1269,3 +1269,10 @@ contract PreimageOracle_LargePreimageProposals_Test is Test {
(root_, proof_) = abi.decode(vm.ffi(commands), (bytes32, bytes32[]));
(root_, proof_) = abi.decode(vm.ffi(commands), (bytes32, bytes32[]));
}
}
}
}
/// @notice Sets the status byte of a hash.
function _setStatusByte(bytes32 _hash, uint8 _status) pure returns (bytes32 out_) {
assembly {
out_ := or(and(not(shl(248, 0xFF)), _hash), shl(248, _status))
}
}
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