infinite gas cap for gas estimate (#1638)

This commit is contained in:
Alex Sharov 2021-03-31 11:03:52 +07:00 committed by GitHub
parent 2ba007b17c
commit 930b9ae37c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 27 deletions

View File

@ -8,6 +8,7 @@ import (
rpcfilters "github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/filters"
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/common/hexutil"
"github.com/ledgerwatch/turbo-geth/common/math"
"github.com/ledgerwatch/turbo-geth/core"
"github.com/ledgerwatch/turbo-geth/core/rawdb"
"github.com/ledgerwatch/turbo-geth/core/types"
@ -138,6 +139,10 @@ type APIImpl struct {
// NewEthAPI returns APIImpl instance
func NewEthAPI(db ethdb.RoKV, eth core.ApiBackend, gascap uint64, filters *rpcfilters.Filters, pending *rpchelper.Pending) *APIImpl {
if gascap == 0 {
gascap = uint64(math.MaxUint64 / 2)
}
return &APIImpl{
BaseAPI: &BaseAPI{},
db: db,

View File

@ -331,15 +331,12 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A
// CallArgs represents the arguments for a call.
type CallArgs struct {
From *common.Address `json:"from"`
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
Value *hexutil.Big `json:"value"`
// We accept "data" and "input" for backwards-compatibility reasons. "input" is the
// newer name and should be preferred by clients.
From *common.Address `json:"from"`
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
Value *hexutil.Big `json:"value"`
Data *hexutil.Bytes `json:"data"`
Input *hexutil.Bytes `json:"input"`
AccessList *types.AccessList `json:"accessList"`
}
@ -371,18 +368,16 @@ func (args *CallArgs) ToMessage(globalGasCap uint64) types.Message {
if args.Value != nil {
value.SetFromBig(args.Value.ToInt())
}
var data []byte
if args.Data != nil {
data = *args.Data
}
var accessList types.AccessList
if args.AccessList != nil {
accessList = *args.AccessList
}
var input []byte
if args.Input != nil {
input = *args.Input
} else if args.Data != nil {
input = *args.Data
}
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, input, accessList, false)
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, accessList, false)
return msg
}
@ -1029,18 +1024,6 @@ func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, ha
signer := types.MakeSigner(s.b.ChainConfig(), bigblock)
from, _ := types.Sender(signer, tx)
// Fill in the derived information in the logs
if receipt.Logs != nil {
for i, log := range receipt.Logs {
log.BlockNumber = blockNumber
log.TxHash = hash
log.TxIndex = uint(index)
log.BlockHash = blockHash
log.Index = uint(i)
}
}
// Now reconstruct the bloom filter
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
fields := map[string]interface{}{
"blockHash": blockHash,
"blockNumber": hexutil.Uint64(blockNumber),