-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d75e28e
core, internal, miner, signer: convert legacy sidecar in Osaka fork
rjl493456442 76e3a36
core/txpool/blobpool: add test
rjl493456442 38d1d12
internal/ethapi: minor cleanups
MariusVanDerWijden b4bf2ae
internal/ethapi: comment
MariusVanDerWijden 3e4ed1c
internal/ethapi: fix test
rjl493456442 1a887a2
core/txpool,internal/ethapi: fixup a few nits
lightclient File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.