Skip to content
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

add support for blob tx #2

Merged
merged 12 commits into from
Jul 11, 2024

Conversation

blockchaindevsh
Copy link
Collaborator

@blockchaindevsh blockchaindevsh commented Apr 9, 2024

Summary of this PR:

  1. allow l2 blob tx if enablel2blob is specified.
  2. add blobs field to RollupCostData, and update newL1CostFuncEcotone accordingly, basically a blob tx will have two extra fees: da fee and da proof fee.
  3. fix Transaction.RollupCostData so that the result is consistent when called from worker and state processor.
  4. port changes from upstream geth to support estimate gas for blob tx.

@@ -69,7 +69,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
if tx.Type() == types.DepositTxType {
return core.ErrTxTypeNotSupported
}
if opts.Config.IsOptimism() && tx.Type() == types.BlobTxType {
if false && opts.Config.IsOptimism() && tx.Type() == types.BlobTxType {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be put a flag to enable L2 blob rather than false/true (blow)?

Copy link
Collaborator Author

@blockchaindevsh blockchaindevsh Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, the flag is named enablel2blob.

… otherwise the result will be different when called from state processor

  2. l2 blob tx will have two extra fees for L1CostFunc: da fee and da proof fee
  3. only check versionedHashes when it's not nil
Copy link

@qizhou qizhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the description of the PR should be updated.

@@ -378,7 +378,7 @@ func (tx *Transaction) RollupCostData() RollupCostData {
if v := tx.rollupCostData.Load(); v != nil {
return v.(RollupCostData)
}
data, err := tx.MarshalBinary()
data, err := tx.WithoutBlobTxSidecar().MarshalBinary()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a few comments about why use non BLOB (but with BLOB hash) version of tx.

Another question is in which case the tx will contain the BLOB (as the derivation stage, we cannot derive the BLOB from L1).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated with some comments.

@@ -167,6 +167,8 @@ type Config struct {

OverrideOptimismInterop *uint64 `toml:",omitempty"`

EnableL2Blob bool
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a few comments of like "Enable accepting EIP-4844 BLOBs on L2"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -47,6 +47,9 @@ const (
LogDataGas uint64 = 8 // Per byte in a LOG* operation's data.
CallStipend uint64 = 2300 // Free gas given at beginning of call.

BlobDAFee = 2000
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are needed here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if msg.AccessList != nil {
arg["accessList"] = msg.AccessList
}
if msg.BlobGasFeeCap != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this parameter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used here, so that a blob tx will not be included if the specified blob gas fee cap is smaller than BlobBaseFee of current block.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Geth v1.13.13 supported it on Feb 21, and op-geth has not merged it...

Copy link
Collaborator Author

@blockchaindevsh blockchaindevsh Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems I mis-understood Qi's question.

Here's more context about this change:ethereum-optimism#299

@blockchaindevsh
Copy link
Collaborator Author

I feel the description of the PR should be updated.

Done.

@@ -213,6 +214,7 @@ func newL1CostFuncEcotone(l1BaseFee, l1BlobBaseFee, l1BaseFeeScalar, l1BlobBaseF
fee = new(big.Int).Add(calldataCostPerByte, blobCostPerByte)
fee = fee.Mul(fee, calldataGasUsed)
fee = fee.Div(fee, ecotoneDivisor)
fee = fee.Add(fee, big.NewInt(int64(costData.blobs*params.BlobDAFee)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to deal with integer overflow case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed!

@@ -47,6 +47,9 @@ const (
LogDataGas uint64 = 8 // Per byte in a LOG* operation's data.
CallStipend uint64 = 2300 // Free gas given at beginning of call.

BlobDAFee = 2000 // Fee for storing blob to DA provider
BlobDAProofGas = 200 // Gas for storing DA proof to span batch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a comment It should be average proof size * TxDataNonZeroGasEIP2028

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@@ -194,6 +194,8 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
cfg.Eth.OverrideVerkle = &v
}

cfg.Eth.EnableL2Blob = ctx.Bool(utils.EnableL2Blob.Name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check ctx.IsSet()?

Copy link
Collaborator Author

@blockchaindevsh blockchaindevsh Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think their effects are the same here.

if msg.AccessList != nil {
arg["accessList"] = msg.AccessList
}
if msg.BlobGasFeeCap != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Geth v1.13.13 supported it on Feb 21, and op-geth has not merged it...

@blockchaindevsh blockchaindevsh merged commit 93729e7 into ethstorage:op-es Jul 11, 2024
qizhou pushed a commit that referenced this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants