mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
core/txpool/blobpool: add legacy sidecar conversion in reinject (#32688)
This adds the conversion for the legacy sidecar if these transactions are reorged out after the osaka.
This commit is contained in:
parent
2b5718fe92
commit
8dfd30fdd1
2 changed files with 43 additions and 0 deletions
|
|
@ -1030,6 +1030,21 @@ func (p *BlobPool) reinject(addr common.Address, txhash common.Hash) error {
|
||||||
// TODO: seems like an easy optimization here would be getting the serialized tx
|
// TODO: seems like an easy optimization here would be getting the serialized tx
|
||||||
// from limbo instead of re-serializing it here.
|
// from limbo instead of re-serializing it here.
|
||||||
|
|
||||||
|
// Converts reorged-out legacy blob transactions to the new format to prevent
|
||||||
|
// them from becoming stuck in the pool until eviction.
|
||||||
|
//
|
||||||
|
// Performance note: Conversion takes ~140ms (Mac M1 Pro). Since a maximum of
|
||||||
|
// 9 legacy blob transactions are allowed in a block pre-Osaka, an adversary
|
||||||
|
// could theoretically halt a Geth node for ~1.2s by reorging per block. However,
|
||||||
|
// this attack is financially inefficient to execute.
|
||||||
|
head := p.head.Load()
|
||||||
|
if p.chain.Config().IsOsaka(head.Number, head.Time) && tx.BlobTxSidecar().Version == types.BlobSidecarVersion0 {
|
||||||
|
if err := tx.BlobTxSidecar().ToV1(); err != nil {
|
||||||
|
log.Error("Failed to convert the legacy sidecar", "err", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Info("Legacy blob transaction is reorged", "hash", tx.Hash())
|
||||||
|
}
|
||||||
// Serialize the transaction back into the primary datastore.
|
// Serialize the transaction back into the primary datastore.
|
||||||
blob, err := rlp.EncodeToBytes(tx)
|
blob, err := rlp.EncodeToBytes(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -225,3 +225,31 @@ func testKZGCells(t *testing.T, ckzg bool) {
|
||||||
t.Fatalf("failed to verify KZG proof at point: %v", err)
|
t.Fatalf("failed to verify KZG proof at point: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// goos: darwin
|
||||||
|
// goarch: arm64
|
||||||
|
// pkg: github.com/ethereum/go-ethereum/crypto/kzg4844
|
||||||
|
// cpu: Apple M1 Pro
|
||||||
|
// BenchmarkGOKZGComputeCellProofs
|
||||||
|
// BenchmarkGOKZGComputeCellProofs-8 8 139012286 ns/op
|
||||||
|
func BenchmarkGOKZGComputeCellProofs(b *testing.B) { benchmarkComputeCellProofs(b, false) }
|
||||||
|
func BenchmarkCKZGComputeCellProofs(b *testing.B) { benchmarkComputeCellProofs(b, true) }
|
||||||
|
|
||||||
|
func benchmarkComputeCellProofs(b *testing.B, ckzg bool) {
|
||||||
|
if ckzg && !ckzgAvailable {
|
||||||
|
b.Skip("CKZG unavailable in this test build")
|
||||||
|
}
|
||||||
|
defer func(old bool) { useCKZG.Store(old) }(useCKZG.Load())
|
||||||
|
useCKZG.Store(ckzg)
|
||||||
|
|
||||||
|
blob := randBlob()
|
||||||
|
_, _ = ComputeCellProofs(blob) // for kzg initialization
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for b.Loop() {
|
||||||
|
_, err := ComputeCellProofs(blob)
|
||||||
|
if err != nil {
|
||||||
|
b.Fatalf("failed to create KZG proof at point: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue