From 5ec2957e84cca400a008e9364fafbefccbaf00cc Mon Sep 17 00:00:00 2001 From: Simon Dudley Date: Thu, 9 Feb 2023 13:34:33 +1000 Subject: [PATCH] Revert "Keep Worldstate Storage open for Bonsai archive latest layer (#5039)" (#5073) This reverts commit e7150102ea208165ac29bd10986fe26bc9e176d0. Signed-off-by: Simon Dudley Signed-off-by: garyschulte --- CHANGELOG.md | 1 - .../bonsai/BonsaiInMemoryWorldState.java | 7 +------ .../bonsai/BonsaiLayeredWorldState.java | 20 ------------------- .../AbstractPendingTransactionsSorter.java | 6 +----- 4 files changed, 2 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43857f46d42..df072a1d9fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,6 @@ tests are updated to use EC private keys instead of RSA keys. ### Bug Fixes - Mitigation fix for stale bonsai code storage leading to log rolling issues on contract recreates [#4906](https://github.com/hyperledger/besu/pull/4906) -- Ensure latest cached layered worldstate is subscribed to storage, fix problem with RPC calls using 'latest' [#5039](https://github.com/hyperledger/besu/pull/5039) ## 23.1.0-RC1 diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java index 2c2e07a34a8..7c0c2e74ec3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiInMemoryWorldState.java @@ -167,12 +167,7 @@ public void persist(final BlockHeader blockHeader) { final Hash newWorldStateRootHash = rootHash(localUpdater); archive .getTrieLogManager() - .saveTrieLog( - archive, - localUpdater, - newWorldStateRootHash, - blockHeader, - (BonsaiPersistedWorldState) this.copy()); + .saveTrieLog(archive, localUpdater, newWorldStateRootHash, blockHeader, this); worldStateRootHash = newWorldStateRootHash; worldStateBlockHash = blockHeader.getBlockHash(); isPersisted = true; diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java index e0839400378..7ac14a37e77 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiLayeredWorldState.java @@ -76,29 +76,9 @@ public Optional getNextWorldView() { } public void setNextWorldView(final Optional nextWorldView) { - maybeUnSubscribe(); this.nextWorldView = nextWorldView; } - private void maybeUnSubscribe() { - nextWorldView - .filter(WorldState.class::isInstance) - .map(WorldState.class::cast) - .ifPresent( - ws -> { - try { - ws.close(); - } catch (final Exception e) { - // no-op - } - }); - } - - @Override - public void close() throws Exception { - maybeUnSubscribe(); - } - public TrieLogLayer getTrieLog() { return trieLog; } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java index cea31614f29..1f3c938ea99 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java @@ -428,11 +428,7 @@ private TransactionAddedStatus addTransaction( LOG, "Transaction {} not added because nonce too far in the future for sender {}", transaction::toTraceLog, - () -> - maybeSenderAccount - .map(Account::getAddress) - .map(Address::toString) - .orElse("unknown")); + maybeSenderAccount::toString); return NONCE_TOO_FAR_IN_FUTURE_FOR_SENDER; }