mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
beacon/engine: encode/decode bals as hex for ExecutableData
This commit is contained in:
parent
36520d8199
commit
aac9c15b62
2 changed files with 70 additions and 51 deletions
|
|
@ -36,7 +36,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||||
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
||||||
BlockAccessList *bal.BlockAccessList `json:"blockAccessList,omitempty"`
|
BlockAccessList *hexBlockAccessList `json:"blockAccessList,omitempty"`
|
||||||
}
|
}
|
||||||
var enc ExecutableData
|
var enc ExecutableData
|
||||||
enc.ParentHash = e.ParentHash
|
enc.ParentHash = e.ParentHash
|
||||||
|
|
@ -62,7 +62,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
||||||
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
|
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
|
||||||
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
|
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
|
||||||
enc.SlotNumber = (*hexutil.Uint64)(e.SlotNumber)
|
enc.SlotNumber = (*hexutil.Uint64)(e.SlotNumber)
|
||||||
enc.BlockAccessList = e.BlockAccessList
|
enc.BlockAccessList = (*hexBlockAccessList)(e.BlockAccessList)
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||||
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
||||||
BlockAccessList *bal.BlockAccessList `json:"blockAccessList,omitempty"`
|
BlockAccessList *hexBlockAccessList `json:"blockAccessList,omitempty"`
|
||||||
}
|
}
|
||||||
var dec ExecutableData
|
var dec ExecutableData
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
|
@ -165,7 +165,7 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
||||||
e.SlotNumber = (*uint64)(dec.SlotNumber)
|
e.SlotNumber = (*uint64)(dec.SlotNumber)
|
||||||
}
|
}
|
||||||
if dec.BlockAccessList != nil {
|
if dec.BlockAccessList != nil {
|
||||||
e.BlockAccessList = dec.BlockAccessList
|
e.BlockAccessList = (*bal.BlockAccessList)(dec.BlockAccessList)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@
|
||||||
package engine
|
package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"math/big"
|
"math/big"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
|
|
@ -104,6 +106,22 @@ type ExecutableData struct {
|
||||||
BlockAccessList *bal.BlockAccessList `json:"blockAccessList,omitempty"`
|
BlockAccessList *bal.BlockAccessList `json:"blockAccessList,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type hexBlockAccessList bal.BlockAccessList
|
||||||
|
|
||||||
|
func (h *hexBlockAccessList) MarshalJSON() ([]byte, error) {
|
||||||
|
return rlp.EncodeToBytes(bal.BlockAccessList(*h))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *hexBlockAccessList) UnmarshalJSON(inp []byte) error {
|
||||||
|
if *h == nil {
|
||||||
|
*h = make(hexBlockAccessList, 0)
|
||||||
|
}
|
||||||
|
if err := rlp.Decode(bytes.NewReader(inp), *h); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// JSON type overrides for executableData.
|
// JSON type overrides for executableData.
|
||||||
type executableDataMarshaling struct {
|
type executableDataMarshaling struct {
|
||||||
Number hexutil.Uint64
|
Number hexutil.Uint64
|
||||||
|
|
@ -117,6 +135,7 @@ type executableDataMarshaling struct {
|
||||||
BlobGasUsed *hexutil.Uint64
|
BlobGasUsed *hexutil.Uint64
|
||||||
ExcessBlobGas *hexutil.Uint64
|
ExcessBlobGas *hexutil.Uint64
|
||||||
SlotNumber *hexutil.Uint64
|
SlotNumber *hexutil.Uint64
|
||||||
|
BlockAccessList *hexBlockAccessList
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatelessPayloadStatusV1 is the result of a stateless payload execution.
|
// StatelessPayloadStatusV1 is the result of a stateless payload execution.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue