Skip to content

Commit 3f421ac

Browse files
hadvkaralabe
authored andcommitted
cmd/puppeth: fix panic error when export aleth genesis wo/ precompile-addresses (#18344)
* cmd/puppeth: fix panic error when export aleth genesis wo/ precompile-addresses * cmd/puppeth: don't need to handle duplicate set
1 parent 4997526 commit 3f421ac

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎cmd/puppeth/genesis.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ func (spec *alethGenesisSpec) setPrecompile(address byte, data *alethGenesisSpec
174174
if spec.Accounts == nil {
175175
spec.Accounts = make(map[common.UnprefixedAddress]*alethGenesisSpecAccount)
176176
}
177-
spec.Accounts[common.UnprefixedAddress(common.BytesToAddress([]byte{address}))].Precompiled = data
177+
addr := common.UnprefixedAddress(common.BytesToAddress([]byte{address}))
178+
if _, exist := spec.Accounts[addr]; !exist {
179+
spec.Accounts[addr] = &alethGenesisSpecAccount{}
180+
}
181+
spec.Accounts[addr].Precompiled = data
178182
}
179183

180184
func (spec *alethGenesisSpec) setAccount(address common.Address, account core.GenesisAccount) {

0 commit comments

Comments
 (0)