mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/types, internal/ethapi: add back blobs after signing
This commit is contained in:
parent
1fd10adab9
commit
75f03ce450
3 changed files with 39 additions and 0 deletions
|
|
@ -446,6 +446,26 @@ func (tx *Transaction) WithoutBlobTxSidecar() *Transaction {
|
||||||
return cpy
|
return cpy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithBlobTxSidecar returns a copy of tx with the blob sidecar added.
|
||||||
|
func (tx *Transaction) WithBlobTxSidecar(sideCar *BlobTxSidecar) *Transaction {
|
||||||
|
blobtx, ok := tx.inner.(*BlobTx)
|
||||||
|
if !ok {
|
||||||
|
return tx
|
||||||
|
}
|
||||||
|
cpy := &Transaction{
|
||||||
|
inner: blobtx.withSidecar(sideCar),
|
||||||
|
time: tx.time,
|
||||||
|
}
|
||||||
|
// Note: tx.size cache not carried over because the sidecar is included in size!
|
||||||
|
if h := tx.hash.Load(); h != nil {
|
||||||
|
cpy.hash.Store(h)
|
||||||
|
}
|
||||||
|
if f := tx.from.Load(); f != nil {
|
||||||
|
cpy.from.Store(f)
|
||||||
|
}
|
||||||
|
return cpy
|
||||||
|
}
|
||||||
|
|
||||||
// SetTime sets the decoding time of a transaction. This is used by tests to set
|
// SetTime sets the decoding time of a transaction. This is used by tests to set
|
||||||
// arbitrary times and by persistent transaction pools when loading old txs from
|
// arbitrary times and by persistent transaction pools when loading old txs from
|
||||||
// disk.
|
// disk.
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,12 @@ func (tx *BlobTx) withoutSidecar() *BlobTx {
|
||||||
return &cpy
|
return &cpy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *BlobTx) withSidecar(sideCar *BlobTxSidecar) *BlobTx {
|
||||||
|
cpy := *tx
|
||||||
|
cpy.Sidecar = sideCar
|
||||||
|
return &cpy
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *BlobTx) encode(b *bytes.Buffer) error {
|
func (tx *BlobTx) encode(b *bytes.Buffer) error {
|
||||||
if tx.Sidecar == nil {
|
if tx.Sidecar == nil {
|
||||||
return rlp.Encode(b, tx)
|
return rlp.Encode(b, tx)
|
||||||
|
|
|
||||||
|
|
@ -499,6 +499,9 @@ func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args Transacti
|
||||||
if args.GasPrice == nil && (args.MaxFeePerGas == nil || args.MaxPriorityFeePerGas == nil) {
|
if args.GasPrice == nil && (args.MaxFeePerGas == nil || args.MaxPriorityFeePerGas == nil) {
|
||||||
return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas")
|
return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas")
|
||||||
}
|
}
|
||||||
|
if args.IsEIP4844() {
|
||||||
|
return nil, errBlobTxNotSupported
|
||||||
|
}
|
||||||
if args.Nonce == nil {
|
if args.Nonce == nil {
|
||||||
return nil, errors.New("nonce not specified")
|
return nil, errors.New("nonce not specified")
|
||||||
}
|
}
|
||||||
|
|
@ -1892,6 +1895,16 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// If the transaction-to-sign was a blob transaction, then the signed one
|
||||||
|
// 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.BlobTxSidecar{
|
||||||
|
args.Blobs,
|
||||||
|
args.Commitments,
|
||||||
|
args.Proofs,
|
||||||
|
})
|
||||||
|
}
|
||||||
data, err := signed.MarshalBinary()
|
data, err := signed.MarshalBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue