Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address bonsai self-destruct stale code present #4906

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@
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;
Expand Down Expand Up @@ -601,10 +604,8 @@ private void rollCodeChange(
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",
Expand Down