I deployed a private blockchain with the following steps:
- Setting the difficulty to a fixed value (see Running a “quick” Ethereum private network for experimentation and testing) and creating the genesis.json
- Creating the genesis block
geth --datadir ~/.geth init ~/.geth/genesis.json - Script
miningontransaction.jsfor mining only when there are pending transactions (see Mining until x confirmations have been achieved):miner.setEtherbase("0xac2c266b110979b162fbcbe994da5b1121b3e2ee"); var minimum_confirmations = 12; var mining_threads = 1 var txBlock = 0 function checkWork() { if (eth.getBlock("pending").transactions.length > 0) { txBlock = eth.getBlock("pending").number if (eth.mining) return; console.log("Transactions pending. Mining..."); miner.start(mining_threads) while (eth.getBlock("latest").number < txBlock + 12) { if (eth.getBlock("pending").transactions.length > 0) txBlock = eth.getBlock("pending").number; } console.log("12 confirmations achieved; mining stopped."); miner.stop() } else { miner.stop() } } eth.filter("latest", function(err, block) { checkWork(); }); eth.filter("pending", function(err, block) { checkWork(); }); checkWork(); - Starting one node
geth \ --verbosity 3 \ --datadir $HOME/.geth \ --nodiscover \ --syncmode "full" \ --gcmode "archive" \ --cache 2659 \ --port 30300 \ --ws \ --wsaddr "0.0.0.0" \ --wsport 8006 \ --wsapi "personal,db,eth,net,web3,txpool,miner" \ --wsorigins "*" \ --rpc \ --rpcaddr "0.0.0.0" \ --rpcport 8005 \ --rpcapi "personal,db,eth,net,web3,txpool,miner" \ --rpcvhosts "*" \ --rpccorsdomain "*" \ --networkid 14562 \ --preload "$HOME/miningontransaction.js" \ console
Sometimes (completely irregularly) the node stops with the following on the console:
ERROR[08-13|01:20:01.160] Failed to reset txpool state err="missing trie node 0ebb4a8b33e7945d2bfdf2b5e7c487bdd302e4b40a010389606657cca6132301 (path )"
ERROR[08-13|01:20:03.161] Failed to create mining context err="missing trie node 0ebb4a8b33e7945d2bfdf2b5e7c487bdd302e4b40a010389606657cca6132301 (path )"
After restarting the node (step 4), the node runs perfectly again. What am I missing?
missing trie nodemeans you are accessing account balances of very old blocks. If you want to have account balance history then sync in archive mode – Nulik Aug 13 '18 at 18:43