From 6e697431925242931dde74bb064f9cae9c71f570 Mon Sep 17 00:00:00 2001 From: Jihoon Song Date: Fri, 7 Feb 2025 21:20:17 +0900 Subject: [PATCH] beacon/engine: add `InclusionList` type --- beacon/engine/types.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/beacon/engine/types.go b/beacon/engine/types.go index 984090ef89..e81acd4141 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -17,6 +17,7 @@ package engine import ( + "encoding/json" "fmt" "math/big" "slices" @@ -350,6 +351,35 @@ type ExecutionPayloadBody struct { Withdrawals []*types.Withdrawal `json:"withdrawals"` } +// Max size of inclusion list in bytes. +const MaxBytesPerInclusionList = uint64(8192) + +// InclusionList is a list of transactions that should be included in a payload. +type InclusionList [][]byte + +func (inclusionList InclusionList) MarshalJSON() ([]byte, error) { + inclusionListHex := make([]hexutil.Bytes, len(inclusionList)) + for i, tx := range inclusionList { + inclusionListHex[i] = tx + } + + return json.Marshal(inclusionListHex) +} + +func (inclusionList *InclusionList) UnmarshalJSON(input []byte) error { + var inclusionListHex []hexutil.Bytes + if err := json.Unmarshal(input, &inclusionListHex); err != nil { + return err + } + + *inclusionList = make([][]byte, len(inclusionListHex)) + for i, tx := range inclusionListHex { + (*inclusionList)[i] = tx + } + + return nil +} + // Client identifiers to support ClientVersionV1. const ( ClientCode = "GE"