Unverified Commit 19824372 authored by Péter Szilágyi's avatar Péter Szilágyi Committed by GitHub

core/types: un-ssz blob txs, add json marshalling and tweaks (#27256)

parent dffd804c
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
// MarshalJSON marshals as JSON. // MarshalJSON marshals as JSON.
func (a AccessTuple) MarshalJSON() ([]byte, error) { func (a AccessTuple) MarshalJSON() ([]byte, error) {
type AccessTuple struct { type AccessTuple struct {
Address common.Address `json:"address" gencodec:"required"` Address common.Address `json:"address" gencodec:"required"`
StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"`
} }
var enc AccessTuple var enc AccessTuple
enc.Address = a.Address enc.Address = a.Address
...@@ -24,8 +24,8 @@ func (a AccessTuple) MarshalJSON() ([]byte, error) { ...@@ -24,8 +24,8 @@ func (a AccessTuple) MarshalJSON() ([]byte, error) {
// UnmarshalJSON unmarshals from JSON. // UnmarshalJSON unmarshals from JSON.
func (a *AccessTuple) UnmarshalJSON(input []byte) error { func (a *AccessTuple) UnmarshalJSON(input []byte) error {
type AccessTuple struct { type AccessTuple struct {
Address *common.Address `json:"address" gencodec:"required"` Address *common.Address `json:"address" gencodec:"required"`
StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"`
} }
var dec AccessTuple var dec AccessTuple
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
......
...@@ -198,7 +198,7 @@ func (tx *Transaction) decodeTyped(b []byte) (TxData, error) { ...@@ -198,7 +198,7 @@ func (tx *Transaction) decodeTyped(b []byte) (TxData, error) {
return &inner, err return &inner, err
case BlobTxType: case BlobTxType:
var inner BlobTx var inner BlobTx
err := rlp.DecodeBytes(b[1:], &inner) // TODO(karalabe): This needs to be ssz err := rlp.DecodeBytes(b[1:], &inner)
return &inner, err return &inner, err
default: default:
return nil, ErrTxTypeNotSupported return nil, ErrTxTypeNotSupported
...@@ -417,11 +417,7 @@ func (tx *Transaction) Size() uint64 { ...@@ -417,11 +417,7 @@ func (tx *Transaction) Size() uint64 {
return size.(uint64) return size.(uint64)
} }
c := writeCounter(0) c := writeCounter(0)
if tx.Type() == BlobTxType { rlp.Encode(&c, &tx.inner)
rlp.Encode(&c, &tx.inner) // TODO(karalabe): Replace with SSZ encoding
} else {
rlp.Encode(&c, &tx.inner)
}
size := uint64(c) size := uint64(c)
if tx.Type() != LegacyTxType { if tx.Type() != LegacyTxType {
......
This diff is collapsed.
...@@ -29,8 +29,8 @@ type AccessList []AccessTuple ...@@ -29,8 +29,8 @@ type AccessList []AccessTuple
// AccessTuple is the element type of an access list. // AccessTuple is the element type of an access list.
type AccessTuple struct { type AccessTuple struct {
Address common.Address `json:"address" gencodec:"required"` Address common.Address `json:"address" gencodec:"required"`
StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"` StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"`
} }
// StorageKeys returns the total number of storage keys in the access list. // StorageKeys returns the total number of storage keys in the access list.
......
...@@ -31,7 +31,7 @@ type BlobTx struct { ...@@ -31,7 +31,7 @@ type BlobTx struct {
GasTipCap *uint256.Int // a.k.a. maxPriorityFeePerGas GasTipCap *uint256.Int // a.k.a. maxPriorityFeePerGas
GasFeeCap *uint256.Int // a.k.a. maxFeePerGas GasFeeCap *uint256.Int // a.k.a. maxFeePerGas
Gas uint64 Gas uint64
To *common.Address // `rlp:"nil"` // nil means contract creation To *common.Address `rlp:"nil"` // nil means contract creation
Value *uint256.Int Value *uint256.Int
Data []byte Data []byte
AccessList AccessList AccessList AccessList
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment