-
Notifications
You must be signed in to change notification settings - Fork 21.1k
core, internal, miner, signer: convert legacy sidecar in Osaka fork #32347
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: master
Are you sure you want to change the base?
Changes from all commits
d75e28e
76e3a36
38d1d12
b4bf2ae
3e4ed1c
1a887a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ import ( | |
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/consensus/misc/eip4844" | ||
"github.com/ethereum/go-ethereum/core" | ||
"github.com/ethereum/go-ethereum/core/state" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
|
@@ -167,9 +166,8 @@ func validateBlobTx(tx *types.Transaction, head *types.Header, opts *ValidationO | |
if len(hashes) == 0 { | ||
return errors.New("blobless blob transaction") | ||
} | ||
maxBlobs := eip4844.MaxBlobsPerBlock(opts.Config, head.Time) | ||
if len(hashes) > maxBlobs { | ||
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), maxBlobs) | ||
if len(hashes) > params.BlobTxMaxBlobs { | ||
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.BlobTxMaxBlobs) | ||
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. What was the purpose of this change? I think you need to use the config to determine the correct max number of blobs? 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, it's a very good question. Originally, we cap the number of blobs within a single tx by Then the PeerDAS EIP introduces this notion, that the blobs in a tx is capped at 6, constantly.
So the original check is no longer meaningful, at least after the PeerDAS EIP. In theory, we should apply the restriction respectively:
In the txpool, we can just blindly unify the restriction by this constant threshold, it won't hurt too much before the Osaka fork. Please let me know if this workaround makes sense or not. |
||
} | ||
if len(sidecar.Blobs) != len(hashes) { | ||
return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(sidecar.Blobs), len(hashes)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1479,6 +1479,8 @@ func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (c | |
|
||
// SendTransaction creates a transaction for the given argument, sign it and submit it to the | ||
// transaction pool. | ||
// | ||
// This API is not capable for submitting blob transaction with sidecar. | ||
func (api *TransactionAPI) SendTransaction(ctx context.Context, args TransactionArgs) (common.Hash, error) { | ||
// Look up the wallet containing the requested signer | ||
account := accounts.Account{Address: args.from()} | ||
|
@@ -1499,7 +1501,7 @@ func (api *TransactionAPI) SendTransaction(ctx context.Context, args Transaction | |
} | ||
|
||
// Set some sanity defaults and terminate on failure | ||
if err := args.setDefaults(ctx, api.b, false); err != nil { | ||
if err := args.setDefaults(ctx, api.b, sidecarConfig{}); err != nil { | ||
return common.Hash{}, err | ||
} | ||
// Assemble the transaction and sign with the wallet | ||
|
@@ -1516,10 +1518,19 @@ func (api *TransactionAPI) SendTransaction(ctx context.Context, args Transaction | |
// on a given unsigned transaction, and returns it to the caller for further | ||
// processing (signing + broadcast). | ||
func (api *TransactionAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { | ||
args.blobSidecarAllowed = true | ||
|
||
// Set some sanity defaults and terminate on failure | ||
if err := args.setDefaults(ctx, api.b, false); err != nil { | ||
sidecarVersion := types.BlobSidecarVersion0 | ||
if len(args.Blobs) > 0 { | ||
h := api.b.CurrentHeader() | ||
if api.b.ChainConfig().IsOsaka(h.Number, h.Time) { | ||
sidecarVersion = types.BlobSidecarVersion1 | ||
} | ||
} | ||
config := sidecarConfig{ | ||
blobSidecarAllowed: true, | ||
blobSidecarVersion: sidecarVersion, | ||
} | ||
if err := args.setDefaults(ctx, api.b, config); err != nil { | ||
return nil, err | ||
} | ||
// Assemble the transaction and obtain rlp | ||
|
@@ -1576,8 +1587,6 @@ type SignTransactionResult struct { | |
// The node needs to have the private key of the account corresponding with | ||
// the given from address and it needs to be unlocked. | ||
func (api *TransactionAPI) SignTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { | ||
args.blobSidecarAllowed = true | ||
|
||
if args.Gas == nil { | ||
return nil, errors.New("gas not specified") | ||
} | ||
|
@@ -1587,7 +1596,19 @@ func (api *TransactionAPI) SignTransaction(ctx context.Context, args Transaction | |
if args.Nonce == nil { | ||
return nil, errors.New("nonce not specified") | ||
} | ||
if err := args.setDefaults(ctx, api.b, false); err != nil { | ||
sidecarVersion := types.BlobSidecarVersion0 | ||
if len(args.Blobs) > 0 { | ||
h := api.b.CurrentHeader() | ||
if api.b.ChainConfig().IsOsaka(h.Number, h.Time) { | ||
sidecarVersion = types.BlobSidecarVersion1 | ||
} | ||
} | ||
|
||
config := sidecarConfig{ | ||
blobSidecarAllowed: true, | ||
blobSidecarVersion: sidecarVersion, | ||
} | ||
if err := args.setDefaults(ctx, api.b, config); err != nil { | ||
return nil, err | ||
} | ||
// Before actually sign the transaction, ensure the transaction fee is reasonable. | ||
|
@@ -1603,7 +1624,7 @@ func (api *TransactionAPI) SignTransaction(ctx context.Context, args Transaction | |
// no longer retains the blobs, only the blob hashes. In this step, we need | ||
// to put back the blob(s). | ||
if args.IsEIP4844() { | ||
signed = signed.WithBlobTxSidecar(types.NewBlobTxSidecar(types.BlobSidecarVersion0, args.Blobs, args.Commitments, args.Proofs)) | ||
signed = signed.WithBlobTxSidecar(types.NewBlobTxSidecar(sidecarVersion, args.Blobs, args.Commitments, args.Proofs)) | ||
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. Note, the legacy proofs submitted by users will be implicitly converted to cell proofs. |
||
} | ||
data, err := signed.MarshalBinary() | ||
if err != nil { | ||
|
@@ -1638,11 +1659,13 @@ func (api *TransactionAPI) PendingTransactions() ([]*RPCTransaction, error) { | |
|
||
// Resend accepts an existing transaction and a new gas price and limit. It will remove | ||
// the given transaction from the pool and reinsert it with the new gas price and limit. | ||
// | ||
// This API is not capable for submitting blob transaction with sidecar. | ||
func (api *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { | ||
if sendArgs.Nonce == nil { | ||
return common.Hash{}, errors.New("missing transaction nonce in transaction spec") | ||
} | ||
if err := sendArgs.setDefaults(ctx, api.b, false); err != nil { | ||
if err := sendArgs.setDefaults(ctx, api.b, sidecarConfig{}); err != nil { | ||
return common.Hash{}, err | ||
} | ||
matchTx := sendArgs.ToTransaction(types.LegacyTxType) | ||
|
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.
One part is still missing:
During the Osaka activation, we should somehow convert the legacy sidecars to new format. It should be done in a following PR.