Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions src/gadgets/mpt_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,10 @@ fn configure_nonce<F: FieldExt>(
bytes: &impl BytesLookup,
poseidon: &impl PoseidonLookup,
) {
cb.assert(
"account leafs cannot be deleted",
!config.path_type.current_matches(&[PathType::ExtensionOld]),
);
for variant in SegmentType::iter() {
let conditional_constraints = |cb: &mut ConstraintBuilder<F>| match variant {
SegmentType::AccountTrie => {
Expand Down Expand Up @@ -1340,10 +1344,13 @@ fn configure_nonce<F: FieldExt>(
SegmentType::AccountLeaf3 => {
cb.assert_zero("direction is 0", config.direction.current());

let old_code_size = (config.old_hash.current() - config.old_value.current())
* Query::Constant(F::from(1 << 32).square().invert().unwrap());
let new_code_size = (config.new_hash.current() - config.new_value.current())
* Query::Constant(F::from(1 << 32).square().invert().unwrap());
cb.add_lookup(
"new nonce is 8 bytes",
[config.new_value.current(), Query::from(7)],
bytes.lookup(),
);
cb.condition(
config.path_type.current_matches(&[PathType::Common]),
|cb| {
Expand All @@ -1352,30 +1359,27 @@ fn configure_nonce<F: FieldExt>(
[config.old_value.current(), Query::from(7)],
bytes.lookup(),
);
cb.add_lookup(
"new nonce is 8 bytes",
[config.old_value.current(), Query::from(7)],
bytes.lookup(),
);
let old_code_size = (config.old_hash.current()
- config.old_value.current())
* Query::Constant(F::from(1 << 32).square().invert().unwrap());
cb.assert_equal(
"old_code_size = new_code_size for nonce update",
old_code_size.clone(),
new_code_size.clone(),
);
cb.add_lookup(
"existing code size is 8 bytes",
[old_code_size.clone(), Query::from(7)],
[old_code_size, Query::from(7)],
bytes.lookup(),
);
},
);
cb.condition(
config.path_type.current_matches(&[PathType::ExtensionNew]),
|cb| {
cb.add_lookup(
"new nonce is 8 bytes",
[config.old_value.current(), Query::from(7)],
bytes.lookup(),
cb.assert_zero(
"old nonce is 0 for ExtensionNew nonce update",
config.old_value.current(),
);
cb.assert_zero(
"code size is 0 for ExtensionNew nonce update",
Expand All @@ -1387,20 +1391,6 @@ fn configure_nonce<F: FieldExt>(
);
},
);
cb.condition(
config.path_type.current_matches(&[PathType::ExtensionOld]),
|cb| {
cb.add_lookup(
"old nonce is 8 bytes",
[config.old_value.current(), Query::from(7)],
bytes.lookup(),
);
cb.assert_zero(
"code size is 0 for ExtensionOld nonce update",
old_code_size,
);
},
);
}
_ => {}
};
Expand Down