beacon/engine: add `InclusionList` type

This commit is contained in:
Jihoon Song 2025-02-07 21:20:17 +09:00
parent fc12dbe40b
commit 6e69743192
1 changed files with 30 additions and 0 deletions

View File

@ -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"