Merge pull request #223 from cerc-io/ian/no_writeStateDiffAt_forward

Remove problematic `eth_writeStateDiffAt` calls
This commit is contained in:
Ian Norden 2023-01-10 18:25:01 -06:00 committed by GitHub
commit 618d2afaac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -707,7 +707,6 @@ func (pea *PublicEthAPI) GetBalance(ctx context.Context, address common.Address,
if pea.proxyOnError { if pea.proxyOnError {
var res *hexutil.Big var res *hexutil.Big
if err := pea.rpc.CallContext(ctx, &res, "eth_getBalance", address, blockNrOrHash); res != nil && err == nil { if err := pea.rpc.CallContext(ctx, &res, "eth_getBalance", address, blockNrOrHash); res != nil && err == nil {
go pea.writeStateDiffAtOrFor(blockNrOrHash)
return res, nil return res, nil
} }
} }
@ -755,8 +754,6 @@ func (pea *PublicEthAPI) GetStorageAt(ctx context.Context, address common.Addres
logrus.Warnf("Missing eth_getStorageAt(%s, %s, %s)", address.Hash().String(), key, blockNrOrHash.String()) logrus.Warnf("Missing eth_getStorageAt(%s, %s, %s)", address.Hash().String(), key, blockNrOrHash.String())
var res hexutil.Bytes var res hexutil.Bytes
if err := pea.rpc.CallContext(ctx, &res, "eth_getStorageAt", address, key, blockNrOrHash); res != nil && err == nil { if err := pea.rpc.CallContext(ctx, &res, "eth_getStorageAt", address, key, blockNrOrHash); res != nil && err == nil {
// If only proxying on error, request statediffing for the missing data.
go pea.writeStateDiffAtOrFor(blockNrOrHash)
return res, nil return res, nil
} }
} }
@ -775,7 +772,6 @@ func (pea *PublicEthAPI) GetCode(ctx context.Context, address common.Address, bl
if pea.proxyOnError { if pea.proxyOnError {
var res hexutil.Bytes var res hexutil.Bytes
if err := pea.rpc.CallContext(ctx, &res, "eth_getCode", address, blockNrOrHash); res != nil && err == nil { if err := pea.rpc.CallContext(ctx, &res, "eth_getCode", address, blockNrOrHash); res != nil && err == nil {
go pea.writeStateDiffAtOrFor(blockNrOrHash)
return res, nil return res, nil
} }
} }
@ -795,7 +791,6 @@ func (pea *PublicEthAPI) GetProof(ctx context.Context, address common.Address, s
if pea.proxyOnError { if pea.proxyOnError {
var res *AccountResult var res *AccountResult
if err := pea.rpc.CallContext(ctx, &res, "eth_getProof", address, storageKeys, blockNrOrHash); res != nil && err == nil { if err := pea.rpc.CallContext(ctx, &res, "eth_getProof", address, storageKeys, blockNrOrHash); res != nil && err == nil {
go pea.writeStateDiffAtOrFor(blockNrOrHash)
return res, nil return res, nil
} }
} }
@ -965,7 +960,6 @@ func (pea *PublicEthAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash
if err != nil && pea.proxyOnError { if err != nil && pea.proxyOnError {
var hex hexutil.Bytes var hex hexutil.Bytes
if err := pea.rpc.CallContext(ctx, &hex, "eth_call", args, blockNrOrHash, overrides); hex != nil && err == nil { if err := pea.rpc.CallContext(ctx, &hex, "eth_call", args, blockNrOrHash, overrides); hex != nil && err == nil {
go pea.writeStateDiffAtOrFor(blockNrOrHash)
return hex, nil return hex, nil
} }
} }
@ -1056,25 +1050,10 @@ func (pea *PublicEthAPI) writeStateDiffAtOrFor(blockNrOrHash rpc.BlockNumberOrHa
// writeStateDiffWithCriteria calls out to the proxy statediffing geth client to fill in a gap in the index // writeStateDiffWithCriteria calls out to the proxy statediffing geth client to fill in a gap in the index
func (pea *PublicEthAPI) writeStateDiffWithCriteria(crit filters.FilterCriteria) { func (pea *PublicEthAPI) writeStateDiffWithCriteria(crit filters.FilterCriteria) {
// short circuit right away if the proxy doesn't support diffing // short circuit right away if the proxy doesn't support diffing
if !pea.supportsStateDiff { if !pea.supportsStateDiff || crit.BlockHash == nil {
return return
} }
if crit.BlockHash != nil { pea.writeStateDiffFor(*crit.BlockHash)
pea.writeStateDiffFor(*crit.BlockHash)
return
}
var start, end int64
if crit.FromBlock != nil {
start = crit.FromBlock.Int64()
}
if crit.ToBlock != nil {
end = crit.ToBlock.Int64()
} else {
end = start
}
for i := start; i <= end; i++ {
pea.writeStateDiffAt(i)
}
} }
// writeStateDiffAt calls out to the proxy statediffing geth client to fill in a gap in the index // writeStateDiffAt calls out to the proxy statediffing geth client to fill in a gap in the index