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

Closed
barnabasbusa opened this issue Oct 9, 2024 · 4 comments · Fixed by #7850
Closed

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

barnabasbusa opened this issue Oct 9, 2024 · 4 comments · Fixed by #7850
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.

@cloudspores
Copy link
Contributor

cloudspores commented Oct 16, 2024

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

Thanks Sally, I'll work on this today.

@vaidikcode
Copy link
Contributor

@jflo Can you assign this to me?

vaidikcode added a commit to vaidikcode/besu that referenced this issue Nov 3, 2024
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>
vaidikcode added a commit to vaidikcode/besu that referenced this issue Nov 4, 2024
@jflo jflo assigned vaidikcode and unassigned cloudspores Nov 4, 2024
macfarla added a commit to vaidikcode/besu that referenced this issue Nov 4, 2024
fab-10 added a commit to vaidikcode/besu that referenced this issue Nov 5, 2024
fab-10 added a commit that referenced this issue Nov 5, 2024
* fixes #7749
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>

* tests
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>

* spotless format fix
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>

---------

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
JanetMo pushed a commit to JanetMo/besu that referenced this issue Nov 17, 2024
* fixes hyperledger#7749
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>

* tests
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>

* spotless format fix
Signed-off-by: vaidikcode <vaidikbhardwaj00@gmail.com>

---------

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Marlene Marz <m.marz@kabelmail.de>
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

Successfully merging a pull request may close this issue.

6 participants
@macfarla @daniellehrner @barnabasbusa @cloudspores @vaidikcode and others