Skip to content

Commit

Permalink
Implement delegation clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Nov 22, 2024
1 parent c2e2105 commit d487ec5
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions test/state/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,25 @@ TransactionReceipt transition(const StateView& state_view, const BlockInfo& bloc
continue;
}

const bytes new_code(bytes(DELEGATION_MAGIC) + bytes(auth.addr));
authority_ptr->code_changed = (authority_ptr->code != new_code);
authority_ptr->code = new_code;

// TODO The hash of delegated accounts is not used anywhere,
// it is only important that it is not a hash of empty.
// We could avoid this hashing, if we found a way to not rely only on code_hash for
// emptiness checks.
// (e.g for emptiness check code_hash == EMPTY_CODE_HASH && !code_changed)
authority_ptr->code_hash = keccak256(authority_ptr->code);
if (auth.addr == address{})
{
authority_ptr->code_changed = !authority_ptr->code.empty();
authority_ptr->code.clear();
authority_ptr->code_hash = Account::EMPTY_CODE_HASH;
}
else
{
const bytes new_code(bytes(DELEGATION_MAGIC) + bytes(auth.addr));
authority_ptr->code_changed = (authority_ptr->code != new_code);
authority_ptr->code = new_code;

// TODO The hash of delegated accounts is not used anywhere,
// it is only important that it is not a hash of empty.
// We could avoid this hashing, if we found a way to not rely only on code_hash for
// emptiness checks.
// (e.g for emptiness check code_hash == EMPTY_CODE_HASH && !code_changed)
authority_ptr->code_hash = keccak256(authority_ptr->code);
}

++authority_ptr->nonce;
}
Expand Down

0 comments on commit d487ec5

Please sign in to comment.