diff --git a/src/gadgets/mpt_update.rs b/src/gadgets/mpt_update.rs index bfdeb868..04049306 100644 --- a/src/gadgets/mpt_update.rs +++ b/src/gadgets/mpt_update.rs @@ -1277,6 +1277,10 @@ fn configure_nonce( 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| match variant { SegmentType::AccountTrie => { @@ -1340,10 +1344,13 @@ fn configure_nonce( 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| { @@ -1352,11 +1359,9 @@ fn configure_nonce( [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(), @@ -1364,7 +1369,7 @@ fn configure_nonce( ); cb.add_lookup( "existing code size is 8 bytes", - [old_code_size.clone(), Query::from(7)], + [old_code_size, Query::from(7)], bytes.lookup(), ); }, @@ -1372,10 +1377,9 @@ fn configure_nonce( 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", @@ -1387,20 +1391,6 @@ fn configure_nonce( ); }, ); - 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, - ); - }, - ); } _ => {} };