Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const UnHealthyTimeout = 5 * time.Second
// allowed to produce in order to speed up calculations.
const estimateGasErrorRatio = 0.015

// maxGetProofKeys is the maximum number of storage keys that can be
// requested in a single eth_getProof call.
const maxGetProofKeys = 1024

var errBlobTxNotSupported = errors.New("signing blob transactions not supported")
var errSubClosed = errors.New("chain subscription closed")

Expand Down Expand Up @@ -374,6 +378,9 @@ func (n *proofList) Delete(key []byte) error {

// GetProof returns the Merkle-proof for a given account and optionally some storage keys.
func (api *BlockChainAPI) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error) {
if len(storageKeys) > maxGetProofKeys {
return nil, &invalidParamsError{fmt.Sprintf("too many storage keys requested (max %d, got %d)", maxGetProofKeys, len(storageKeys))}
}
var (
keys = make([]common.Hash, len(storageKeys))
keyLengths = make([]int, len(storageKeys))
Expand Down Expand Up @@ -406,6 +413,9 @@ func (api *BlockChainAPI) GetProof(ctx context.Context, address common.Address,
}
// Create the proofs for the storageKeys.
for i, key := range keys {
if err := ctx.Err(); err != nil {
return nil, err
}
// Output key encoding is a bit special: if the input was a 32-byte hash, it is
// returned as such. Otherwise, we apply the QUANTITY encoding mandated by the
// JSON-RPC spec for getProof. This behavior exists to preserve backwards
Expand Down
Loading