-
Couldn't load subscription status.
- Fork 934
core/types: Populate Jovian receipt fields #710
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
base: optimism
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| package types | ||||||
|
|
||||||
| import ( | ||||||
| "fmt" | ||||||
|
|
||||||
| "github.com/ethereum/go-ethereum/params" | ||||||
| ) | ||||||
|
|
||||||
| // deriveOPStackFields derives the OP Stack specific fields for each receipt. | ||||||
| // It must only be called for blocks with at least two transactions. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: it will still work even if there is only the system deposit transaction right?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the system deposit (l1 attribs) tx would be skipped below because of the I'm generally unsure about this requirement, it does match the condition in the calling function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It would panic since we read There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah completely empty tx slice would be problematic, but shouldn't happen on an optimism chain, so the tx length check in the caller seems redundant to me still. Doesn't need to block this PR since I think it preserves original semantics, but I would like to either understand this better or circle back and change it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The genesis block might be an edge case. |
||||||
| func (rs Receipts) deriveOPStackFields(config *params.ChainConfig, blockTime uint64, txs []*Transaction) error { | ||||||
| l1AttributesData := txs[0].Data() | ||||||
| gasParams, err := extractL1GasParams(config, blockTime, l1AttributesData) | ||||||
| if err != nil { | ||||||
| return fmt.Errorf("failed to extract L1 gas params: %w", err) | ||||||
| } | ||||||
|
|
||||||
| var daFootprintGasScalar uint64 | ||||||
| if config.IsJovian(blockTime) { | ||||||
| scalar, err := ExtractDAFootprintGasScalar(l1AttributesData) | ||||||
| if err != nil { | ||||||
| return fmt.Errorf("failed to extract DA footprint gas scalar: %w", err) | ||||||
| } | ||||||
| daFootprintGasScalar = uint64(scalar) | ||||||
| } | ||||||
|
|
||||||
| for i := range rs { | ||||||
| if txs[i].IsDepositTx() { | ||||||
| continue | ||||||
| } | ||||||
| rs[i].L1GasPrice = gasParams.l1BaseFee | ||||||
| rs[i].L1BlobBaseFee = gasParams.l1BlobBaseFee | ||||||
| rcd := txs[i].RollupCostData() | ||||||
| rs[i].L1Fee, rs[i].L1GasUsed = gasParams.costFunc(rcd) | ||||||
| rs[i].FeeScalar = gasParams.feeScalar | ||||||
| rs[i].L1BaseFeeScalar = u32ptrTou64ptr(gasParams.l1BaseFeeScalar) | ||||||
| rs[i].L1BlobBaseFeeScalar = u32ptrTou64ptr(gasParams.l1BlobBaseFeeScalar) | ||||||
| if gasParams.operatorFeeScalar != nil && gasParams.operatorFeeConstant != nil && (*gasParams.operatorFeeScalar != 0 || *gasParams.operatorFeeConstant != 0) { | ||||||
| rs[i].OperatorFeeScalar = u32ptrTou64ptr(gasParams.operatorFeeScalar) | ||||||
| rs[i].OperatorFeeConstant = gasParams.operatorFeeConstant | ||||||
| } | ||||||
| if config.IsJovian(blockTime) { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can have |
||||||
| rs[i].DAFootprintGasScalar = &daFootprintGasScalar | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a tad wasteful to include the scalar (a block-level attribute) in every receipt when it can be statically inferred from the I see we include other block-level attributes like the Any thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noting also that we should specify whatever behaviour we want to enshrine in the specs, as was done here https://specs.optimism.io/protocol/isthmus/exec-engine.html#receipts. |
||||||
| rs[i].BlobGasUsed = daFootprintGasScalar * rcd.EstimatedDASize().Uint64() | ||||||
| } | ||||||
| } | ||||||
| return nil | ||||||
| } | ||||||
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.
Condition changed: we still need the
config.Optimism != nil, correct? Suggesting we leave the condition unchanged since it doesn't seem to have an impact on this PR.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 think the condition is equivalent because of this:
op-geth/params/config.go
Lines 907 to 910 in 96738d2