Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Besu can't interpret nonce as integer for preloaded contracts #7749

Open
barnabasbusa opened this issue Oct 9, 2024 · 2 comments
Open

Besu can't interpret nonce as integer for preloaded contracts #7749

barnabasbusa opened this issue Oct 9, 2024 · 2 comments
Assignees
Labels
good first issue Good for newcomers snack Smaller coding task - less than a day for an experienced dev

Comments

@barnabasbusa
Copy link

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.

@macfarla macfarla added good first issue Good for newcomers snack Smaller coding task - less than a day for an experienced dev labels Oct 14, 2024
@macfarla
Copy link
Contributor

@cloudspores might fit with the genesis file parsing you're working on

@daniellehrner
Copy link
Contributor

@cloudspores I think that problem is that the method JsonUtil.getString that we use to get the nonce requires it explicitly to be a string: here

There is another method JsonUtil.getValueAsString that seems to read the value without expecting a specific format. I think we can just use that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers snack Smaller coding task - less than a day for an experienced dev
Projects
None yet
Development

No branches or pull requests

4 participants