mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Fix CopyTxs for BlobTxWrapper (EIP-4844) (#8002)
This commit is contained in:
parent
8809a4acd3
commit
e377cea51d
@ -1594,11 +1594,16 @@ func CopyTxs(in Transactions) Transactions {
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("MarshalTransactionsBinary failed: %w", err))
|
||||
}
|
||||
out, err := DecodeTransactions(transactionsData)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("DecodeTransactions failed: %w", err))
|
||||
}
|
||||
for i := 0; i < len(in); i++ {
|
||||
out := make([]Transaction, len(in))
|
||||
for i, tx := range in {
|
||||
if _, ok := tx.(*BlobTxWrapper); ok {
|
||||
out[i], err = UnmarshalWrappedTransactionFromBinary(transactionsData[i])
|
||||
} else {
|
||||
out[i], err = UnmarshalTransactionFromBinary(transactionsData[i])
|
||||
}
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("DecodeTransactions failed: %w", err))
|
||||
}
|
||||
if s, ok := in[i].GetSender(); ok {
|
||||
out[i].SetSender(s)
|
||||
}
|
||||
|
@ -486,3 +486,29 @@ func TestBlockRawBodyPostShanghaiWithdrawals(t *testing.T) {
|
||||
require.Equal(0, len(body.Transactions))
|
||||
require.Equal(2, len(body.Withdrawals))
|
||||
}
|
||||
|
||||
func TestCopyTxs(t *testing.T) {
|
||||
var txs Transactions
|
||||
txs = append(txs, &LegacyTx{
|
||||
CommonTx: CommonTx{
|
||||
Nonce: 0,
|
||||
Value: new(uint256.Int).SetUint64(10000),
|
||||
Gas: 50000,
|
||||
Data: []byte("Sparta"),
|
||||
},
|
||||
GasPrice: new(uint256.Int).SetUint64(10),
|
||||
})
|
||||
|
||||
populateBlobTxs()
|
||||
for _, tx := range dummyBlobTxs {
|
||||
txs = append(txs, tx)
|
||||
}
|
||||
|
||||
populateBlobWrapperTxs()
|
||||
for _, tx := range dummyBlobWrapperTxs {
|
||||
txs = append(txs, tx)
|
||||
}
|
||||
|
||||
copies := CopyTxs(txs)
|
||||
assert.Equal(t, txs, copies)
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ func NewLatestBlockBuiltStore() *LatestBlockBuiltStore {
|
||||
func (s *LatestBlockBuiltStore) AddBlockBuilt(block *types.Block) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
s.block = block.Copy()
|
||||
s.block = block
|
||||
}
|
||||
|
||||
func (s *LatestBlockBuiltStore) BlockBuilt() *types.Block {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
return s.block.Copy()
|
||||
return s.block
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user