mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Revert "Fixed corrupted transactions in GetPayloadBodies" (#8426)
Reverts ledgerwatch/erigon#8416
This commit is contained in:
parent
1617f1802b
commit
1d5d29709e
@ -1510,16 +1510,28 @@ func (b *Block) SendersToTxs(senders []libcommon.Address) {
|
||||
// RawBody creates a RawBody based on the block. It is not very efficient, so
|
||||
// will probably be removed in favour of RawBlock. Also it panics
|
||||
func (b *Block) RawBody() *RawBody {
|
||||
return b.Body().RawBody()
|
||||
br := &RawBody{Transactions: make([][]byte, len(b.transactions)), Uncles: b.uncles, Withdrawals: b.withdrawals}
|
||||
for i, tx := range b.transactions {
|
||||
var err error
|
||||
br.Transactions[i], err = rlp.EncodeToBytes(tx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return br
|
||||
}
|
||||
|
||||
// RawBody creates a RawBody based on the body.
|
||||
func (b *Body) RawBody() *RawBody {
|
||||
txs, err := MarshalTransactionsBinary(b.Transactions)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
br := &RawBody{Transactions: make([][]byte, len(b.Transactions)), Uncles: b.Uncles, Withdrawals: b.Withdrawals}
|
||||
for i, tx := range b.Transactions {
|
||||
var err error
|
||||
br.Transactions[i], err = rlp.EncodeToBytes(tx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
return &RawBody{Transactions: txs, Uncles: b.Uncles, Withdrawals: b.Withdrawals}
|
||||
return br
|
||||
}
|
||||
|
||||
// Size returns the true RLP encoded storage size of the block, either by encoding
|
||||
|
@ -512,52 +512,3 @@ func TestCopyTxs(t *testing.T) {
|
||||
copies := CopyTxs(txs)
|
||||
assert.Equal(t, txs, copies)
|
||||
}
|
||||
|
||||
func TestRawBodyConverter(t *testing.T) {
|
||||
blockEnc := common.FromHex("f90260f901f9a083cafc574e1f51ba9dc0568fc617a08ea2429fb384059c972f13b19fa1c8dd55a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017a05fe50b260da6308036625b850b5d6ced6d0a9f814c0688bc91ffb7b7a3a54b67a0bc37d79753ad738a6dac4921e57392f145d8887476de3f783dfa7edae9283e52b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd8825208845506eb0780a0bd4472abb6659ebe3ee06ee4d7b72a00a9f4d001caca51342001075469aff49888a13a5a8c8f2bb1c4f861f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1c0")
|
||||
var block Block
|
||||
if err := rlp.DecodeBytes(blockEnc, &block); err != nil {
|
||||
t.Fatal("decode error: ", err)
|
||||
}
|
||||
|
||||
expectedTxs := [][]byte{
|
||||
libcommon.FromHex("f85f800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba09bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094fa08a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1"),
|
||||
}
|
||||
require.Equal(t, block.RawBody().Transactions, expectedTxs)
|
||||
}
|
||||
|
||||
func TestRawBodyConverterShangai(t *testing.T) {
|
||||
header := Header{
|
||||
ParentHash: libcommon.HexToHash("0x8b00fcf1e541d371a3a1b79cc999a85cc3db5ee5637b5159646e1acd3613fd15"),
|
||||
Coinbase: libcommon.HexToAddress("0x571846e42308df2dad8ed792f44a8bfddf0acb4d"),
|
||||
Root: libcommon.HexToHash("0x351780124dae86b84998c6d4fe9a88acfb41b4856b4f2c56767b51a4e2f94dd4"),
|
||||
Difficulty: libcommon.Big0,
|
||||
Number: big.NewInt(20_000_000),
|
||||
GasLimit: 30_000_000,
|
||||
GasUsed: 3_074_345,
|
||||
Time: 1666343339,
|
||||
Extra: make([]byte, 0),
|
||||
MixDigest: libcommon.HexToHash("0x7f04e338b206ef863a1fad30e082bbb61571c74e135df8d1677e3f8b8171a09b"),
|
||||
BaseFee: big.NewInt(7_000_000_000),
|
||||
}
|
||||
|
||||
withdrawals := make([]*Withdrawal, 2)
|
||||
withdrawals[0] = &Withdrawal{
|
||||
Index: 44555666,
|
||||
Validator: 89,
|
||||
Address: libcommon.HexToAddress("0x690b9a9e9aa1c9db991c7721a92d351db4fac990"),
|
||||
Amount: 2,
|
||||
}
|
||||
withdrawals[1] = &Withdrawal{
|
||||
Index: 44555667,
|
||||
Validator: 37,
|
||||
Address: libcommon.HexToAddress("0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5"),
|
||||
Amount: 5_000_000_000,
|
||||
}
|
||||
|
||||
block := NewBlock(&header, nil, nil, nil, withdrawals)
|
||||
|
||||
rb := block.RawBody()
|
||||
|
||||
require.Equal(t, rb.Withdrawals, withdrawals)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user