Geth version: 1.5.6
OS & Version: Ubuntu 16.04
Commit hash : (if develop)
1.5.6-stable release modified to change block-time
According to https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console#debugsethead
It should accept dec and rollback blockchain to set number
Error: invalid argument 0: cannot unmarshal non-string as hex data
at web3.js:3119:20
at web3.js:6023:15
at web3.js:4995:36
at
debug.setHead(10000)
Error: invalid argument 0: cannot unmarshal non-string as hex data
at web3.js:3119:20
at web3.js:6023:15
at web3.js:4995:36
at:1:1
Sending a hex, however works
debug.setHead("0x2710")
null
So either change function to accept dec, or modify the wiki to reflect latest changes
@fjl, this was changed with the introduction of the hexutil package. Other functions of the debug api still accept uint64. Did you had a specific reason for this change?
Otherwise we can convert uint64 arguments to hexutil.Uint64 and define custom input formatters in web3ext. That way the rpc interface is compliant and users can still use decimal numbers in the console.
@hrishikeshio note that rpc methods in the debug package are not considered safe for use. For instance the setHead method has a race condition in it that can cause database corruption.
Oh. I was using it to demonstrate how blockchain can recover if someone tries to deliberately rollback one of the nodes. Any alternative to this? @bas-vk
Not sure what you mean with recover the chain?
debug.setHead sets the chain head to an older block. If you want to do such a thing the safest solution is to export the relevant part of the chain and import it into a fresh datadir.
> geth export /tmp/chain.dump 0 1000 (inclusive, this will export 1001 blocks)
> geth import /tmp/chain.dump
Still only takes hex. Updated API documentation link (still says decimal).
> debug.setHead('1910103')
Error: invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type hexutil.Uint64
at web3.js:3104:20
at web3.js:6191:15
at web3.js:5004:36
at <anonymous>:1:1
> debug.setHead('0x1D2557')
WARN [11-18|20:38:21] Rewinding blockchain target=1910103
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Still only takes hex. Updated API documentation link (still says decimal).