-
Notifications
You must be signed in to change notification settings - Fork 265
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
chainid and version as globals in contracts #910
Conversation
8a6cbcc
to
9dc4d7e
Compare
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.
Overall looks great, have a nit question over whether the private_global_variables
should just live within the call_context
, and the call context can diverge for public and private. This isnt blocking approval but just a discussion starter.
@@ -242,6 +258,8 @@ void write(std::vector<uint8_t>& buf, PrivateCircuitPublicInputs<NCT> const& pri | |||
write(buf, pis.historic_l1_to_l2_messages_tree_root); | |||
|
|||
write(buf, pis.contract_deployment_data); | |||
write(buf, pis.chain_id); |
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.
While we are here we could probably alter this to use the MSGPACK_FIELDS() macro
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.
Seems like it needs changes quite a few places to use MSGPACK_FIELDS()
consistently (in other part os the code as well), so might be better to put that off to a separate cleanup PR.
@@ -1,16 +1,17 @@ | |||
// @todo @LHerskind Looks like the length is hardcoded without a constant here. Should have a description. Seems like number of public inputs + 5 |
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.
flagging!
@@ -19,6 +19,8 @@ struct PrivateContextInputs { | |||
roots: CommitmentTreesRoots, | |||
|
|||
contract_deployment_data: ContractDeploymentData, | |||
|
|||
private_global_variables: PrivateGlobalVariables, |
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.
I think these should belong in the call_context
, rather than being in their own section?
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.
Was not put in the call_context
as those values could change throughout execution, e.g., msg_sender
etc.
Seemed better to have the constants separately to that.
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.
Overall looks great, have a nit question over whether the private_global_variables
should just live within the call_context
, and the call context can diverge for public and private. This isnt blocking approval but just a discussion starter.
c5f3d53
to
50e4b5a
Compare
@@ -66,7 +70,8 @@ template <typename NCT> class PrivateCircuitPublicInputs { | |||
historic_nullifier_tree_root == other.historic_nullifier_tree_root && | |||
historic_contract_tree_root == other.historic_contract_tree_root && | |||
historic_l1_to_l2_messages_tree_root == other.historic_l1_to_l2_messages_tree_root && | |||
contract_deployment_data == other.contract_deployment_data; | |||
contract_deployment_data == other.contract_deployment_data && chain_id == other.chain_id && |
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.
nit: add these in different lines to be coherent and easily spottable.
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.
This is when formatted, notice the first line also have two values, both call_context
and args_hash
.
@@ -49,7 +49,7 @@ describe('Private Execution test suite', () => { | |||
|
|||
const historicRoots = PrivateHistoricTreeRoots.empty(); | |||
const contractDeploymentData = ContractDeploymentData.empty(); | |||
const txContext = new TxContext(false, false, false, contractDeploymentData, Fr.ZERO, Fr.ZERO); | |||
const txContext = new TxContext(false, false, false, contractDeploymentData, new Fr(69), new Fr(420)); |
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.
@@ -337,6 +337,8 @@ function_tree_root: 0x3 | |||
contract_address_salt: 0x4 | |||
portal_contract_address: 0x505050505050505050505050505050505050505 | |||
|
|||
chain_id: 0x2111 |
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.
why are these exactly the same?
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.
Description
Fixes #912.
Todo:
Checklist: