besu icon indicating copy to clipboard operation
besu copied to clipboard

Besu can't interpret nonce as integer for preloaded contracts

Open barnabasbusa opened this issue 1 year ago • 3 comments

When I try to run besu with the following preloaded contract (kurtosis config)

participants:
  - el_type: geth
  - el_type: besu
network_params:
  preset: minimal
  genesis_delay: 5
  additional_preloaded_contracts: '{
                    "0x4e59b44847b379578588920cA78FbF26c0B4956C": {
                        "balance": "0ETH",
                        "code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3",
                        "storage": {},
                        "nonce": 1,
                        "secretKey": "0x"
                    }
                }'

I get the following error message:

2024-10-09 13:36:05.708+00:00 | main | ERROR | Besu | Failed to start Besu
picocli.CommandLine$ExecutionException: java.lang.IllegalArgumentException: Expected string value but got number
	at org.hyperledger.besu.cli.BesuCommand.buildController(BesuCommand.java:1826)
	at org.hyperledger.besu.cli.BesuCommand.run(BesuCommand.java:1117)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
	at picocli.CommandLine.execute(CommandLine.java:2174)
	at org.hyperledger.besu.cli.BesuCommand.lambda$createExecuteTask$1(BesuCommand.java:1041)
	at picocli.CommandLine.execute(CommandLine.java:2174)
	at org.hyperledger.besu.cli.BesuCommand.lambda$createPluginRegistrationTask$2(BesuCommand.java:1051)
	at picocli.CommandLine.execute(CommandLine.java:2174)
	at org.hyperledger.besu.cli.util.ConfigDefaultValueProviderStrategy.execute(ConfigDefaultValueProviderStrategy.java:58)
	at picocli.CommandLine.execute(CommandLine.java:2174)
	at org.hyperledger.besu.cli.BesuCommand.executeCommandLine(BesuCommand.java:1078)
	at org.hyperledger.besu.cli.BesuCommand.parse(BesuCommand.java:1020)
	at org.hyperledger.besu.Besu.main(Besu.java:41)
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Expected string value but got number
	at org.hyperledger.besu.ethereum.chain.GenesisState.calculateGenesisStateRoot(GenesisState.java:191)
	at org.hyperledger.besu.ethereum.chain.GenesisState.fromConfig(GenesisState.java:118)
	at org.hyperledger.besu.controller.BesuControllerBuilder.lambda$getGenesisState$4(BesuControllerBuilder.java:797)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at org.hyperledger.besu.controller.BesuControllerBuilder.getGenesisState(BesuControllerBuilder.java:795)
	at org.hyperledger.besu.controller.BesuControllerBuilder.build(BesuControllerBuilder.java:572)
	at org.hyperledger.besu.controller.TransitionBesuControllerBuilder.build(TransitionBesuControllerBuilder.java:291)
	at org.hyperledger.besu.cli.BesuCommand.buildController(BesuCommand.java:1824)
	... 18 more
Caused by: java.lang.IllegalArgumentException: Expected string value but got number
	at org.hyperledger.besu.config.JsonUtil.validateType(JsonUtil.java:585)
	at org.hyperledger.besu.config.JsonUtil.lambda$getString$2(JsonUtil.java:154)
	at java.base/java.util.Optional.filter(Optional.java:218)
	at org.hyperledger.besu.config.JsonUtil.getString(JsonUtil.java:154)
	at org.hyperledger.besu.config.GenesisReader$FromObjectNode.lambda$streamAllocations$0(GenesisReader.java:83)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.hyperledger.besu.ethereum.chain.GenesisState.writeAccountsTo(GenesisState.java:172)
	at org.hyperledger.besu.ethereum.chain.GenesisState.calculateGenesisStateRoot(GenesisState.java:188)
	... 25 more
java.lang.IllegalArgumentException: Expected string value but got number

To display full help:
besu [COMMAND] --help

Every other client able to interpret nonce as an integer, but for besu it needs to be set as "nonce": "1". Thats why I assume its a bug on besu's side.

barnabasbusa avatar Oct 09 '24 13:10 barnabasbusa