Skip to content

Commit

Permalink
Revert "small improvement to remove ACCOUNT_HASH_BY_CODE_HASH if ther…
Browse files Browse the repository at this point in the history
…e no references instead of storing empty list"

This reverts commit 7661784.
  • Loading branch information
jframe committed Sep 20, 2023
1 parent 7661784 commit 1c948ff
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,10 @@ public BonsaiUpdater removeCode(final Hash accountHash, final Hash codeHash) {
final Set<Bytes32> updatedCodeAccounts = new HashSet<>(codeAccounts);
updatedCodeAccounts.remove(accountHash);

if (!updatedCodeAccounts.isEmpty()) {
final Bytes encodedAddresses =
RLP.encode(o -> o.writeList(updatedCodeAccounts, (val, out) -> out.writeBytes(val)));
composedWorldStateTransaction.put(
ACCOUNT_HASH_BY_CODE_HASH, codeHash.toArray(), encodedAddresses.toArrayUnsafe());
} else {
composedWorldStateTransaction.remove(ACCOUNT_STORAGE_STORAGE, codeHash.toArrayUnsafe());
}
final Bytes encodedAddresses =
RLP.encode(o -> o.writeList(updatedCodeAccounts, (val, out) -> out.writeBytes(val)));
composedWorldStateTransaction.put(
ACCOUNT_HASH_BY_CODE_HASH, codeHash.toArray(), encodedAddresses.toArrayUnsafe());

if (updatedCodeAccounts.isEmpty()) {
composedWorldStateTransaction.remove(CODE_STORAGE_BY_HASH, codeHash.toArrayUnsafe());
Expand All @@ -412,7 +408,7 @@ public BonsaiUpdater putCode(final Hash accountHash, final Bytes32 codeHash, fin
final Bytes encodedAddresses =
RLP.encode(o -> o.writeList(updatedCodeAccounts, (val, out) -> out.writeBytes(val)));
composedWorldStateTransaction.put(
ACCOUNT_HASH_BY_CODE_HASH, codeHash.toArrayUnsafe(), encodedAddresses.toArrayUnsafe());
ACCOUNT_HASH_BY_CODE_HASH, codeHash.toArray(), encodedAddresses.toArrayUnsafe());

if (codeAccounts.isEmpty()) {
composedWorldStateTransaction.put(
Expand Down

0 comments on commit 1c948ff

Please sign in to comment.