Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
Signed-off-by: Danno Ferrin <[email protected]>
  • Loading branch information
shemnon committed Oct 26, 2023
2 parents a37fd7b + f58f6cf commit 86815f6
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 70 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

### Download Links

## 23.10.2

### Breaking Changes

### Deprecations

### Additions and Improvements
- Ethereum Classic Spiral network upgrade [#6078](https://github.com/hyperledger/besu/pull/6078)

### Bug fixes

### Download Links

## 23.10.1
- Cache last n blocks by using a new Besu flag --cache-last-blocks=n [#6009](https://github.com/hyperledger/besu/pull/6009)
- Optimize performances of RPC method Eth_feeHistory [#6011](https://github.com/hyperledger/besu/pull/6011)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.hyperledger.besu.plugin.services.BesuEvents;
import org.hyperledger.besu.plugin.services.PicoCLIOptions;
import org.hyperledger.besu.plugin.services.PluginTransactionValidatorService;
import org.hyperledger.besu.plugin.services.RpcEndpointService;
import org.hyperledger.besu.plugin.services.SecurityModuleService;
import org.hyperledger.besu.plugin.services.StorageService;
import org.hyperledger.besu.plugin.services.TransactionSelectionService;
Expand Down Expand Up @@ -98,6 +99,7 @@ private BesuPluginContextImpl buildPluginContext(
besuPluginContext.addService(StorageService.class, storageService);
besuPluginContext.addService(SecurityModuleService.class, securityModuleService);
besuPluginContext.addService(PicoCLIOptions.class, new PicoCLIOptionsImpl(commandLine));
besuPluginContext.addService(RpcEndpointService.class, new RpcEndpointServiceImpl());
besuPluginContext.addService(
TransactionSelectionService.class, new TransactionSelectionServiceImpl());
besuPluginContext.addService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ public static Collection<Object[]> parameters() {
new ForkId(Bytes.ofUnsignedInt(0xf42f5539L), 2520000L),
new ForkId(Bytes.ofUnsignedInt(0x66b5c286L), 3985893),
new ForkId(Bytes.ofUnsignedInt(0x92b323e0L), 5520000L),
new ForkId(Bytes.ofUnsignedInt(0x8c9b1797L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x8c9b1797L), 0L))
new ForkId(Bytes.ofUnsignedInt(0x8c9b1797L), 9957000L),
new ForkId(Bytes.ofUnsignedInt(0x3a6b00d7L), 0L),
new ForkId(Bytes.ofUnsignedInt(0x3a6b00d7L), 0L))
},
new Object[] {
NetworkName.CLASSIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,15 @@ default boolean isConsensusMigration() {
*/
OptionalLong getMystiqueBlockNumber();

/**
* Block number to activate Spiral on Classic networks.
*
* @return block number of Spiral fork on Classic networks
* @see <a
* href="https://ecips.ethereumclassic.org/ECIPs/ecip-1109">https://ecips.ethereumclassic.org/ECIPs/ecip-1109</a>
*/
OptionalLong getSpiralBlockNumber();

/**
* Gets chain id.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ public OptionalLong getMystiqueBlockNumber() {
return getOptionalLong("mystiqueblock");
}

@Override
public OptionalLong getSpiralBlockNumber() {
return getOptionalLong("spiralblock");
}

@Override
public Optional<BigInteger> getChainId() {
return getOptionalBigInteger("chainid");
Expand Down Expand Up @@ -460,6 +465,7 @@ public Map<String, Object> asMap() {
getThanosBlockNumber().ifPresent(l -> builder.put("thanosBlock", l));
getMagnetoBlockNumber().ifPresent(l -> builder.put("magnetoBlock", l));
getMystiqueBlockNumber().ifPresent(l -> builder.put("mystiqueBlock", l));
getSpiralBlockNumber().ifPresent(l -> builder.put("spiralBlock", l));

getContractSizeLimit().ifPresent(l -> builder.put("contractSizeLimit", l));
getEvmStackSize().ifPresent(l -> builder.put("evmstacksize", l));
Expand Down Expand Up @@ -567,7 +573,8 @@ public List<Long> getForkBlockNumbers() {
getPhoenixBlockNumber(),
getThanosBlockNumber(),
getMagnetoBlockNumber(),
getMystiqueBlockNumber());
getMystiqueBlockNumber(),
getSpiralBlockNumber());
// when adding forks add an entry to ${REPO_ROOT}/config/src/test/resources/all_forks.json

return forkBlockNumbers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
private OptionalLong thanosBlockNumber = OptionalLong.empty();
private OptionalLong magnetoBlockNumber = OptionalLong.empty();
private OptionalLong mystiqueBlockNumber = OptionalLong.empty();
private OptionalLong spiralBlockNumber = OptionalLong.empty();
private Optional<BigInteger> chainId = Optional.empty();
private OptionalInt contractSizeLimit = OptionalInt.empty();
private OptionalInt stackSizeLimit = OptionalInt.empty();
Expand Down Expand Up @@ -316,6 +317,11 @@ public OptionalLong getMystiqueBlockNumber() {
return mystiqueBlockNumber;
}

@Override
public OptionalLong getSpiralBlockNumber() {
return spiralBlockNumber;
}

@Override
public OptionalInt getContractSizeLimit() {
return contractSizeLimit;
Expand Down Expand Up @@ -374,6 +380,7 @@ public Map<String, Object> asMap() {
getThanosBlockNumber().ifPresent(l -> builder.put("thanosBlock", l));
getMagnetoBlockNumber().ifPresent(l -> builder.put("magnetoBlock", l));
getMystiqueBlockNumber().ifPresent(l -> builder.put("mystiqueBlock", l));
getSpiralBlockNumber().ifPresent(l -> builder.put("spiralBlock", l));

getContractSizeLimit().ifPresent(l -> builder.put("contractSizeLimit", l));
getEvmStackSize().ifPresent(l -> builder.put("evmStackSize", l));
Expand Down Expand Up @@ -800,6 +807,17 @@ public StubGenesisConfigOptions mystique(final long blockNumber) {
return this;
}

/**
* Spiral stub genesis config options.
*
* @param blockNumber the block number
* @return the stub genesis config options
*/
public StubGenesisConfigOptions spiral(final long blockNumber) {
spiralBlockNumber = OptionalLong.of(blockNumber);
return this;
}

/**
* Chain id stub genesis config options.
*
Expand Down
2 changes: 2 additions & 0 deletions config/src/main/resources/mordor.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"thanosBlock": 2520000,
"magnetoBlock": 3985893,
"mystiqueBlock": 5520000,
"spiralBlock": 9957000,
"ethash": {},
"discovery": {
"dns": "enrtree://AJE62Q4DUX4QMMXEHCSSCSC65TDHZYSMONSD64P3WULVLSF6MRQ3K@all.mordor.blockd.info",
"bootnodes": [
"enode://642cf9650dd8869d42525dbf6858012e3b4d64f475e733847ab6f7742341a4397414865d953874e8f5ed91b0e4e1c533dee14ad1d6bb276a5459b2471460ff0d@157.230.152.87:30303",
"enode://651b484b652c07c72adebfaaf8bc2bd95b420b16952ef3de76a9c00ef63f07cca02a20bd2363426f9e6fe372cef96a42b0fec3c747d118f79fd5e02f2a4ebd4e@51.158.190.99:45678",
Expand Down
3 changes: 2 additions & 1 deletion config/src/test/resources/all_forks.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"phoenixBlock": 108,
"thanosBlock": 109,
"magnetoBlock": 110,
"mystiqueBlock": 111
"mystiqueBlock": 111,
"spiralBlock": 112
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ public void returnsClassicForkBlocks() {
.phoenix(8)
.thanos(9)
.magneto(10)
.mystique(12);
.mystique(11)
.spiral(12);

final AdminNodeInfo methodClassic =
new AdminNodeInfo(
Expand All @@ -403,7 +404,8 @@ public void returnsClassicForkBlocks() {
"phoenixBlock", 8L,
"thanosBlock", 9L,
"magnetoBlock", 10L));
expectedConfig.put("mystiqueBlock", 12L);
expectedConfig.put("mystiqueBlock", 11L);
expectedConfig.put("spiralBlock", 12L);

final JsonRpcResponse response = methodClassic.response(request);
assertThat(response).isInstanceOf(JsonRpcSuccessResponse.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
import org.hyperledger.besu.ethereum.proof.WorldStateProof;
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.storage.StorageProvider;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.trie.patricia.StoredMerklePatriciaTrie;
import org.hyperledger.besu.ethereum.worldstate.DataStorageFormat;
import org.hyperledger.besu.ethereum.worldstate.StateTrieAccountValue;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
Expand Down Expand Up @@ -69,24 +67,6 @@ public class BonsaiWorldStateProvider implements WorldStateArchive {
private final BonsaiWorldStateKeyValueStorage worldStateStorage;
private final CachedMerkleTrieLoader cachedMerkleTrieLoader;

public BonsaiWorldStateProvider(
final StorageProvider provider,
final Blockchain blockchain,
final CachedMerkleTrieLoader cachedMerkleTrieLoader,
final ObservableMetricsSystem metricsSystem,
final BesuContext pluginContext,
final EvmConfiguration evmConfiguration) {
this(
(BonsaiWorldStateKeyValueStorage)
provider.createWorldStateStorage(DataStorageFormat.BONSAI),
blockchain,
Optional.empty(),
cachedMerkleTrieLoader,
metricsSystem,
pluginContext,
evmConfiguration);
}

public BonsaiWorldStateProvider(
final BonsaiWorldStateKeyValueStorage worldStateStorage,
final Blockchain blockchain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.hyperledger.besu.evm.gascalculator.IstanbulGasCalculator;
import org.hyperledger.besu.evm.gascalculator.LondonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.PetersburgGasCalculator;
import org.hyperledger.besu.evm.gascalculator.ShanghaiGasCalculator;
import org.hyperledger.besu.evm.gascalculator.SpuriousDragonGasCalculator;
import org.hyperledger.besu.evm.gascalculator.TangerineWhistleGasCalculator;
import org.hyperledger.besu.evm.internal.EvmConfiguration;
Expand Down Expand Up @@ -333,4 +334,46 @@ public static ProtocolSpecBuilder mystiqueDefinition(
1))
.name("Mystique");
}

public static ProtocolSpecBuilder spiralDefinition(
final Optional<BigInteger> chainId,
final OptionalInt configContractSizeLimit,
final OptionalInt configStackSizeLimit,
final boolean enableRevertReason,
final OptionalLong ecip1017EraRounds,
final EvmConfiguration evmConfiguration) {
final int stackSizeLimit = configStackSizeLimit.orElse(MessageFrame.DEFAULT_MAX_STACK_SIZE);
return mystiqueDefinition(
chainId,
configContractSizeLimit,
configStackSizeLimit,
enableRevertReason,
ecip1017EraRounds,
evmConfiguration)
// EIP-3860
.gasCalculator(ShanghaiGasCalculator::new)
// EIP-3855
.evmBuilder(
(gasCalculator, jdCacheConfig) ->
MainnetEVMs.shanghai(
gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
// EIP-3651
.transactionProcessorBuilder(
(gasCalculator,
feeMarket,
transactionValidatorFactory,
contractCreationProcessor,
messageCallProcessor) ->
new MainnetTransactionProcessor(
gasCalculator,
transactionValidatorFactory,
contractCreationProcessor,
messageCallProcessor,
true,
true,
stackSizeLimit,
feeMarket,
CoinbaseFeePriceCalculator.frontier()))
.name("Spiral");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,14 @@ public ProtocolSpecBuilder mystiqueDefinition() {
ecip1017EraRounds,
evmConfiguration);
}

public ProtocolSpecBuilder spiralDefinition() {
return ClassicProtocolSpecs.spiralDefinition(
chainId,
contractSizeLimit,
evmStackSize,
isRevertReasonEnabled,
ecip1017EraRounds,
evmConfiguration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ private void validateClassicForkOrdering() {
lastForkBlock = validateForkOrder("Thanos", config.getThanosBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Magneto", config.getMagnetoBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Mystique", config.getMystiqueBlockNumber(), lastForkBlock);
lastForkBlock = validateForkOrder("Spiral", config.getSpiralBlockNumber(), lastForkBlock);
assert (lastForkBlock >= 0);
}

Expand Down Expand Up @@ -329,7 +330,8 @@ private Stream<Optional<BuilderMapEntry>> createMilestones(
blockNumberMilestone(config.getPhoenixBlockNumber(), specFactory.phoenixDefinition()),
blockNumberMilestone(config.getThanosBlockNumber(), specFactory.thanosDefinition()),
blockNumberMilestone(config.getMagnetoBlockNumber(), specFactory.magnetoDefinition()),
blockNumberMilestone(config.getMystiqueBlockNumber(), specFactory.mystiqueDefinition()));
blockNumberMilestone(config.getMystiqueBlockNumber(), specFactory.mystiqueDefinition()),
blockNumberMilestone(config.getSpiralBlockNumber(), specFactory.spiralDefinition()));
}

private Optional<BuilderMapEntry> timestampMilestone(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.chain.DefaultBlockchain;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
Expand All @@ -36,6 +37,8 @@
import org.hyperledger.besu.services.kvstore.InMemoryKeyValueStorage;
import org.hyperledger.besu.services.kvstore.SegmentedInMemoryKeyValueStorage;

import java.util.Optional;

public class InMemoryKeyValueStorageProvider extends KeyValueStorageProvider {

public InMemoryKeyValueStorageProvider() {
Expand Down Expand Up @@ -93,8 +96,10 @@ public static BonsaiWorldStateProvider createBonsaiInMemoryWorldStateArchive(
final CachedMerkleTrieLoader cachedMerkleTrieLoader =
new CachedMerkleTrieLoader(new NoOpMetricsSystem());
return new BonsaiWorldStateProvider(
inMemoryKeyValueStorageProvider,
(BonsaiWorldStateKeyValueStorage)
inMemoryKeyValueStorageProvider.createWorldStateStorage(DataStorageFormat.BONSAI),
blockchain,
Optional.empty(),
cachedMerkleTrieLoader,
new NoOpMetricsSystem(),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.bonsai.BonsaiWorldStateProvider;
import org.hyperledger.besu.ethereum.bonsai.cache.CachedMerkleTrieLoader;
import org.hyperledger.besu.ethereum.bonsai.storage.BonsaiWorldStateKeyValueStorage;
import org.hyperledger.besu.ethereum.bonsai.worldview.BonsaiWorldState;
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
Expand Down Expand Up @@ -83,19 +82,10 @@ class BlockImportExceptionHandlingTest {
private final WorldStateStorage worldStateStorage =
new BonsaiWorldStateKeyValueStorage(storageProvider, new NoOpMetricsSystem());

private CachedMerkleTrieLoader cachedMerkleTrieLoader;

private final WorldStateArchive worldStateArchive =
// contains a BonsaiWorldState which we need to spy on.
// do we need to also test with a DefaultWorldStateArchive?
spy(
new BonsaiWorldStateProvider(
storageProvider,
blockchain,
cachedMerkleTrieLoader,
new NoOpMetricsSystem(),
null,
EvmConfiguration.DEFAULT));
spy(InMemoryKeyValueStorageProvider.createBonsaiInMemoryWorldStateArchive(blockchain));

private final BonsaiWorldState persisted =
spy(
Expand All @@ -116,7 +106,6 @@ public void setup() {
mainnetBlockValidator =
new MainnetBlockValidator(
blockHeaderValidator, blockBodyValidator, blockProcessor, badBlockManager);
cachedMerkleTrieLoader = new CachedMerkleTrieLoader(new NoOpMetricsSystem());
}

@Test
Expand Down
Loading

0 comments on commit 86815f6

Please sign in to comment.