iotex-core
iotex-core copied to clipboard
start a new PoS chain from zero with iotex-core
Description of new feature request
For blockchain developers to spawn a new chain (new chain id, network id) with IoTeX, proof of staking with a group of full-fledged validators is a significant feature. Currently, it is pretty hard to do so for legacy purposes - e.g., once using Ethereum as the gravity chain, transitioning from native staking v1 to v2, hard-forks in the entire history of IoTeX.
How to reproduce?
-
git clone [email protected]:puncsky/iotex-core.git
, which, as you can see in this diff, prepares genesisDelegates for native staking v2 and added configurations for 6 nodes, starts all hardforks from height of 1. - replace TODO_REPLACE_WITH_YOUR_OWN_SK_OR_ADDRESS in the
./config
directory with your own secret keys or addresses, separately for those 6 configurations and 1 genesis file. - run 6 nodes with
make run1
,make run2
, ...,make run6
What is the problem?
people cannot make native token transfers with ioctl or metamask
{"level":"error","ts":1713302918.3700109,"caller":"api/web3server.go:258","msg":"web3server","ioAddr":"ioAddressRedacted","requestParams":"{\"id\":5079593286506449,\"jsonrpc\":\"2.0\",\"method\":\"eth_sendRawTransaction\",\"params\":[\"0xf87102860500918bd800825208943847b796ef3122208306ba1e5d78d1d275d7a6b1897270029371519c00008083071f0ea080b7520b60478afb39e22856d3258c58c538190489797c8114cfa602dbcdcdffa00a6887ba06bf4b7ce9b724b998cd4a07c5230b59baad0bdd62023febf2ac7168\"]}","error":"rpc error: code = Internal desc = ioAddressRedacted: nonce too low"}
and the height increase stopped from heights 119 to 120
{"level":"error","ts":1713304653.951641,"caller":"consensusfsm/fsm.go:407","msg":"failed to generate block proposal","ioAddr":"ioAddressRedacted","height":120,"epoch":1,"round":77,"proposer":"ioAddressRedacted","error":"failed to create block builder at new block height 120: failed to prepare delegates for next epoch 2: failed to fetch delegates by epoch height 1, empty list: delegates cannot be found","errorVerbose":"delegates cannot be found\ngithub.com/iotexproject/iotex-core/action/protocol/poll.init\n\t<autogenerated>:1\nruntime.doInit1\n\t/usr/local/opt/go/libexec/src/runtime/proc.go:7176\nruntime.doInit\n\t/usr/local/opt/go/libexec/src/runtime/proc.go:7143\nruntime.main\n\t/usr/local/opt/go/libexec/src/runtime/proc.go:253\nruntime.goexit\n\t/usr/local/opt/go/libexec/src/runtime/asm_amd64.s:1695\nfailed to fetch delegates by epoch height 1, empty list\ngithub.com/iotexproject/iotex-core/action/protocol/poll.createPostSystemActions\n\t/iotex-core/action/protocol/poll/util.go:135\ngithub.com/iotexproject/iotex-core/action/protocol/poll.(*stakingCommand).CreatePostSystemActions\n\tiotex-core/action/protocol/poll/staking_command.go:85\ngithub.com/iotexproject/iotex-core/state/factory.(*stateDB).NewBlockBuilder\n\t/iotex-core/state/factory/statedb.go:332\ngithub.com/iotexproject/iotex-core/state/factory.(*minter).NewBlockBuilder\n\t/iotex-core/state/factory/minter.go:30\ngithub.com/iotexproject/iotex-core/blockchain.(*blockchain).MintNewBlock\n\t/iotex-core/blockchain/blockchain.go:392\ngithub.com/iotexproject/iotex-core/consensus/scheme/rolldpos.(*rollDPoSCtx).mintNewBlock\n\t/iotex-core/consensus/scheme/rolldpos/rolldposctx.go:590\ngithub.com/iotexproject/iotex-core/consensus/scheme/rolldpos.(*rollDPoSCtx).Proposal\n\tiotex-core/consensus/consensusfsm/fsm.go:236\nruntime.goexit\n\t/usr/local/opt/go/libexec/src/runtime/asm_amd64.s:1695"}
What is expected?
It should run smoothly with those 6 nodes - people should be able to make native token transfers with ioctl or metamask. the block height should increase over time.
Is this a hard-fork (and height to be activated)
- [] Yes
- Name of activation height:
Implementation plan
- [] Phase 1 description (PR number)
- [] Phase 2 description (PR number)
- [] Phase 3 description (PR number)
Affected modules
- [] action
- [] actpool
- [] api
- [] blockchain
- [] blockindex
- [] blocksync
- [] chainservice
- [] config
- [x] consensus
- [] db
- [] dispatcher
- [] ioctl
- [] p2p
- [] server
- [] state
- [] tools