Skip to content
Snippets Groups Projects
Commit c92436a6 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Simplified genesis creation to allow just a single node. Additional nodes are to be proposed.

parent 71100ee8
No related branches found
No related tags found
No related merge requests found
......@@ -200,53 +200,50 @@ function prereq
test $err -eq 0
}
function repeat
{
printf -- "$2%0.s" $( seq 1 $1 )
}
function gen_genesis
{
local genesis="${BFAHOME}/src/genesis.json"
test -e "${genesis}" &&
return
SECONDS=$( date +%s )
bfaconfig account
nodes=$account
#echo "** If you want extra nodes added, add them to nodes.remote.txt and run $0 again."
test -r "nodes.remote.txt" &&
nodes="${nodes} $( cat nodes.remote.txt )"
allocs=
sealers=
for node in ${nodes}
do
test "${node:0:2}" = "0x" &&
node=${node:2}
allocs="${allocs}"$(
printf ', "%s": { "balance": "%s" }' \
$node \
0x200000000000000000000000000000000000000000000000000000000000000
)
sealers="${sealers}${node}"
done
# Get rid of leading comma-space
allocs="${allocs:2}"
local zero4="0000"
local zero8="${zero4}${zero4}"
local zero16="${zero8}${zero8}"
local zero20="${zero16}${zero4}"
local zero32="${zero16}${zero16}"
local zero40="${zero20}${zero20}"
local zero60="${zero40}${zero20}"
local zero64="${zero32}${zero32}"
local zero128="${zero64}${zero64}"
local zero130="${zero128}00"
local nodes=$account
local timestamp=$( printf '0x%08x' $( date +%s ) )
local vanity_Blockchain="426c6f636b636861696e"
local vanity_Federal="4665646572616c"
local vanity_Argentina="417267656e74696e61"
local vanity_NIC="4e4943"
local vanity="${vanity_Blockchain}20${vanity_Federal}20${vanity_Argentina}20${vanity_NIC}"
## Make sure vanity is exactly 64 characters
vanity="${vanity}${zero64}"
vanity="${vanity:0:64}"
echo -n "$vanity" | grep -Evq '[^0-9a-fA-F]'
cat <<-EOCONF > ${genesis}
{
"config": {
"chainId": ${BFANETWORKID},
"homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 4,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip150Hash": "0x${zero64}",
"clique": { "period": 15, "epoch": 30000 }
},
"nonce": "0x0000000000000000",
"timestamp": "$( printf '0x%08x' $SECONDS )",
"extraData": "0x426c6f636b636861696e204665646572616c20417267656e74696e61204e4943${sealers}$( repeat 130 0 )",
"gasLimit": "0xffeeddcc", "difficulty": "0x1", "number": "0x0", "gasUsed": "0x0",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"alloc": { $allocs }
"timestamp": "${timestamp}",
"extraData": "0x${vanity}${account}${zero130}",
"gasUsed": "0x0", "gasLimit": "0xffeeddcc", "difficulty": "0x1",
"number": "0x0",
"mixHash": "0x${zero64}",
"coinbase": "0x${zero40}",
"parentHash": "0x${zero64}",
"alloc": { "${account}": { "balance": "0x200${zero60}" } }
}
EOCONF
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment