From ee6e4a339414a6d75efa13068617c0fd9dd5a003 Mon Sep 17 00:00:00 2001 From: z2trillion Date: Tue, 14 Nov 2023 08:06:59 +0800 Subject: [PATCH] Expand and correct comment explaining why account must already exist (#80) Co-authored-by: Mason Liang --- src/types.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index 0c9d3fca..55c34b4d 100644 --- a/src/types.rs +++ b/src/types.rs @@ -260,7 +260,11 @@ impl From<(&MPTProofType, &SMTTrace)> for ClaimKind { match update { [None, None] => (), [Some(old), Some(new)] => { - // The account must exist, because only contracts with bytecode can modify their own storage slots. + // Accesses to the MPT happen in the order defined in the state (aka rw) circuit, which is not the + // same as the order they occur in the EVM. In the state circuit, nonce and balance modifications + // will precede storage modifications for a given address, which means that the MPT circuit only + // needs to handle storage modifications for existing accounts, even though this is not true in the + // EVM, where the storage of an account can be modified during its construction. if !(account_old == account_new || (account_old.is_none() && account_new == &Some(Default::default()))) {