mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
fix: modify removeParity function
This commit is contained in:
parent
46084fc2a5
commit
987582b5b3
2 changed files with 26 additions and 19 deletions
|
|
@ -184,33 +184,37 @@ func (ptx *PooledBlobTx) Convert() (*types.Transaction, error) {
|
|||
|
||||
return ptx.Transaction.WithBlobTxSidecar(sidecar), nil
|
||||
}
|
||||
|
||||
func (ptx *PooledBlobTx) RemoveParity() error {
|
||||
sc := ptx.Sidecar
|
||||
custodySize := sc.Custody.OneCount()
|
||||
if custodySize == 0 {
|
||||
return errors.New("blobless transaction")
|
||||
if sc == nil {
|
||||
return errors.New("nil sidecar")
|
||||
}
|
||||
blobCount := len(sc.Cells) / custodySize
|
||||
|
||||
var cellsWithoutParity []kzg4844.Cell
|
||||
pos := 0
|
||||
for range blobCount {
|
||||
for bit := 0; bit < kzg4844.CellsPerBlob; bit++ {
|
||||
if sc.Custody.IsSet(uint(bit)) {
|
||||
cell := sc.Cells[pos]
|
||||
pos++
|
||||
if bit < kzg4844.DataPerBlob {
|
||||
cellsWithoutParity = append(cellsWithoutParity, cell)
|
||||
}
|
||||
}
|
||||
for bit := range kzg4844.DataPerBlob {
|
||||
if !sc.Custody.IsSet(uint(bit)) {
|
||||
return errors.New("cannot remove parity for non-full payload transaction")
|
||||
}
|
||||
}
|
||||
sc.Cells = cellsWithoutParity
|
||||
for bit := 64; bit < kzg4844.CellsPerBlob; bit++ {
|
||||
sc.Custody.Clear(uint(bit))
|
||||
|
||||
blobCount := len(sc.Cells) / kzg4844.CellsPerBlob
|
||||
if blobCount == 0 || len(sc.Cells)%kzg4844.CellsPerBlob != 0 {
|
||||
return errors.New("inconsistent cell count")
|
||||
}
|
||||
|
||||
var cellsWithoutParity []kzg4844.Cell
|
||||
for blob := range blobCount {
|
||||
offset := blob * kzg4844.CellsPerBlob
|
||||
cellsWithoutParity = append(
|
||||
cellsWithoutParity,
|
||||
sc.Cells[offset:offset+kzg4844.DataPerBlob]...,
|
||||
)
|
||||
|
||||
for bit := 64; bit < kzg4844.CellsPerBlob; bit++ {
|
||||
sc.Custody.Clear(uint(bit))
|
||||
}
|
||||
}
|
||||
|
||||
sc.Cells = cellsWithoutParity
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,6 +145,9 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
|||
}
|
||||
|
||||
func ValidateBlobSidecar(tx *types.Transaction, sidecar *types.BlobTxCellSidecar, head *types.Header, opts *ValidationOptions) error {
|
||||
if sidecar.Custody.OneCount() == 0 {
|
||||
return errors.New("blobless blob transaction")
|
||||
}
|
||||
// Ensure the blob fee cap satisfies the minimum blob gas price
|
||||
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
|
||||
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrTxGasPriceTooLow, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)
|
||||
|
|
|
|||
Loading…
Reference in a new issue