-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Changes from 4 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 |
---|---|---|
|
@@ -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 { | ||
config := sidecarConfig{ | ||
blobSidecarAllowed: true, | ||
blobSidecarVersion: types.BlobSidecarVersion0, | ||
} | ||
if len(args.Blobs) > 0 { | ||
chainHead := api.b.CurrentHeader() | ||
isOsaka := api.b.ChainConfig().IsOsaka(chainHead.Number, chainHead.Time) | ||
if isOsaka { | ||
config.blobSidecarVersion = types.BlobSidecarVersion1 | ||
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. |
||
} | ||
} | ||
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,20 @@ 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 { | ||
chainHead := api.b.CurrentHeader() | ||
isOsaka := api.b.ChainConfig().IsOsaka(chainHead.Number, chainHead.Time) | ||
if isOsaka { | ||
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 +1625,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 +1660,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.