-
Notifications
You must be signed in to change notification settings - Fork 152
BM-1466: Ec2/claim digest #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
435e8c4
4c36ef5
d798851
a1d3222
575d8b5
1ebbc60
924c53f
2e2156a
63d873a
da0cc55
661daa6
7cd90bb
a672a0a
918934a
4a8b78e
48822c6
ebbccd1
0985ba3
9b25d47
e4dbfd4
00f1078
3c43edf
25c7b42
7b905ef
27d0dc0
41aa8b6
9566b73
50167b3
fc6bd7f
e2013f8
eaa391f
0032fa2
c90f973
4ae5304
ea907a8
1937e1b
69abfb7
5df52a5
7864baa
ac3c914
3e0d070
8d8a0c8
d3c9ace
2ba252f
8833ded
e161dff
de0d3e2
3b54725
7f2172e
04f6f99
0600765
88b981b
d294e34
dd44c54
d70bc72
de7225e
3778944
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
{ | ||
"ERC20 approve: required for depositStake": "45966", | ||
"bytecode size implementation": "24381", | ||
"bytecode size implementation": "24341", | ||
"bytecode size proxy": "89", | ||
"deposit: first ever deposit": "50920", | ||
"deposit: second deposit": "33820", | ||
"depositStake: 1 HP (tops up market account)": "59400", | ||
"depositStake: full (drains testProver account)": "49800", | ||
"depositStakeWithPermit: 1 HP (tops up market account)": "72272", | ||
"depositStakeWithPermit: full (drains testProver account)": "72262", | ||
"fulfill: a batch of 8": "402078", | ||
"fulfill: a locked request": "90511", | ||
"fulfill: a locked request (locked via prover signature)": "90511", | ||
"fulfill: a locked request with 10kB journal": "427539", | ||
"fulfill: another prover fulfills without payment": "85473", | ||
"fulfill: fulfilled by the locked prover for payment (request already fulfilled by another prover)": "80772", | ||
"fulfillAndWithdraw: a batch of 8": "414256", | ||
"fulfillAndWithdraw: a locked request": "102689", | ||
"lockinRequest: base case": "146877", | ||
"lockinRequest: with prover signature": "156522", | ||
"priceAndFulfill: a single request": "108760", | ||
"priceAndFulfill: a single request (smart contract signature)": "118938", | ||
"priceAndFulfill: a single request (with selector)": "111059", | ||
"priceAndFulfill: a single request that was not locked": "108760", | ||
"priceAndFulfill: a single request that was not locked fulfilled by prover not in allow-list": "108760", | ||
"priceAndFulfill: fulfill already fulfilled was locked request": "102475", | ||
"slash: base case": "100967", | ||
"slash: fulfilled request after lock deadline": "80532", | ||
"submitRequest: with maxPrice ether": "51904", | ||
"submitRequest: without ether": "45061", | ||
"submitRootAndFulfill: a batch of 2 requests": "168676", | ||
"submitRootAndFulfill: a locked request": "124555", | ||
"submitRootAndFulfill: a locked request (locked via prover signature)": "124555", | ||
"submitRootAndFulfillAndWithdraw: a locked request": "136476", | ||
"submitRootAndPriceAndFulfill: a single request": "141098", | ||
"submitRootAndPriceAndFulfill: a single request that was not locked": "141110", | ||
"submitRootAndPriceAndFulfill: a single request that was not locked fulfilled by prover not in allow-list": "141110", | ||
"withdraw: 1 ether": "40314", | ||
"withdraw: full balance": "40326", | ||
"withdrawStake: 1 HP balance": "68743", | ||
"withdrawStake: full balance": "51739" | ||
"deposit: first ever deposit": "50876", | ||
"deposit: second deposit": "33776", | ||
"depositStake: 1 HP (tops up market account)": "59378", | ||
"depositStake: full (drains testProver account)": "49778", | ||
"depositStakeWithPermit: 1 HP (tops up market account)": "72236", | ||
"depositStakeWithPermit: full (drains testProver account)": "72227", | ||
"fulfill (no journal): a batch of 8": "385299", | ||
"fulfill: a batch of 8": "438335", | ||
"fulfill: a locked request": "95167", | ||
"fulfill: a locked request (locked via prover signature)": "95167", | ||
"fulfill: a locked request with 10kB journal": "432569", | ||
"fulfill: another prover fulfills without payment": "90165", | ||
"fulfill: fulfilled by the locked prover for payment (request already fulfilled by another prover)": "84071", | ||
"fulfillAndWithdraw: a batch of 8": "451307", | ||
"fulfillAndWithdraw: a locked request": "108139", | ||
"lockinRequest: base case": "147332", | ||
"lockinRequest: with prover signature": "157039", | ||
"priceAndFulfill: a single request": "113970", | ||
"priceAndFulfill: a single request (smart contract signature)": "124159", | ||
"priceAndFulfill: a single request (with selector)": "116270", | ||
"priceAndFulfill: a single request that was not locked": "113934", | ||
"priceAndFulfill: a single request that was not locked fulfilled by prover not in allow-list": "113934", | ||
"priceAndFulfill: fulfill already fulfilled was locked request": "106280", | ||
"slash: base case": "100898", | ||
"slash: fulfilled request after lock deadline": "80465", | ||
"submitRequest: with maxPrice ether": "52227", | ||
"submitRequest: without ether": "45384", | ||
"submitRootAndFulfill: a batch of 2 requests": "177800", | ||
"submitRootAndFulfill: a locked request": "129534", | ||
"submitRootAndFulfill: a locked request (locked via prover signature)": "129534", | ||
"submitRootAndFulfillAndWithdraw: a locked request": "141954", | ||
"submitRootAndPriceAndFulfill: a single request": "146462", | ||
"submitRootAndPriceAndFulfill: a single request that was not locked": "146426", | ||
"submitRootAndPriceAndFulfill: a single request that was not locked fulfilled by prover not in allow-list": "146426", | ||
"withdraw: 1 ether": "40331", | ||
"withdraw: full balance": "40343", | ||
"withdrawStake: 1 HP balance": "68755", | ||
"withdrawStake: full balance": "51751" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
{ | ||
"fulfill (with callback): batch of 001": "132142", | ||
"fulfill (with callback): batch of 002": "218443", | ||
"fulfill (with callback): batch of 004": "392147", | ||
"fulfill (with callback): batch of 008": "739579", | ||
"fulfill (with callback): batch of 016": "1272464", | ||
"fulfill (with callback): batch of 032": "2373148", | ||
"fulfill (with selector): batch of 001": "92745", | ||
"fulfill (with selector): batch of 002": "139726", | ||
"fulfill (with selector): batch of 004": "236258", | ||
"fulfill (with selector): batch of 008": "420231", | ||
"fulfill (with selector): batch of 016": "790425", | ||
"fulfill (with selector): batch of 032": "1558877", | ||
"fulfill: batch of 001": "90487", | ||
"fulfill: batch of 002": "135232", | ||
"fulfill: batch of 004": "227181", | ||
"fulfill: batch of 008": "402117", | ||
"fulfill: batch of 016": "754179", | ||
"fulfill: batch of 032": "1485129", | ||
"fulfill: batch of 064": "3014348", | ||
"fulfill: batch of 128": "6255291" | ||
"fulfill (with callback): batch of 001": "136946", | ||
"fulfill (with callback): batch of 002": "227879", | ||
"fulfill (with callback): batch of 004": "410896", | ||
"fulfill (with callback): batch of 008": "776960", | ||
"fulfill (with callback): batch of 016": "1346098", | ||
"fulfill (with callback): batch of 032": "2522586", | ||
"fulfill (with selector): batch of 001": "97441", | ||
"fulfill (with selector): batch of 002": "148905", | ||
"fulfill (with selector): batch of 004": "254383", | ||
"fulfill (with selector): batch of 008": "456439", | ||
"fulfill (with selector): batch of 016": "862953", | ||
"fulfill (with selector): batch of 032": "1704151", | ||
"fulfill: batch of 001": "95191", | ||
"fulfill: batch of 002": "144387", | ||
"fulfill: batch of 004": "245394", | ||
"fulfill: batch of 008": "438338", | ||
"fulfill: batch of 016": "826511", | ||
"fulfill: batch of 032": "1630160", | ||
"fulfill: batch of 064": "3306156", | ||
"fulfill: batch of 128": "6849269" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,15 @@ | |
// as found in the LICENSE-BSL file. | ||
pragma solidity ^0.8.20; | ||
|
||
import {CallbackType} from "./CallbackType.sol"; | ||
|
||
struct AssessorCallback { | ||
/// @notice The index of the fill in the request | ||
uint16 index; | ||
/// @notice The address of the contract to call back | ||
address addr; | ||
/// @notice Maximum gas to use for the callback | ||
uint96 gasLimit; | ||
/// @notice The type of callback | ||
CallbackType callbackType; | ||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of just the callback type, we should encode the full callback data here, and ensure it is committed in the assessor journal. This both allows us to skip the recomputation of the receipt claim onchain when we go to send the callback, because it will now be part of what the assessor constructs, and allows for more flexibility in the future in how we evolve the system. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to my comments below, I am kind of thinking we should just embed the |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
pragma solidity ^0.8.20; | ||
|
||
import {AssessorCallback} from "./AssessorCallback.sol"; | ||
import {PredicateType} from "./Predicate.sol"; | ||
import {Selector} from "./Selector.sol"; | ||
|
||
/// @title Assessor Journal Struct | ||
|
@@ -17,6 +18,8 @@ struct AssessorJournal { | |
/// @notice The (optional) selectors for the requests committed by the assessor. | ||
/// @dev This is used to verify the fulfillment of the request against its selector's seal. | ||
Selector[] selectors; | ||
/// @notice The list of `PredicateType` for each request. | ||
PredicateType[] predicateTypes; | ||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this. Also, if we do this should be in |
||
/// @notice Root of the Merkle tree committing to the set of proven claims. | ||
/// @dev In the case of a batch of size one, this may simply be the eip712Digest of the `AssessorCommitment`. | ||
bytes32 root; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,23 +6,27 @@ pragma solidity ^0.8.24; | |
|
||
using CallbackLibrary for Callback global; | ||
|
||
import {CallbackType} from "./CallbackType.sol"; | ||
|
||
/// @title Callback Struct and Library | ||
/// @notice Represents a callback configuration for proof delivery | ||
struct Callback { | ||
/// @notice The address of the contract to call back | ||
address addr; | ||
/// @notice Maximum gas to use for the callback | ||
uint96 gasLimit; | ||
/// @notice The type of callback | ||
CallbackType callbackType; | ||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we maybe not support multiple callback types? I am leaning towards saying that we should not, or least not support multiple callback types right now. Maybe this will be requested in the future, but its unclear what the receiver experience would look like and I'm inclined to think we probably won't support it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another way to keep the option open for multiple callback types would be to add a version number to the start of the encoded But we don't necessarily need to do that even: because the first 32 bytes are a hash, we can use a special value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another option for forward compatibility is that we can increment the entire request version, and accordingly create any need code paths we need, switching on that. We have reserved bits in the request ID that can be used for this. |
||
} | ||
|
||
library CallbackLibrary { | ||
string constant CALLBACK_TYPE = "Callback(address addr,uint96 gasLimit)"; | ||
string constant CALLBACK_TYPE = "Callback(address addr,uint96 gasLimit,uint8 callbackType)"; | ||
bytes32 constant CALLBACK_TYPEHASH = keccak256(bytes(CALLBACK_TYPE)); | ||
|
||
/// @notice Computes the EIP-712 digest for the given callback | ||
/// @param callback The callback to compute the digest for | ||
/// @return The EIP-712 digest of the callback | ||
function eip712Digest(Callback memory callback) internal pure returns (bytes32) { | ||
return keccak256(abi.encode(CALLBACK_TYPEHASH, callback.addr, callback.gasLimit)); | ||
return keccak256(abi.encode(CALLBACK_TYPEHASH, callback.addr, callback.gasLimit, callback.callbackType)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2025 RISC Zero, Inc. | ||
// | ||
// Use of this source code is governed by the Business Source License | ||
// as found in the LICENSE-BSL file. | ||
pragma solidity ^0.8.24; | ||
|
||
using CallbackDataLibrary for CallbackData global; | ||
|
||
/// @title Callback Struct and Library | ||
/// @notice Represents a callback configuration for proof delivery | ||
struct CallbackData { | ||
/// @notice Image ID of the guest that was verifiably executed to satisfy the request. | ||
bytes32 imageId; | ||
/// @notice Journal committed by the guest program execution. | ||
/// @dev The journal is checked to satisfy the predicate specified on the request's requirements. | ||
bytes journal; | ||
} | ||
|
||
library CallbackDataLibrary {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright 2025 RISC Zero, Inc. | ||
// | ||
// Use of this source code is governed by the Business Source License | ||
// as found in the LICENSE-BSL file. | ||
pragma solidity ^0.8.20; | ||
|
||
enum CallbackType { | ||
None, | ||
JournalRequired | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By placing the callback data into the
AssessorCallback
, we can mostly eliminate the new validation here, and simply decode and execute the callback (reverting if decode fails). If we directly embed theCallbackData
intoAssessorCallback
, we can avoid the extra decode step as well.