-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handle l1 rpc error #854
base: l1sload
Are you sure you want to change the base?
Conversation
638193a
to
d3adddf
Compare
6be1f88
to
712fd3b
Compare
5d042e2
to
edeb6d9
Compare
@@ -1179,6 +1181,9 @@ func (c *l1sload) RequiredGas(input []byte) uint64 { | |||
} | |||
|
|||
func (c *l1sload) Run(state StateDB, input []byte) ([]byte, error) { | |||
log.Info("l1sload", "input", input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info("l1sload", "input", input) | |
log.Debug("l1sload", "input", input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional to set log.Info
here? btw, can print block number here for easier searching of the specific tx containing l1sload in other tools like scrollscan.
} | ||
// wait before retrying | ||
time.Sleep(100 * time.Millisecond) | ||
log.Warn("L1 client request error", "err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can add address
, keys
, block
in the log for easier debugging. e.g. if one needs to replay the rpc failure by sending through json rpc.
for i := 0; i < l1ClientMaxRetries; i++ { | ||
res, err := c.l1Client.StoragesAt(context.Background(), address, keys, block) | ||
if err != nil { | ||
innerErr = err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about printing the number of i-th
tries, address
, keys
, block
and error messages
here? because during the middle of the for-loop, the error will be simply omitted, it's not worse recording them somehow at first.
res, err := c.l1Client.StoragesAt(context.Background(), address, keys, block) | ||
if err != nil { | ||
return nil, &ErrL1RPCError{err: err} | ||
// if caller type is non-worker then we can retry request multiple times and return err, the tx will be reinserted in tx poll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if caller type is non-worker then we can retry request multiple times and return err, the tx will be reinserted in tx poll | |
// if caller type is worker then we can retry request multiple times and return err, the tx will be reinserted in tx poll |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and use if c.callerType == CallerTypeWorker
first to align with this comment.
return res, nil | ||
} | ||
// wait before retrying | ||
time.Sleep(100 * time.Millisecond) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do exponential backoff?
} | ||
// wait before retrying | ||
time.Sleep(100 * time.Millisecond) | ||
log.Warn("L1 client request error", "err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Warn("L1 client request error", "err", err) | |
log.Warn("failed to perform L1Sload RPC call", "err", err) |
} else { | ||
var innerErr error | ||
for i := 0; i < l1ClientMaxRetries; i++ { | ||
res, err := c.l1Client.StoragesAt(context.Background(), address, keys, block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this call have a built-in timeout mechanism? Or is it possible that it would hang indefinitely?
@@ -1168,6 +1174,12 @@ loop: | |||
log.Trace("Skipping account with hight nonce", "sender", from, "nonce", tx.Nonce()) | |||
txs.Pop() | |||
|
|||
case errors.As(err, &errL1): | |||
// Skip the current transaction failed on L1Sload precompile with L1RpcError without shifting in the next from the account, this tx will be left in txpool and retried in future block | |||
log.Trace("Skipping transaction failed on L1Sload precompile with L1RpcError", "sender", from) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log error
case errors.As(err, &errL1): | ||
// Skip the current transaction failed on L1Sload precompile with L1RpcError without shifting in the next from the account, this tx will be left in txpool and retried in future block | ||
log.Trace("Skipping transaction failed on L1Sload precompile with L1RpcError", "sender", from) | ||
atomic.AddInt32(&w.newTxs, int32(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
1. Purpose or design rationale of this PR
Handle Rpc Error as documented here https://hackmd.io/@haichen/l1sload#Errors
Do not treat
L1RpcError
as an execution error, but instead retry the request and not remove tx from TxPool2. PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
3. Deployment tag versioning
Has the version in
params/version.go
been updated?4. Breaking change label
Does this PR have the
breaking-change
label?