forked from cerc-io/plugeth
internal/ethapi: default to zero address for calls (#20702)
This makes eth_call and eth_estimateGas use the zero address as sender when the "from" parameter is not supplied. Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
2a5ed1a1d3
commit
fadf84a752
@ -764,17 +764,13 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
|
||||
if state == nil || err != nil {
|
||||
return nil, 0, false, err
|
||||
}
|
||||
// Set sender address or use a default if none specified
|
||||
|
||||
// Set sender address or use zero address if none specified.
|
||||
var addr common.Address
|
||||
if args.From == nil {
|
||||
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
|
||||
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
|
||||
addr = accounts[0].Address
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if args.From != nil {
|
||||
addr = *args.From
|
||||
}
|
||||
|
||||
// Override the fields of specified contracts before execution.
|
||||
for addr, account := range overrides {
|
||||
// Override account nonce.
|
||||
@ -906,17 +902,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
|
||||
}
|
||||
cap = hi
|
||||
|
||||
// Set sender address or use a default if none specified
|
||||
// Use zero address if sender unspecified.
|
||||
if args.From == nil {
|
||||
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
|
||||
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
|
||||
args.From = &accounts[0].Address
|
||||
}
|
||||
}
|
||||
}
|
||||
// Use zero-address if none other is available
|
||||
if args.From == nil {
|
||||
args.From = &common.Address{}
|
||||
args.From = new(common.Address)
|
||||
}
|
||||
// Create a helper to check if a gas allowance results in an executable transaction
|
||||
executable := func(gas uint64) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user