mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core/types: add handcrafted and generated rlp encoders
This commit is contained in:
parent
f9f1172d59
commit
89a5581473
17 changed files with 1332 additions and 5 deletions
|
|
@ -69,7 +69,7 @@ type ExecutionWitness struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate go run github.com/fjl/gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
|
//go:generate go run github.com/fjl/gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
|
||||||
//go:generate go run ../../rlp/rlpgen -type Header -out gen_header_rlp.go
|
//go:generate go run ../../rlp/rlpgen -type Header -decoder=false -out gen_header_rlp.go
|
||||||
|
|
||||||
// Header represents a block header in the Ethereum blockchain.
|
// Header represents a block header in the Ethereum blockchain.
|
||||||
type Header struct {
|
type Header struct {
|
||||||
|
|
@ -554,3 +554,124 @@ func HeaderParentHashFromRLP(header []byte) common.Hash {
|
||||||
}
|
}
|
||||||
return common.BytesToHash(parentHash)
|
return common.BytesToHash(parentHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *Header) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var err error
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ParentHash:
|
||||||
|
if err := dec.ReadBytes(obj.ParentHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// UncleHash:
|
||||||
|
if err := dec.ReadBytes(obj.UncleHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Coinbase:
|
||||||
|
if err := dec.ReadBytes(obj.Coinbase[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Root:
|
||||||
|
if err := dec.ReadBytes(obj.Root[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// TxHash:
|
||||||
|
if err := dec.ReadBytes(obj.TxHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ReceiptHash:
|
||||||
|
if err := dec.ReadBytes(obj.ReceiptHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Bloom:
|
||||||
|
if err := dec.ReadBytes(obj.Bloom[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Difficulty:
|
||||||
|
obj.Difficulty, err = dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Number:
|
||||||
|
obj.Number, err = dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
// GasLimit:
|
||||||
|
obj.GasLimit, err = dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// GasUsed:
|
||||||
|
obj.GasUsed, err = dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Time:
|
||||||
|
obj.Time, err = dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Extra:
|
||||||
|
obj.Extra, err = dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// MixDigest:
|
||||||
|
if err := dec.ReadBytes(obj.MixDigest[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Nonce:
|
||||||
|
if err := dec.ReadBytes(obj.Nonce[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// BaseFee:
|
||||||
|
if dec.MoreDataInList() {
|
||||||
|
obj.BaseFee, err = dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// WithdrawalsHash:
|
||||||
|
if dec.MoreDataInList() {
|
||||||
|
if err := dec.ReadBytes(obj.WithdrawalsHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// BlobGasUsed:
|
||||||
|
if dec.MoreDataInList() {
|
||||||
|
_tmp18, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
obj.BlobGasUsed = &_tmp18
|
||||||
|
// ExcessBlobGas:
|
||||||
|
if dec.MoreDataInList() {
|
||||||
|
_tmp19, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
obj.ExcessBlobGas = &_tmp19
|
||||||
|
// ParentBeaconRoot:
|
||||||
|
if dec.MoreDataInList() {
|
||||||
|
if err := dec.ReadBytes(obj.ParentBeaconRoot[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// RequestsHash:
|
||||||
|
if dec.MoreDataInList() {
|
||||||
|
if err := dec.ReadBytes(obj.RequestsHash[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ func BenchmarkEncodeBlock(b *testing.B) {
|
||||||
func makeBenchBlock() *Block {
|
func makeBenchBlock() *Block {
|
||||||
var (
|
var (
|
||||||
key, _ = crypto.GenerateKey()
|
key, _ = crypto.GenerateKey()
|
||||||
txs = make([]*Transaction, 70)
|
txs = make([]*Transaction, 200)
|
||||||
receipts = make([]*Receipt, len(txs))
|
receipts = make([]*Receipt, len(txs))
|
||||||
signer = LatestSigner(params.TestChainConfig)
|
signer = LatestSigner(params.TestChainConfig)
|
||||||
uncles = make([]*Header, 3)
|
uncles = make([]*Header, 3)
|
||||||
|
|
@ -237,7 +237,15 @@ func makeBenchBlock() *Block {
|
||||||
amount := math.BigPow(2, int64(i))
|
amount := math.BigPow(2, int64(i))
|
||||||
price := big.NewInt(300000)
|
price := big.NewInt(300000)
|
||||||
data := make([]byte, 100)
|
data := make([]byte, 100)
|
||||||
tx := NewTransaction(uint64(i), common.Address{}, amount, 123457, price, data)
|
tx := NewTx(&DynamicFeeTx{
|
||||||
|
ChainID: big.NewInt(0),
|
||||||
|
Nonce: uint64(i),
|
||||||
|
To: &common.Address{},
|
||||||
|
Value: amount,
|
||||||
|
Gas: price.Uint64(),
|
||||||
|
Data: data,
|
||||||
|
AccessList: make(AccessList, 0),
|
||||||
|
})
|
||||||
signedTx, err := SignTx(tx, signer, key)
|
signedTx, err := SignTx(tx, signer, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
||||||
205
core/types/gen_access_list_tx_rlp.go
Normal file
205
core/types/gen_access_list_tx_rlp.go
Normal file
|
|
@ -0,0 +1,205 @@
|
||||||
|
// Code generated by rlpgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
func (obj *AccessListTx) EncodeRLP(_w io.Writer) error {
|
||||||
|
w := rlp.NewEncoderBuffer(_w)
|
||||||
|
_tmp0 := w.List()
|
||||||
|
if obj.ChainID == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.ChainID.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.ChainID)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Nonce)
|
||||||
|
if obj.GasPrice == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.GasPrice.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.GasPrice)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Gas)
|
||||||
|
if obj.To == nil {
|
||||||
|
w.Write([]byte{0x80})
|
||||||
|
} else {
|
||||||
|
w.WriteBytes(obj.To[:])
|
||||||
|
}
|
||||||
|
if obj.Value == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.Value.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.Value)
|
||||||
|
}
|
||||||
|
w.WriteBytes(obj.Data)
|
||||||
|
_tmp1 := w.List()
|
||||||
|
for _, _tmp2 := range obj.AccessList {
|
||||||
|
_tmp3 := w.List()
|
||||||
|
w.WriteBytes(_tmp2.Address[:])
|
||||||
|
_tmp4 := w.List()
|
||||||
|
for _, _tmp5 := range _tmp2.StorageKeys {
|
||||||
|
w.WriteBytes(_tmp5[:])
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp4)
|
||||||
|
w.ListEnd(_tmp3)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp1)
|
||||||
|
if obj.V == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.V.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.V)
|
||||||
|
}
|
||||||
|
if obj.R == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.R.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.R)
|
||||||
|
}
|
||||||
|
if obj.S == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.S.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.S)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp0)
|
||||||
|
return w.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *AccessListTx) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 AccessListTx
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ChainID:
|
||||||
|
_tmp1, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.ChainID = _tmp1
|
||||||
|
// Nonce:
|
||||||
|
_tmp2, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Nonce = _tmp2
|
||||||
|
// GasPrice:
|
||||||
|
_tmp3, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasPrice = _tmp3
|
||||||
|
// Gas:
|
||||||
|
_tmp4, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Gas = _tmp4
|
||||||
|
// To:
|
||||||
|
var _tmp6 *common.Address
|
||||||
|
if _tmp7, _tmp8, err := dec.Kind(); err != nil {
|
||||||
|
return err
|
||||||
|
} else if _tmp8 != 0 || _tmp7 != rlp.String {
|
||||||
|
var _tmp5 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp5[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp6 = &_tmp5
|
||||||
|
}
|
||||||
|
_tmp0.To = _tmp6
|
||||||
|
// Value:
|
||||||
|
_tmp9, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Value = _tmp9
|
||||||
|
// Data:
|
||||||
|
_tmp10, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Data = _tmp10
|
||||||
|
// AccessList:
|
||||||
|
var _tmp11 []AccessTuple
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp12 AccessTuple
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Address:
|
||||||
|
var _tmp13 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp13[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp12.Address = _tmp13
|
||||||
|
// StorageKeys:
|
||||||
|
var _tmp14 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp15 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp15[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp14 = append(_tmp14, _tmp15)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp12.StorageKeys = _tmp14
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp11 = append(_tmp11, _tmp12)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.AccessList = _tmp11
|
||||||
|
// V:
|
||||||
|
_tmp16, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.V = _tmp16
|
||||||
|
// R:
|
||||||
|
_tmp17, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.R = _tmp17
|
||||||
|
// S:
|
||||||
|
_tmp18, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.S = _tmp18
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
import "github.com/ethereum/go-ethereum/rlp"
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "github.com/holiman/uint256"
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
func (obj *StateAccount) EncodeRLP(_w io.Writer) error {
|
func (obj *StateAccount) EncodeRLP(_w io.Writer) error {
|
||||||
|
|
@ -19,3 +21,41 @@ func (obj *StateAccount) EncodeRLP(_w io.Writer) error {
|
||||||
w.ListEnd(_tmp0)
|
w.ListEnd(_tmp0)
|
||||||
return w.Flush()
|
return w.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *StateAccount) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 StateAccount
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Nonce:
|
||||||
|
_tmp1, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Nonce = _tmp1
|
||||||
|
// Balance:
|
||||||
|
var _tmp2 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp2); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Balance = &_tmp2
|
||||||
|
// Root:
|
||||||
|
var _tmp3 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp3[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Root = _tmp3
|
||||||
|
// CodeHash:
|
||||||
|
_tmp4, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.CodeHash = _tmp4
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
221
core/types/gen_blob_tx_rlp.go
Normal file
221
core/types/gen_blob_tx_rlp.go
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
// Code generated by rlpgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "github.com/holiman/uint256"
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
func (obj *BlobTx) EncodeRLP(_w io.Writer) error {
|
||||||
|
w := rlp.NewEncoderBuffer(_w)
|
||||||
|
_tmp0 := w.List()
|
||||||
|
if obj.ChainID == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.ChainID)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Nonce)
|
||||||
|
if obj.GasTipCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.GasTipCap)
|
||||||
|
}
|
||||||
|
if obj.GasFeeCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.GasFeeCap)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Gas)
|
||||||
|
w.WriteBytes(obj.To[:])
|
||||||
|
if obj.Value == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.Value)
|
||||||
|
}
|
||||||
|
w.WriteBytes(obj.Data)
|
||||||
|
_tmp1 := w.List()
|
||||||
|
for _, _tmp2 := range obj.AccessList {
|
||||||
|
_tmp3 := w.List()
|
||||||
|
w.WriteBytes(_tmp2.Address[:])
|
||||||
|
_tmp4 := w.List()
|
||||||
|
for _, _tmp5 := range _tmp2.StorageKeys {
|
||||||
|
w.WriteBytes(_tmp5[:])
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp4)
|
||||||
|
w.ListEnd(_tmp3)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp1)
|
||||||
|
if obj.BlobFeeCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.BlobFeeCap)
|
||||||
|
}
|
||||||
|
_tmp6 := w.List()
|
||||||
|
for _, _tmp7 := range obj.BlobHashes {
|
||||||
|
w.WriteBytes(_tmp7[:])
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp6)
|
||||||
|
if obj.V == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.V)
|
||||||
|
}
|
||||||
|
if obj.R == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.R)
|
||||||
|
}
|
||||||
|
if obj.S == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.S)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp0)
|
||||||
|
return w.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *BlobTx) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 BlobTx
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ChainID:
|
||||||
|
var _tmp1 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.ChainID = &_tmp1
|
||||||
|
// Nonce:
|
||||||
|
_tmp2, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Nonce = _tmp2
|
||||||
|
// GasTipCap:
|
||||||
|
var _tmp3 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp3); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasTipCap = &_tmp3
|
||||||
|
// GasFeeCap:
|
||||||
|
var _tmp4 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp4); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasFeeCap = &_tmp4
|
||||||
|
// Gas:
|
||||||
|
_tmp5, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Gas = _tmp5
|
||||||
|
// To:
|
||||||
|
var _tmp6 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp6[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.To = _tmp6
|
||||||
|
// Value:
|
||||||
|
var _tmp7 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp7); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Value = &_tmp7
|
||||||
|
// Data:
|
||||||
|
_tmp8, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Data = _tmp8
|
||||||
|
// AccessList:
|
||||||
|
var _tmp9 []AccessTuple
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp10 AccessTuple
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Address:
|
||||||
|
var _tmp11 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp11[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp10.Address = _tmp11
|
||||||
|
// StorageKeys:
|
||||||
|
var _tmp12 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp13 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp13[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp12 = append(_tmp12, _tmp13)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp10.StorageKeys = _tmp12
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp9 = append(_tmp9, _tmp10)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.AccessList = _tmp9
|
||||||
|
// BlobFeeCap:
|
||||||
|
var _tmp14 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp14); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.BlobFeeCap = &_tmp14
|
||||||
|
// BlobHashes:
|
||||||
|
var _tmp15 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp16 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp16[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15 = append(_tmp15, _tmp16)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.BlobHashes = _tmp15
|
||||||
|
// V:
|
||||||
|
var _tmp17 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp17); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.V = &_tmp17
|
||||||
|
// R:
|
||||||
|
var _tmp18 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp18); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.R = &_tmp18
|
||||||
|
// S:
|
||||||
|
var _tmp19 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp19); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.S = &_tmp19
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
219
core/types/gen_dynamic_fee_tx_rlp.go
Normal file
219
core/types/gen_dynamic_fee_tx_rlp.go
Normal file
|
|
@ -0,0 +1,219 @@
|
||||||
|
// Code generated by rlpgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
func (obj *DynamicFeeTx) EncodeRLP(_w io.Writer) error {
|
||||||
|
w := rlp.NewEncoderBuffer(_w)
|
||||||
|
_tmp0 := w.List()
|
||||||
|
if obj.ChainID == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.ChainID.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.ChainID)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Nonce)
|
||||||
|
if obj.GasTipCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.GasTipCap.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.GasTipCap)
|
||||||
|
}
|
||||||
|
if obj.GasFeeCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.GasFeeCap.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.GasFeeCap)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Gas)
|
||||||
|
if obj.To == nil {
|
||||||
|
w.Write([]byte{0x80})
|
||||||
|
} else {
|
||||||
|
w.WriteBytes(obj.To[:])
|
||||||
|
}
|
||||||
|
if obj.Value == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.Value.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.Value)
|
||||||
|
}
|
||||||
|
w.WriteBytes(obj.Data)
|
||||||
|
_tmp1 := w.List()
|
||||||
|
for _, _tmp2 := range obj.AccessList {
|
||||||
|
_tmp3 := w.List()
|
||||||
|
w.WriteBytes(_tmp2.Address[:])
|
||||||
|
_tmp4 := w.List()
|
||||||
|
for _, _tmp5 := range _tmp2.StorageKeys {
|
||||||
|
w.WriteBytes(_tmp5[:])
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp4)
|
||||||
|
w.ListEnd(_tmp3)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp1)
|
||||||
|
if obj.V == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.V.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.V)
|
||||||
|
}
|
||||||
|
if obj.R == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.R.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.R)
|
||||||
|
}
|
||||||
|
if obj.S == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.S.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.S)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp0)
|
||||||
|
return w.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *DynamicFeeTx) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 DynamicFeeTx
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ChainID:
|
||||||
|
_tmp1, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.ChainID = _tmp1
|
||||||
|
// Nonce:
|
||||||
|
_tmp2, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Nonce = _tmp2
|
||||||
|
// GasTipCap:
|
||||||
|
_tmp3, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasTipCap = _tmp3
|
||||||
|
// GasFeeCap:
|
||||||
|
_tmp4, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasFeeCap = _tmp4
|
||||||
|
// Gas:
|
||||||
|
_tmp5, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Gas = _tmp5
|
||||||
|
// To:
|
||||||
|
var _tmp7 *common.Address
|
||||||
|
if _tmp8, _tmp9, err := dec.Kind(); err != nil {
|
||||||
|
return err
|
||||||
|
} else if _tmp9 != 0 || _tmp8 != rlp.String {
|
||||||
|
var _tmp6 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp6[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp7 = &_tmp6
|
||||||
|
}
|
||||||
|
_tmp0.To = _tmp7
|
||||||
|
// Value:
|
||||||
|
_tmp10, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Value = _tmp10
|
||||||
|
// Data:
|
||||||
|
_tmp11, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Data = _tmp11
|
||||||
|
// AccessList:
|
||||||
|
var _tmp12 []AccessTuple
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp13 AccessTuple
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Address:
|
||||||
|
var _tmp14 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp14[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp13.Address = _tmp14
|
||||||
|
// StorageKeys:
|
||||||
|
var _tmp15 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp16 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp16[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15 = append(_tmp15, _tmp16)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp13.StorageKeys = _tmp15
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp12 = append(_tmp12, _tmp13)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.AccessList = _tmp12
|
||||||
|
// V:
|
||||||
|
_tmp17, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.V = _tmp17
|
||||||
|
// R:
|
||||||
|
_tmp18, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.R = _tmp18
|
||||||
|
// S:
|
||||||
|
_tmp19, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.S = _tmp19
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
136
core/types/gen_legacy_tx_rlp.go
Normal file
136
core/types/gen_legacy_tx_rlp.go
Normal file
|
|
@ -0,0 +1,136 @@
|
||||||
|
// Code generated by rlpgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
func (obj *LegacyTx) EncodeRLP(_w io.Writer) error {
|
||||||
|
w := rlp.NewEncoderBuffer(_w)
|
||||||
|
_tmp0 := w.List()
|
||||||
|
w.WriteUint64(obj.Nonce)
|
||||||
|
if obj.GasPrice == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.GasPrice.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.GasPrice)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Gas)
|
||||||
|
if obj.To == nil {
|
||||||
|
w.Write([]byte{0x80})
|
||||||
|
} else {
|
||||||
|
w.WriteBytes(obj.To[:])
|
||||||
|
}
|
||||||
|
if obj.Value == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.Value.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.Value)
|
||||||
|
}
|
||||||
|
w.WriteBytes(obj.Data)
|
||||||
|
if obj.V == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.V.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.V)
|
||||||
|
}
|
||||||
|
if obj.R == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.R.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.R)
|
||||||
|
}
|
||||||
|
if obj.S == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
if obj.S.Sign() == -1 {
|
||||||
|
return rlp.ErrNegativeBigInt
|
||||||
|
}
|
||||||
|
w.WriteBigInt(obj.S)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp0)
|
||||||
|
return w.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *LegacyTx) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 LegacyTx
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Nonce:
|
||||||
|
_tmp1, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Nonce = _tmp1
|
||||||
|
// GasPrice:
|
||||||
|
_tmp2, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasPrice = _tmp2
|
||||||
|
// Gas:
|
||||||
|
_tmp3, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Gas = _tmp3
|
||||||
|
// To:
|
||||||
|
var _tmp5 *common.Address
|
||||||
|
if _tmp6, _tmp7, err := dec.Kind(); err != nil {
|
||||||
|
return err
|
||||||
|
} else if _tmp7 != 0 || _tmp6 != rlp.String {
|
||||||
|
var _tmp4 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp4[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp5 = &_tmp4
|
||||||
|
}
|
||||||
|
_tmp0.To = _tmp5
|
||||||
|
// Value:
|
||||||
|
_tmp8, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Value = _tmp8
|
||||||
|
// Data:
|
||||||
|
_tmp9, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Data = _tmp9
|
||||||
|
// V:
|
||||||
|
_tmp10, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.V = _tmp10
|
||||||
|
// R:
|
||||||
|
_tmp11, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.R = _tmp11
|
||||||
|
// S:
|
||||||
|
_tmp12, err := dec.BigInt()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.S = _tmp12
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
import "github.com/ethereum/go-ethereum/rlp"
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
|
|
@ -18,3 +19,45 @@ func (obj *Log) EncodeRLP(_w io.Writer) error {
|
||||||
w.ListEnd(_tmp0)
|
w.ListEnd(_tmp0)
|
||||||
return w.Flush()
|
return w.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *Log) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 Log
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Address:
|
||||||
|
var _tmp1 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp1[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Address = _tmp1
|
||||||
|
// Topics:
|
||||||
|
var _tmp2 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp3 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp3[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp2 = append(_tmp2, _tmp3)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Topics = _tmp2
|
||||||
|
// Data:
|
||||||
|
_tmp4, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Data = _tmp4
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
258
core/types/gen_setcode_tx_rlp.go
Normal file
258
core/types/gen_setcode_tx_rlp.go
Normal file
|
|
@ -0,0 +1,258 @@
|
||||||
|
// Code generated by rlpgen. DO NOT EDIT.
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
|
import "github.com/holiman/uint256"
|
||||||
|
import "io"
|
||||||
|
|
||||||
|
func (obj *SetCodeTx) EncodeRLP(_w io.Writer) error {
|
||||||
|
w := rlp.NewEncoderBuffer(_w)
|
||||||
|
_tmp0 := w.List()
|
||||||
|
if obj.ChainID == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.ChainID)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Nonce)
|
||||||
|
if obj.GasTipCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.GasTipCap)
|
||||||
|
}
|
||||||
|
if obj.GasFeeCap == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.GasFeeCap)
|
||||||
|
}
|
||||||
|
w.WriteUint64(obj.Gas)
|
||||||
|
w.WriteBytes(obj.To[:])
|
||||||
|
if obj.Value == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.Value)
|
||||||
|
}
|
||||||
|
w.WriteBytes(obj.Data)
|
||||||
|
_tmp1 := w.List()
|
||||||
|
for _, _tmp2 := range obj.AccessList {
|
||||||
|
_tmp3 := w.List()
|
||||||
|
w.WriteBytes(_tmp2.Address[:])
|
||||||
|
_tmp4 := w.List()
|
||||||
|
for _, _tmp5 := range _tmp2.StorageKeys {
|
||||||
|
w.WriteBytes(_tmp5[:])
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp4)
|
||||||
|
w.ListEnd(_tmp3)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp1)
|
||||||
|
_tmp6 := w.List()
|
||||||
|
for _, _tmp7 := range obj.AuthList {
|
||||||
|
_tmp8 := w.List()
|
||||||
|
w.WriteUint256(&_tmp7.ChainID)
|
||||||
|
w.WriteBytes(_tmp7.Address[:])
|
||||||
|
w.WriteUint64(_tmp7.Nonce)
|
||||||
|
w.WriteUint64(uint64(_tmp7.V))
|
||||||
|
w.WriteUint256(&_tmp7.R)
|
||||||
|
w.WriteUint256(&_tmp7.S)
|
||||||
|
w.ListEnd(_tmp8)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp6)
|
||||||
|
if obj.V == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.V)
|
||||||
|
}
|
||||||
|
if obj.R == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.R)
|
||||||
|
}
|
||||||
|
if obj.S == nil {
|
||||||
|
w.Write(rlp.EmptyString)
|
||||||
|
} else {
|
||||||
|
w.WriteUint256(obj.S)
|
||||||
|
}
|
||||||
|
w.ListEnd(_tmp0)
|
||||||
|
return w.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (obj *SetCodeTx) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 SetCodeTx
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ChainID:
|
||||||
|
var _tmp1 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp1); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.ChainID = &_tmp1
|
||||||
|
// Nonce:
|
||||||
|
_tmp2, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Nonce = _tmp2
|
||||||
|
// GasTipCap:
|
||||||
|
var _tmp3 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp3); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasTipCap = &_tmp3
|
||||||
|
// GasFeeCap:
|
||||||
|
var _tmp4 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp4); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.GasFeeCap = &_tmp4
|
||||||
|
// Gas:
|
||||||
|
_tmp5, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Gas = _tmp5
|
||||||
|
// To:
|
||||||
|
var _tmp6 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp6[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.To = _tmp6
|
||||||
|
// Value:
|
||||||
|
var _tmp7 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp7); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Value = &_tmp7
|
||||||
|
// Data:
|
||||||
|
_tmp8, err := dec.Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Data = _tmp8
|
||||||
|
// AccessList:
|
||||||
|
var _tmp9 []AccessTuple
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp10 AccessTuple
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Address:
|
||||||
|
var _tmp11 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp11[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp10.Address = _tmp11
|
||||||
|
// StorageKeys:
|
||||||
|
var _tmp12 []common.Hash
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp13 common.Hash
|
||||||
|
if err := dec.ReadBytes(_tmp13[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp12 = append(_tmp12, _tmp13)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp10.StorageKeys = _tmp12
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp9 = append(_tmp9, _tmp10)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.AccessList = _tmp9
|
||||||
|
// AuthList:
|
||||||
|
var _tmp14 []SetCodeAuthorization
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dec.MoreDataInList() {
|
||||||
|
var _tmp15 SetCodeAuthorization
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// ChainID:
|
||||||
|
var _tmp16 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp16); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15.ChainID = _tmp16
|
||||||
|
// Address:
|
||||||
|
var _tmp17 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp17[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15.Address = _tmp17
|
||||||
|
// Nonce:
|
||||||
|
_tmp18, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15.Nonce = _tmp18
|
||||||
|
// V:
|
||||||
|
_tmp19, err := dec.Uint8()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15.V = _tmp19
|
||||||
|
// R:
|
||||||
|
var _tmp20 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp20); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15.R = _tmp20
|
||||||
|
// S:
|
||||||
|
var _tmp21 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp21); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp15.S = _tmp21
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_tmp14 = append(_tmp14, _tmp15)
|
||||||
|
}
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.AuthList = _tmp14
|
||||||
|
// V:
|
||||||
|
var _tmp22 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp22); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.V = &_tmp22
|
||||||
|
// R:
|
||||||
|
var _tmp23 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp23); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.R = &_tmp23
|
||||||
|
// S:
|
||||||
|
var _tmp24 uint256.Int
|
||||||
|
if err := dec.ReadUint256(&_tmp24); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.S = &_tmp24
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package types
|
package types
|
||||||
|
|
||||||
|
import "github.com/ethereum/go-ethereum/common"
|
||||||
import "github.com/ethereum/go-ethereum/rlp"
|
import "github.com/ethereum/go-ethereum/rlp"
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
|
|
@ -15,3 +16,41 @@ func (obj *Withdrawal) EncodeRLP(_w io.Writer) error {
|
||||||
w.ListEnd(_tmp0)
|
w.ListEnd(_tmp0)
|
||||||
return w.Flush()
|
return w.Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (obj *Withdrawal) DecodeRLP(dec *rlp.Stream) error {
|
||||||
|
var _tmp0 Withdrawal
|
||||||
|
{
|
||||||
|
if _, err := dec.List(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Index:
|
||||||
|
_tmp1, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Index = _tmp1
|
||||||
|
// Validator:
|
||||||
|
_tmp2, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Validator = _tmp2
|
||||||
|
// Address:
|
||||||
|
var _tmp3 common.Address
|
||||||
|
if err := dec.ReadBytes(_tmp3[:]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Address = _tmp3
|
||||||
|
// Amount:
|
||||||
|
_tmp4, err := dec.Uint64()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_tmp0.Amount = _tmp4
|
||||||
|
if err := dec.ListEnd(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*obj = _tmp0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run github.com/fjl/gencodec -type AccessTuple -out gen_access_tuple.go
|
//go:generate go run github.com/fjl/gencodec -type AccessTuple -out gen_access_tuple.go
|
||||||
|
//go:generate go run ../../rlp/rlpgen -type AccessListTx -out gen_access_list_tx_rlp.go
|
||||||
|
|
||||||
// AccessList is an EIP-2930 access list.
|
// AccessList is an EIP-2930 access list.
|
||||||
type AccessList []AccessTuple
|
type AccessList []AccessTuple
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import (
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../../rlp/rlpgen -type BlobTx -out gen_blob_tx_rlp.go
|
||||||
|
|
||||||
// BlobTx represents an EIP-4844 transaction.
|
// BlobTx represents an EIP-4844 transaction.
|
||||||
type BlobTx struct {
|
type BlobTx struct {
|
||||||
ChainID *uint256.Int
|
ChainID *uint256.Int
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../../rlp/rlpgen -type DynamicFeeTx -out gen_dynamic_fee_tx_rlp.go
|
||||||
|
|
||||||
// DynamicFeeTx represents an EIP-1559 transaction.
|
// DynamicFeeTx represents an EIP-1559 transaction.
|
||||||
type DynamicFeeTx struct {
|
type DynamicFeeTx struct {
|
||||||
ChainID *big.Int
|
ChainID *big.Int
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../../rlp/rlpgen -type LegacyTx -out gen_legacy_tx_rlp.go
|
||||||
|
|
||||||
// LegacyTx is the transaction data of the original Ethereum transactions.
|
// LegacyTx is the transaction data of the original Ethereum transactions.
|
||||||
type LegacyTx struct {
|
type LegacyTx struct {
|
||||||
Nonce uint64 // nonce of sender account
|
Nonce uint64 // nonce of sender account
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import (
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate go run ../../rlp/rlpgen -type SetCodeTx -out gen_setcode_tx_rlp.go
|
||||||
|
|
||||||
// DelegationPrefix is used by code to denote the account is delegating to
|
// DelegationPrefix is used by code to denote the account is delegating to
|
||||||
// another account.
|
// another account.
|
||||||
var DelegationPrefix = []byte{0xef, 0x01, 0x00}
|
var DelegationPrefix = []byte{0xef, 0x01, 0x00}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto/kzg4844"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
type devnull struct{ len int }
|
type devnull struct{ len int }
|
||||||
|
|
@ -43,7 +45,7 @@ func BenchmarkDecodeRLP(b *testing.B) {
|
||||||
func benchRLP(b *testing.B, encode bool) {
|
func benchRLP(b *testing.B, encode bool) {
|
||||||
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||||
to := common.HexToAddress("0x00000000000000000000000000000000deadbeef")
|
to := common.HexToAddress("0x00000000000000000000000000000000deadbeef")
|
||||||
signer := NewLondonSigner(big.NewInt(1337))
|
signer := NewCancunSigner(big.NewInt(1337))
|
||||||
for _, tc := range []struct {
|
for _, tc := range []struct {
|
||||||
name string
|
name string
|
||||||
obj interface{}
|
obj interface{}
|
||||||
|
|
@ -121,6 +123,32 @@ func benchRLP(b *testing.B, encode bool) {
|
||||||
GasFeeCap: big.NewInt(500),
|
GasFeeCap: big.NewInt(500),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"blob-transaction",
|
||||||
|
MustSignNewTx(key, signer,
|
||||||
|
&BlobTx{
|
||||||
|
Nonce: 1,
|
||||||
|
Gas: 1000000,
|
||||||
|
To: to,
|
||||||
|
Value: uint256.NewInt(1),
|
||||||
|
GasTipCap: uint256.NewInt(500),
|
||||||
|
GasFeeCap: uint256.NewInt(500),
|
||||||
|
BlobFeeCap: uint256.NewInt(500),
|
||||||
|
BlobHashes: make([]common.Hash, 6),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"blob-sidecar",
|
||||||
|
&BlobTxSidecar{
|
||||||
|
Blobs: make([]kzg4844.Blob, 6),
|
||||||
|
Commitments: make([]kzg4844.Commitment, 6),
|
||||||
|
Proofs: make([]kzg4844.Proof, 6),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"full-block",
|
||||||
|
makeBenchBlock(),
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
if encode {
|
if encode {
|
||||||
b.Run(tc.name, func(b *testing.B) {
|
b.Run(tc.name, func(b *testing.B) {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func main() {
|
||||||
pkgdir = flag.String("dir", ".", "input package")
|
pkgdir = flag.String("dir", ".", "input package")
|
||||||
output = flag.String("out", "-", "output file (default is stdout)")
|
output = flag.String("out", "-", "output file (default is stdout)")
|
||||||
genEncoder = flag.Bool("encoder", true, "generate EncodeRLP?")
|
genEncoder = flag.Bool("encoder", true, "generate EncodeRLP?")
|
||||||
genDecoder = flag.Bool("decoder", false, "generate DecodeRLP?")
|
genDecoder = flag.Bool("decoder", true, "generate DecodeRLP?")
|
||||||
typename = flag.String("type", "", "type to generate methods for")
|
typename = flag.String("type", "", "type to generate methods for")
|
||||||
)
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue