Skip to content

Commit

Permalink
fix missing private key for the hardcoded DevnetEtherbase
Browse files Browse the repository at this point in the history
* do not panic if SigKey is not found
* save hardcoded DevnetEtherbase/DevnetSignPrivateKey into accounts so that SigKey can recover it
  • Loading branch information
battlmonstr committed Oct 26, 2023
1 parent b642fde commit 1abead2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cmd/devnet/accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ func init() {
core.DevnetSignKey = func(addr libcommon.Address) *ecdsa.PrivateKey {
return SigKey(addr)
}

devnetEtherbaseAccount := &Account{
"DevnetEtherbase",
core.DevnetEtherbase,
core.DevnetSignPrivateKey,
}
accountsByAddress[core.DevnetEtherbase] = devnetEtherbaseAccount
accountsByName[devnetEtherbaseAccount.Name] = devnetEtherbaseAccount
}

var accountsByAddress = map[libcommon.Address]*Account{}
Expand Down
7 changes: 6 additions & 1 deletion cmd/devnet/transactions/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,12 @@ func signEIP1559TxsHigherThanBaseFee(ctx context.Context, n int, baseFeePerGas u

devnet.Logger(ctx).Info("HIGHER", "transaction", i, "nonce", transaction.Nonce, "value", transaction.Value, "feecap", transaction.FeeCap)

signedTransaction, err := types.SignTx(transaction, signer, accounts.SigKey(fromAddress))
signerKey := accounts.SigKey(fromAddress)
if signerKey == nil {
return nil, fmt.Errorf("devnet.signEIP1559TxsHigherThanBaseFee failed to SignTx: private key not found for address %s", fromAddress)
}

signedTransaction, err := types.SignTx(transaction, signer, signerKey)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1abead2

Please sign in to comment.