Skip to content

Commit

Permalink
Merge branch 'main' into zkbesu
Browse files Browse the repository at this point in the history
  • Loading branch information
fab-10 committed Nov 6, 2024
2 parents eb7bb53 + 4099b3b commit 640d3ba
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public BesuPluginContextImpl providePluginContext(
final RpcEndpointServiceImpl rpcEndpointServiceImpl,
final BesuConfiguration commonPluginConfiguration,
final PermissioningServiceImpl permissioningService,
final MetricsConfiguration metricsConfiguration,
final MetricCategoryRegistryImpl metricCategoryRegistry,
final MetricsSystem metricsSystem,
final @Named("ExtraCLIOptions") List<String> extraCLIOptions,
Expand All @@ -512,6 +513,7 @@ public BesuPluginContextImpl providePluginContext(
TransactionSimulationService.class, transactionSimulationServiceImpl);
besuPluginContext.addService(BlockchainService.class, blockchainServiceImpl);
besuPluginContext.addService(BesuConfiguration.class, commonPluginConfiguration);
metricCategoryRegistry.setMetricsConfiguration(metricsConfiguration);
besuPluginContext.addService(MetricCategoryRegistry.class, metricCategoryRegistry);
besuPluginContext.addService(MetricsSystem.class, metricsSystem);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ protected ProtocolSchedule createProtocolSchedule() {
genesisConfigOptions,
forksSchedule,
nodeKey,
privacyParameters,
isRevertReasonEnabled,
evmConfiguration,
miningConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public Stream<GenesisAccount> streamAllocations() {
final var on = normalizeKeys((ObjectNode) entry.getValue());
return new GenesisAccount(
Address.fromHexString(entry.getKey()),
JsonUtil.getString(on, "nonce").map(ParserUtils::parseUnsignedLong).orElse(0L),
JsonUtil.getValueAsString(on, "nonce")
.map(ParserUtils::parseUnsignedLong)
.orElse(0L),
JsonUtil.getString(on, "balance")
.map(ParserUtils::parseBalance)
.orElse(Wei.ZERO),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.config.GenesisReader.ALLOCATION_FIELD;
import static org.hyperledger.besu.config.GenesisReader.CONFIG_FIELD;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
Expand All @@ -27,6 +28,7 @@
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
Expand Down Expand Up @@ -111,4 +113,17 @@ private ObjectNode generateAllocation(final Wei balance) {
entry.put("balance", balance.toShortHexString());
return entry;
}

@Test
void testNonceHandlingAsStringAndInteger() {
ObjectNode accountNode = JsonNodeFactory.instance.objectNode();

accountNode.put("nonce", 10);
String nonceAsStringFromInt = JsonUtil.getValueAsString(accountNode, "nonce").orElse("");
assertEquals("10", nonceAsStringFromInt, "Nonce should convert integer to string correctly");

accountNode.put("nonce", "20");
String nonceAsStringDirect = JsonUtil.getValueAsString(accountNode, "nonce").orElse("");
assertEquals("20", nonceAsStringDirect, "Nonce should keep string as string correctly");
}
}
11 changes: 10 additions & 1 deletion platform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ dependencies {
api project(':acceptance-tests:dsl')
api project(':besu')
api project(':config')
api project(':consensus:clique')
api project(':consensus:common')
api project(':consensus:ibft')
api project(':consensus:merge')
api project(':consensus:qbft')
api project(':crypto:algorithms')
api project(':crypto:services')
api project(':datatypes')
api project(':ethereum:api')
api project(':ethereum:blockcreation')
api project(':ethereum:core')
Expand All @@ -53,9 +59,12 @@ dependencies {
api project(':ethereum:permissioning')
api project(':ethereum:referencetests')
api project(':ethereum:rlp')
api project(':ethereum:trie')
api project(':evm')
api project(':datatypes')
api project(':metrics:core')
api project(':plugin-api')
api project(':testutil')
api project(':util')

api 'com.github.ben-manes.caffeine:caffeine:3.1.8'

Expand Down

0 comments on commit 640d3ba

Please sign in to comment.