-
Notifications
You must be signed in to change notification settings - Fork 6
Add blob length errors for engine api and transition tool. #125
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
Conversation
core/state_transition.go
Outdated
| if err != nil { | ||
| return msg, err | ||
| } | ||
| numBlobsTx := len(tx.DataHashes()) |
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.
Seems a little odd to do validation checks on # of blobs here when there are no other validation checks being performed. what makes blobs validation special enough to be an exception here?
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.
I don't disagree here, maybe there is somewhere else it can be added?
I initially wanted to add the check here only for 0 blobs: https://github.com/mdehoog/go-ethereum/blob/eip-4844/cmd/evm/internal/t8ntool/execution.go#L179, as the t8n-tool should return the rejected txs for erroneous # blobs.
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 there are too many blobs then state transition should already fail with "data gas limit reached".
I see some tx validity checks performed here:
| func Transaction(ctx *cli.Context) error { |
Would checking for 0 blobs there work?
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.
I'll omit the > max blobs check :D
If we have the check there the t8n-tool fails which means that we can't generate the erroneous fixtures. What about something like this:
if chainConfig.IsCancun(pre.Env.Timestamp) && tx.Type() == types.BlobTxType && len(tx.DataHashes()) == 0 {
err := fmt.Errorf("blob transaction with zero blobs")
log.Warn("rejected tx", "index", i, "hash", tx.Hash(), "error", err)
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
continue
}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.
After some more thought this seems more appropriate: check for zero data gas if in Cancun here: core/state_transition.go#L240
if dataGasUsed == 0 {
return fmt.Errorf("%w: cancun is active but DataGasUsed is 0. .....Context.Time)
}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 we want to check for 0 blobs & error out in state_transition, then I think the more explicit check looking at dataHashes len is more clear. Also datagasused == 0 is going to be expected for non-blob txs.
If this validity check should be performed in state transition then I guess the current check is as good as any. Is state_transition supposed to catch any invalid tx? I'd always assumed basic tx validity checking was done before we got to this point and therefore doing it at this point would be redundant.
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.
Maybe @Inphi has more insight into this.
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.
I'm not keen on redundant checks in state transition either. Though it looks like this issue has been addressed.
Inphi
left a comment
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.
LGTM. I do think we need to assert non-zero blobs/versionedHash in areas where a blob transaction may be imported directly without the blob itself (maybe by the CL). We're still figuring out how that should work (or if it's even desirable). So for now I'm OK with having zero-blob checks in ExecutableDataToBlock.
Adds errors for the blob length within transition tool and engine api. This lets us generate the expected
execution-spec-testsfixtures, and return the appropriateINVALIDpayload status when running the fixtures inhive.