Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon committed Jun 24, 2024
1 parent adf2d64 commit 5427be5
Showing 1 changed file with 46 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static ProtocolSpecBuilder frontierDefinition(final EvmConfiguration evmC
contractCreationProcessor,
messageCallProcessor,
false,
evmConfiguration.evmStackSize(),
evmConfiguration.evmStackSize(),
new PrivateTransactionValidator(Optional.empty())))
.difficultyCalculator(MainnetDifficultyCalculators.FRONTIER)
.blockHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.create())
Expand Down Expand Up @@ -783,53 +783,53 @@ static TransactionReceipt berlinTransactionReceiptFactoryWithReasonEnabled(
private record DaoBlockProcessor(BlockProcessor wrapped) implements BlockProcessor {

@Override
public BlockProcessingResult processBlock(
final Blockchain blockchain,
final MutableWorldState worldState,
final BlockHeader blockHeader,
final List<Transaction> transactions,
final List<BlockHeader> ommers,
final Optional<List<Withdrawal>> withdrawals,
final PrivateMetadataUpdater privateMetadataUpdater) {
updateWorldStateForDao(worldState);
return wrapped.processBlock(
blockchain,
worldState,
blockHeader,
transactions,
ommers,
withdrawals,
privateMetadataUpdater);
}
public BlockProcessingResult processBlock(
final Blockchain blockchain,
final MutableWorldState worldState,
final BlockHeader blockHeader,
final List<Transaction> transactions,
final List<BlockHeader> ommers,
final Optional<List<Withdrawal>> withdrawals,
final PrivateMetadataUpdater privateMetadataUpdater) {
updateWorldStateForDao(worldState);
return wrapped.processBlock(
blockchain,
worldState,
blockHeader,
transactions,
ommers,
withdrawals,
privateMetadataUpdater);
}

private static final Address DAO_REFUND_CONTRACT_ADDRESS =
Address.fromHexString("0xbf4ed7b27f1d666546e30d74d50d173d20bca754");

private void updateWorldStateForDao(final MutableWorldState worldState) {
try {
final JsonArray json =
new JsonArray(
Resources.toString(
Objects.requireNonNull(this.getClass().getResource("/daoAddresses.json")),
StandardCharsets.UTF_8));
final List<Address> addresses =
IntStream.range(0, json.size())
.mapToObj(json::getString)
.map(Address::fromHexString)
.toList();
final WorldUpdater worldUpdater = worldState.updater();
final MutableAccount daoRefundContract =
worldUpdater.getOrCreate(DAO_REFUND_CONTRACT_ADDRESS);
for (final Address address : addresses) {
final MutableAccount account = worldUpdater.getOrCreate(address);
final Wei balance = account.getBalance();
account.decrementBalance(balance);
daoRefundContract.incrementBalance(balance);
}
worldUpdater.commit();
} catch (final IOException e) {
throw new IllegalStateException(e);
private static final Address DAO_REFUND_CONTRACT_ADDRESS =
Address.fromHexString("0xbf4ed7b27f1d666546e30d74d50d173d20bca754");

private void updateWorldStateForDao(final MutableWorldState worldState) {
try {
final JsonArray json =
new JsonArray(
Resources.toString(
Objects.requireNonNull(this.getClass().getResource("/daoAddresses.json")),
StandardCharsets.UTF_8));
final List<Address> addresses =
IntStream.range(0, json.size())
.mapToObj(json::getString)
.map(Address::fromHexString)
.toList();
final WorldUpdater worldUpdater = worldState.updater();
final MutableAccount daoRefundContract =
worldUpdater.getOrCreate(DAO_REFUND_CONTRACT_ADDRESS);
for (final Address address : addresses) {
final MutableAccount account = worldUpdater.getOrCreate(address);
final Wei balance = account.getBalance();
account.decrementBalance(balance);
daoRefundContract.incrementBalance(balance);
}
worldUpdater.commit();
} catch (final IOException e) {
throw new IllegalStateException(e);
}
}
}
}

0 comments on commit 5427be5

Please sign in to comment.