Address bonsai self-destruct stale code present (#4906)

Signed-off-by: garyschulte <garyschulte@gmail.com>
pull/4928/head
garyschulte 2 years ago committed by GitHub
parent 1cd15a86f6
commit aa7f6fd404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 9
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java

@ -16,6 +16,8 @@
### Additions and Improvements
### 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)
## 23.1.0-RC1

@ -43,9 +43,12 @@ import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BonsaiWorldStateUpdater extends AbstractWorldUpdater<BonsaiWorldView, BonsaiAccount>
implements BonsaiWorldView {
private static final Logger LOG = LoggerFactory.getLogger(BonsaiWorldStateUpdater.class);
private final AccountConsumingMap<BonsaiValue<BonsaiAccount>> accountsToUpdate;
private final Consumer<BonsaiValue<BonsaiAccount>> accountPreloader;
@ -601,10 +604,8 @@ public class BonsaiWorldStateUpdater extends AbstractWorldUpdater<BonsaiWorldVie
if ((expectedCode == null || expectedCode.isEmpty())
&& existingCode != null
&& !existingCode.isEmpty()) {
throw new IllegalStateException(
String.format("Expected to create code, but the code exists. Address=%s", address));
}
if (!Objects.equals(expectedCode, existingCode)) {
LOG.warn("At Address={}, expected to create code, but code exists. Overwriting.", address);
} else if (!Objects.equals(expectedCode, existingCode)) {
throw new IllegalStateException(
String.format(
"Old value of code does not match expected value. Address=%s ExpectedHash=%s ActualHash=%s",

Loading…
Cancel
Save