Boot Sequence
aelf Blockchain Boot Sequence#
This guide explains how the aelf Blockchain starts from initial nodes and transitions to production nodes through elections, completing the full startup process.
Start Initial Nodes#
To begin the aelf Blockchain, you need to start at least one initial node. It’s recommended to start with 1-5 initial nodes.
Follow these steps to start multiple nodes:#
Setup Initial Nodes:#
Election Time Configuration:#
1{2"Consensus": {3"PeriodSeconds": 6048004}5}
By following these steps, you can successfully start the aelf Blockchain with initial nodes and prepare for the election of production nodes.
Run a Full Node#
Create an Account for the Full Node#
To create an account for the full node, use the following command:
1aelf-command create
You will receive your wallet information, which includes the mnemonic, private key, public key, and address. Here is an example of the output:
1AElf [Info]: Your wallet info is :2AElf [Info]: Mnemonic : major clap hurdle hammer push slogan ranch quantum reunion hope enroll repeat3AElf [Info]: Private Key : 2229945cf294431183fd1d8101e27b17a1a590d3a1f7f2b9299850b24262ed8a4AElf [Info]: Public Key : 04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef2679055AElf [Info]: Address : Q3t34SAEsxAQrSQidTRzDonWNTPpSTgH8bqu8pQUGCSWRPdRC
Start the Full Node#
Starting the full node involves similar steps to starting the initial nodes. However, ensure that the InitialMinerList in your configuration file matches the list from the initial node setup. Here is an example configuration:
1{2"InitialMinerList": [3"0499d3bb14337961c4d338b9729f46b20de8a49ed38e260a5c19a18da569462b44b820e206df8e848185dac6c139f05392c268effe915c147cde422e69514cc927",4"048397dfd9e1035fdd7260329d9492d88824f42917c156aef93fd7c2e3ab73b636f482b8ceb5cb435c556bfa067445a86e6f5c3b44ae6853c7f3dd7052609ed40b",5"041cc962a51e7bbdd829a8855eca8a03fda708fdf31969251321cb31edadd564bf3c6e7ab31b4c1f49f0f206be81dbe68a75c70b293bf9d04d867ee5e415d3bf8a"6]7}
By following these steps, you can successfully create an account and start your full node, ensuring it is properly configured to participate in the aelf blockchain network.
Full node started successfully:#
After starting the full node, verify its status to ensure it's properly synchronizing with the blockchain.
Check Node State#
To check the current state of the node, use the following command:
1aelf-command get-chain-status
This command will output the current status of the blockchain. Here's an example of what you might see:
1{2"ChainId": "AELF",3"Branches": {4"fb749177c2f43db8c7d73ea050240b9f870c40584f044b13e7ec146c460b0eff": 24495},6"NotLinkedBlocks": {},7"LongestChainHeight": 2449,8"LongestChainHash": "fb749177c2f43db8c7d73ea050240b9f870c40584f044b13e7ec146c460b0eff",9"GenesisBlockHash": "ea9c0b026bd638ceb38323eb71174814c95333e39c62936a38c4e01a8f18062e",10"GenesisContractAddress": "pykr77ft9UUKJZLVq15wCH8PinBSjVRQ12sD1Ayq92mKFsJ1i",11"LastIrreversibleBlockHash": "66638f538038bd56357f3cf205424e7393c5966830ef0d16a75d4a117847e0bc",12"LastIrreversibleBlockHeight": 2446,13"BestChainHash": "fb749177c2f43db8c7d73ea050240b9f870c40584f044b13e7ec146c460b0eff",14"BestChainHeight": 244915}
Understanding the Output#
When running a full node on the aelf blockchain network, the following key information is crucial for monitoring and understanding the node's status:
The BestChainHeight and LastIrreversibleBlockHeight should be increasing as the full node catches up with the initial nodes. Once the heights match, the node is fully synchronized, and you can proceed with further steps.
By following these details, you ensure that your full node is correctly set up and actively participating in the aelf blockchain network.
Become a Candidate Node#
To participate in the election process and become a candidate node, full nodes need to interact with the Election contract. Here's a step-by-step guide:
Step 1: Ensure Sufficient Tokens#
Full nodes must stake mortgage 10W ELF tokens to become candidates. Ensure your node's account has enough tokens. For demonstration purposes, you can transfer tokens from the initial node account to the full node account.
Transfer Tokens:#
1aelf-command send AElf.ContractNames.Token Transfer '{"symbol": "ELF", "to": "Q3t34SAEsxAQrSQidTRzDonWNTPpSTgH8bqu8pQUGCSWRPdRC", "amount": "20000000000000"}'
Check Balance:#
1aelf-command call AElf.ContractNames.Token GetBalance '{"symbol": "ELF", "owner": "Q3t34SAEsxAQrSQidTRzDonWNTPpSTgH8bqu8pQUGCSWRPdRC"}'
Expected Result:#
1{2"symbol": "ELF",3"owner": "Q3t34SAEsxAQrSQidTRzDonWNTPpSTgH8bqu8pQUGCSWRPdRC",4"balance": "20000000000000"5}
This result confirms that the full node account has 20W ELF tokens.
Step 2: Announce Candidacy#
Announce your candidacy using the Election contract. The AnnounceElection transaction requires the admin address to be specified.
Announce Election:#
1aelf-command send AElf.ContractNames.Election AnnounceElection '{"value": "Q3t34SAEsxAQrSQidTRzDonWNTPpSTgH8bqu8pQUGCSWRPdRC"}' -a Q3t34SAEsxAQrSQidTRzDonWNTPpSTgH8bqu8pQUGCSWRPdRC
Step 3: Verify Candidacy#
Check the candidate information to confirm that your full node is now a candidate.
Check Candidate Information::#
1aelf-command call AElf.ContractNames.Election GetCandidateInformation '{"value":"04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905"}'
Expected Result:#
1{2"terms": [],3"pubkey": "04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905",4"producedBlocks": "0",5"missedTimeSlots": "0",6"continualAppointmentCount": "0",7"announcementTransactionId": "8cc8eb5de35e390e4f7964bbdc7edc433498b041647761361903c6165b9f8659",8"isCurrentCandidate": true9}
This result indicates that the full node is now a candidate for the election, with the isCurrentCandidate field set to true.
By following these steps, your full node can successfully enter the election process and participate as a candidate node in the aelf blockchain network.
User vote election#
To demonstrate user voting in the election, follow these steps to create a user account, transfer tokens to the account, and then vote for a candidate node.
Step 1: Create a User Account#
Create a new user account using the command below:
1aelf-command create
You will receive the following wallet information:
1AElf [Info]: Your wallet info is :2AElf [Info]: Mnemonic : walnut market museum play grunt chuckle hybrid accuse relief misery share meadow3AElf [Info]: Private Key : 919a220fac2d80e674a256f2367ac840845f344269f4dcdd56d37460de17f9474AElf [Info]: Public Key : 04794948de40ffda2a6c884d7e6a99bb8e42b8b96b9ee5cc4545da3a1d5f7725eec93de62ddbfb598ef6f04fe52aa310acc7d17abeeea3946622573c4b0b2433ac5AElf [Info]: Address : ZBBPU7DMVQ72YBQNmaKTDPKaAkHNzzA3naH5B6kE7cBm8g1ei
Step 2: Transfer Tokens to the User Account#
After the user account is created successfully, we will first transfer some tokens to the account for voting.
Transfer Tokens:#
1aelf-command send AElf.ContractNames.Token Transfer '{"symbol": "ELF", "to": "ZBBPU7DMVQ72YBQNmaKTDPKaAkHNzzA3naH5B6kE7cBm8g1ei", "amount": "200000000000"}'
Confirm the Balance:#
1aelf-command call AElf.ContractNames.Token GetBalance '{"symbol": "ELF", "owner": "ZBBPU7DMVQ72YBQNmaKTDPKaAkHNzzA3naH5B6kE7cBm8g1ei"}'
Expected Result:#
1{2"symbol": "ELF",3"owner": "ZBBPU7DMVQ72YBQNmaKTDPKaAkHNzzA3naH5B6kE7cBm8g1ei",4"balance": "200000000000"5}
This confirms the user account has received the tokens.
Step 3: Vote for a Candidate Node#
Use the Election contract to vote for a candidate node. Here, we vote for the node with the public key 04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905.
Cast Vote:#
1aelf-command send AElf.ContractNames.Election Vote '{"candidatePubkey":"04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905","amount":2000000000,"endTimestamp":{"seconds":1600271999,"nanos":999000}}' -a ZBBPU7DMVQ72YBQNmaKTDPKaAkHNzzA3naH5B6kE7cBm8g1ei
Step 4: Verify the Vote#
Check the votes received by the candidate node to ensure your vote has been counted.
Check Candidate Votes:#
1aelf-command call AElf.ContractNames.Election GetCandidateVote '{"value":"04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905"}'
Expected Result:#
1{2"obtainedActiveVotingRecordIds": [3"172375e9cee303ce60361aa73d7326920706553e80f4485f97ffefdb904486f1"4],5"obtainedWithdrawnVotingRecordIds": [],6"obtainedActiveVotingRecords": [],7"obtainedWithdrawnVotesRecords": [],8"obtainedActiveVotedVotesAmount": "2000000000",9"allObtainedVotedVotesAmount": "2000000000",10"pubkey": "04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905"11}
This result confirms that the full node has successfully obtained 20 votes from the user account.
Become production node#
In the next election, the candidate nodes with the highest number of votes (up to 17) will automatically be elected as production nodes. You can view the current list of production nodes through the consensus contracts.
Viewing the Current Production Nodes#
To see the current list of production nodes, use the following command:
1aelf-command call AElf.ContractNames.Consensus GetCurrentMinerPubkeyList '{}'
Expected Result:#
1{2"pubkeys": [3"0499d3bb14337961c4d338b9729f46b20de8a49ed38e260a5c19a18da569462b44b820e206df8e848185dac6c139f05392c268effe915c147cde422e69514cc927",4"048397dfd9e1035fdd7260329d9492d88824f42917c156aef93fd7c2e3ab73b636f482b8ceb5cb435c556bfa067445a86e6f5c3b44ae6853c7f3dd7052609ed40b",5"041cc962a51e7bbdd829a8855eca8a03fda708fdf31969251321cb31edadd564bf3c6e7ab31b4c1f49f0f206be81dbe68a75c70b293bf9d04d867ee5e415d3bf8a",6"04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905"7]8}
In this example, the node with the public key 04eed00eb009ccd283798e3862781cebd25ed6a4641e0e1b7d0e3b6b59025040679fc4dc0edc9de166bd630c7255188a9aeadfc832fdae0828270f77c6ef267905 has been elected as a production node.
Add more production nodes#
To add more production nodes, follow these steps:
When the number of initial nodes and candidate nodes exceeds the maximum number of production nodes, the initial nodes will gradually be replaced by the newly elected production nodes. Note that once an initial node is replaced, it cannot run for election again. At this point, the initial node has completed its role in starting the AElf Blockchain.
Example Workflow:#
1aelf-command create
1aelf-command send AElf.ContractNames.Token Transfer '{"symbol": "ELF", "to": "<new_node_address>", "amount": "200000000000"}'
1aelf-command send AElf.ContractNames.Election AnnounceElection '{"value": "<new_node_address>"}' -a <new_node_address>
1aelf-command send AElf.ContractNames.Election Vote '{"candidatePubkey":"<new_node_pubkey>","amount":2000000000,"endTimestamp":{"seconds":<timestamp>,"nanos":999000}}' -a <user_address>
By following these steps, you can ensure a smooth transition from initial nodes to production nodes, maintaining the stability and performance of the AElf Blockchain.
Edited on: 15 July 2024 03:08:37 GMT+0