Simulation in the Local Environment
Set up a Full Node#
To simulate BP nodes in a local environment, you need to set up at least three nodes, as a single node cannot become a BP. BP elections occur every 7 days, but for this tutorial, we'll change the term to 120 seconds. Follow the steps below:
1"Consensus": {2"InitialMinerList": [3"04884d9563b3b67a5526dd489e3805211cba710d956718",4"045670526219d73158629891b0617ab605e646ae78961c",5"046a5913eae5fee3d3826beb2b7109b5141679a1927338"6],7"MiningInterval": 4000,8"StartTimestamp": 0,9"PeriodSeconds": 120,10"MinerIncreaseInterval": 3153600011}
Become a Candidate Node
1aelf-command call AElf.ContractNames.Token GetBalance '{"symbol": "ELF", "owner": "YOUR_ADDRESS"}'
1aelf-command send AElf.ContractNames.Token Transfer '{"symbol": "ELF", "to": "YOUR_ADDRESS", "amount": "10000000000000"}'
1aelf-command send AElf.ContractNames.Election AnnounceElection '{"value": "YOUR_ADDRESS"}' -a YOUR_ADDRESS
1aelf-command call AElf.ContractNames.Election GetCandidateInformation '{"value":"YOUR_PUBLIC_KEY"}'
Users Vote for Nodes
1aelf-command create
1aelf-command send AElf.ContractNames.Token Transfer '{"symbol": "ELF", "to": "USER_ADDRESS", "amount": "200000000000"}'
1aelf-command call AElf.ContractNames.Token GetBalance '{"symbol": "ELF", "owner": "USER_ADDRESS"}'
1aelf-command send AElf.ContractNames.Election Vote '{"candidatePubkey":"CANDIDATE_PUBLIC_KEY","amount":2000000000,"endTimestamp":{"seconds":1600271999,"nanos":999000}}' -a USER_ADDRESS
1aelf-command call AElf.ContractNames.Election GetCandidateVote '{"value":"CANDIDATE_PUBLIC_KEY"}'
Become a BP
The top 2N+1 candidate nodes are elected as BPs in the next term. Get the list of current BPs:
1aelf-command call AElf.ContractNames.Consensus GetCurrentMinerPubkeyList '{}'
Add More BPs#
Repeat the steps to add more BPs. No need to edit appsettings.json again. When candidate nodes exceed the max BPs, they replace genesis nodes, which cannot participate in elections again.
Proceed to contract deployment and DApp development guides for more details.
Edited on: 17 July 2024 03:27:13 GMT+0