Skip to content

Commit

Permalink
Missing withdrawals wiring in BlockProcessor
Browse files Browse the repository at this point in the history
Add empty withdrawals in GenesisState for shanghai at genesis
Signed-off-by: Simon Dudley <[email protected]>
  • Loading branch information
siladu committed Jan 22, 2023
1 parent 3a210fc commit 7473a3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package org.hyperledger.besu.ethereum.chain;

import static java.util.Collections.emptyList;

import org.hyperledger.besu.config.GenesisAllocation;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.datatypes.Address;
Expand All @@ -25,6 +27,7 @@
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.HeaderBasedProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
Expand All @@ -37,11 +40,11 @@
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;

import java.math.BigInteger;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalLong;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand All @@ -53,9 +56,6 @@

public final class GenesisState {

private static final BlockBody BODY =
new BlockBody(Collections.emptyList(), Collections.emptyList());

private final Block block;
private final List<GenesisAccount> genesisAccounts;

Expand Down Expand Up @@ -89,10 +89,16 @@ public static GenesisState fromConfig(
final Block block =
new Block(
buildHeader(config, calculateGenesisStateHash(genesisAccounts), protocolSchedule),
BODY);
buildBody(config));
return new GenesisState(block, genesisAccounts);
}

private static BlockBody buildBody(final GenesisConfigFile config) {
final Optional<List<Withdrawal>> withdrawals =
isShanghaiAtGenesis(config) ? Optional.of(emptyList()) : Optional.empty();
return new BlockBody(emptyList(), emptyList(), withdrawals);
}

public Block getBlock() {
return block;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ default BlockProcessingResult processBlock(
block.getHeader(),
block.getBody().getTransactions(),
block.getBody().getOmmers(),
Optional.empty(),
block.getBody().getWithdrawals(),
null);
}

Expand Down

0 comments on commit 7473a3a

Please sign in to comment.