From e92e68ee397845b3bd8dc5517d601fedc0498164 Mon Sep 17 00:00:00 2001 From: hadv Date: Thu, 20 Dec 2018 18:09:27 +0700 Subject: [PATCH 1/2] cmd/puppeth: fix panic error when export aleth genesis wo/ precompile-addresses --- cmd/puppeth/genesis.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/puppeth/genesis.go b/cmd/puppeth/genesis.go index 1025dfe826a..268b5c104cb 100644 --- a/cmd/puppeth/genesis.go +++ b/cmd/puppeth/genesis.go @@ -174,7 +174,11 @@ func (spec *alethGenesisSpec) setPrecompile(address byte, data *alethGenesisSpec if spec.Accounts == nil { spec.Accounts = make(map[common.UnprefixedAddress]*alethGenesisSpecAccount) } - spec.Accounts[common.UnprefixedAddress(common.BytesToAddress([]byte{address}))].Precompiled = data + a := common.UnprefixedAddress(common.BytesToAddress([]byte{address})) + if _, exist := spec.Accounts[a]; !exist { + spec.Accounts[a] = &alethGenesisSpecAccount{} + } + spec.Accounts[a].Precompiled = data } func (spec *alethGenesisSpec) setAccount(address common.Address, account core.GenesisAccount) { From 81e7e511359a12381e67e3086e1c49cf635a959c Mon Sep 17 00:00:00 2001 From: hadv Date: Thu, 3 Jan 2019 17:12:03 +0700 Subject: [PATCH 2/2] cmd/puppeth: don't need to handle duplicate set --- cmd/puppeth/genesis.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/puppeth/genesis.go b/cmd/puppeth/genesis.go index 268b5c104cb..c95c81a6dd4 100644 --- a/cmd/puppeth/genesis.go +++ b/cmd/puppeth/genesis.go @@ -174,11 +174,11 @@ func (spec *alethGenesisSpec) setPrecompile(address byte, data *alethGenesisSpec if spec.Accounts == nil { spec.Accounts = make(map[common.UnprefixedAddress]*alethGenesisSpecAccount) } - a := common.UnprefixedAddress(common.BytesToAddress([]byte{address})) - if _, exist := spec.Accounts[a]; !exist { - spec.Accounts[a] = &alethGenesisSpecAccount{} + addr := common.UnprefixedAddress(common.BytesToAddress([]byte{address})) + if _, exist := spec.Accounts[addr]; !exist { + spec.Accounts[addr] = &alethGenesisSpecAccount{} } - spec.Accounts[a].Precompiled = data + spec.Accounts[addr].Precompiled = data } func (spec *alethGenesisSpec) setAccount(address common.Address, account core.GenesisAccount) {