beacon/engine, eth/catalyst, miner: use primitive type instead of new structures
This commit is contained in:
parent
0858a85bca
commit
bbdaa45719
|
@ -132,14 +132,6 @@ type executionPayloadEnvelopeMarshaling struct {
|
|||
// Max size of inclusion list in bytes.
|
||||
const MaxBytesPerInclusionList = uint64(8192)
|
||||
|
||||
type InclusionListV1 struct {
|
||||
Transactions [][]byte `json:"transactions" gencodec:"required"`
|
||||
}
|
||||
|
||||
type UpdateInclusionListResponse struct {
|
||||
PayloadID *PayloadID `json:"payloadId"`
|
||||
}
|
||||
|
||||
type PayloadStatusV1 struct {
|
||||
Status string `json:"status"`
|
||||
Witness *hexutil.Bytes `json:"witness"`
|
||||
|
@ -355,8 +347,8 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
|
|||
}
|
||||
}
|
||||
|
||||
func InclusionListToTransactions(inclusionList *InclusionListV1) ([]*types.Transaction, error) {
|
||||
txs, err := decodeTransactions(inclusionList.Transactions)
|
||||
func InclusionListToTransactions(inclusionList [][]byte) ([]*types.Transaction, error) {
|
||||
txs, err := decodeTransactions(inclusionList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -364,10 +356,8 @@ func InclusionListToTransactions(inclusionList *InclusionListV1) ([]*types.Trans
|
|||
return txs, nil
|
||||
}
|
||||
|
||||
func TransactionsToInclusionList(txs []*types.Transaction) *InclusionListV1 {
|
||||
return &InclusionListV1{
|
||||
Transactions: encodeTransactions(txs),
|
||||
}
|
||||
func TransactionsToInclusionList(txs []*types.Transaction) [][]byte {
|
||||
return encodeTransactions(txs)
|
||||
}
|
||||
|
||||
// ExecutionPayloadBody is used in the response to GetPayloadBodiesByHash and GetPayloadBodiesByRange
|
||||
|
|
|
@ -562,7 +562,7 @@ func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
return res, nil
|
||||
}
|
||||
|
||||
func (api *ConsensusAPI) GetInclusionListV1(parentHash common.Hash) (*engine.InclusionListV1, error) {
|
||||
func (api *ConsensusAPI) GetInclusionListV1(parentHash common.Hash) ([][]byte, error) {
|
||||
if inclusionList := api.localInclusionLists.get(parentHash); inclusionList != nil {
|
||||
return inclusionList, nil
|
||||
}
|
||||
|
@ -581,26 +581,20 @@ func (api *ConsensusAPI) GetInclusionListV1(parentHash common.Hash) (*engine.Inc
|
|||
return inclusionList, nil
|
||||
}
|
||||
|
||||
func (api *ConsensusAPI) UpdatePayloadWithInclusionListV1(payloadID engine.PayloadID, inclusionList engine.InclusionListV1) (engine.UpdateInclusionListResponse, error) {
|
||||
response := func(id *engine.PayloadID) engine.UpdateInclusionListResponse {
|
||||
return engine.UpdateInclusionListResponse{
|
||||
PayloadID: id,
|
||||
}
|
||||
}
|
||||
|
||||
func (api *ConsensusAPI) UpdatePayloadWithInclusionListV1(payloadID engine.PayloadID, inclusionList [][]byte) (*engine.PayloadID, error) {
|
||||
payload := api.localBlocks.peak(payloadID)
|
||||
if payload == nil {
|
||||
return engine.UpdateInclusionListResponse{PayloadID: nil}, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
inclusionListTxs, err := engine.InclusionListToTransactions(&inclusionList)
|
||||
inclusionListTxs, err := engine.InclusionListToTransactions(inclusionList)
|
||||
if err != nil {
|
||||
return engine.UpdateInclusionListResponse{PayloadID: nil}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
payload.UpdateWithInclusionList(inclusionListTxs)
|
||||
|
||||
return response(&payloadID), nil
|
||||
return &payloadID, nil
|
||||
}
|
||||
|
||||
// NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
|
||||
|
@ -692,7 +686,7 @@ func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHas
|
|||
}
|
||||
|
||||
// NewPayloadV5 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
|
||||
func (api *ConsensusAPI) NewPayloadV5(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, executionRequests []hexutil.Bytes, inclusionList *engine.InclusionListV1) (engine.PayloadStatusV1, error) {
|
||||
func (api *ConsensusAPI) NewPayloadV5(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, executionRequests []hexutil.Bytes, inclusionList [][]byte) (engine.PayloadStatusV1, error) {
|
||||
if params.Withdrawals == nil {
|
||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai"))
|
||||
}
|
||||
|
@ -814,7 +808,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, v
|
|||
|
||||
// NewPayloadWithWitnessV5 is analogous to NewPayloadV5, only it also generates
|
||||
// and returns a stateless witness after running the payload.
|
||||
func (api *ConsensusAPI) NewPayloadWithWitnessV5(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, executionRequests []hexutil.Bytes, inclusionList *engine.InclusionListV1) (engine.PayloadStatusV1, error) {
|
||||
func (api *ConsensusAPI) NewPayloadWithWitnessV5(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, executionRequests []hexutil.Bytes, inclusionList [][]byte) (engine.PayloadStatusV1, error) {
|
||||
if params.Withdrawals == nil {
|
||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai"))
|
||||
}
|
||||
|
@ -934,7 +928,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData,
|
|||
return api.executeStatelessPayload(params, versionedHashes, beaconRoot, requests, opaqueWitness)
|
||||
}
|
||||
|
||||
func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, inclusionList *engine.InclusionListV1, witness bool) (engine.PayloadStatusV1, error) {
|
||||
func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, inclusionList [][]byte, witness bool) (engine.PayloadStatusV1, error) {
|
||||
// The locking here is, strictly, not required. Without these locks, this can happen:
|
||||
//
|
||||
// 1. NewPayload( execdata-N ) is invoked from the CL. It goes all the way down to
|
||||
|
|
|
@ -1869,7 +1869,7 @@ func TestInclusionList(t *testing.T) {
|
|||
|
||||
for i, tt := range []*struct {
|
||||
name string
|
||||
inclusionList *engine.InclusionListV1
|
||||
inclusionList [][]byte
|
||||
updateInclusionList bool
|
||||
expectedTransactions int
|
||||
expectedStatus string
|
||||
|
@ -1934,7 +1934,7 @@ func TestInclusionList(t *testing.T) {
|
|||
|
||||
if tt.updateInclusionList {
|
||||
// Update the payload with the inclusion list.
|
||||
api.UpdatePayloadWithInclusionListV1(*resp.PayloadID, *tt.inclusionList)
|
||||
api.UpdatePayloadWithInclusionListV1(*resp.PayloadID, tt.inclusionList)
|
||||
}
|
||||
|
||||
// Get the payload.
|
||||
|
|
|
@ -181,7 +181,7 @@ func (q *headerQueue) get(hash common.Hash) *types.Header {
|
|||
// or evicted.
|
||||
type inclusionListQueueItem struct {
|
||||
parentHash common.Hash
|
||||
inclusionList *engine.InclusionListV1
|
||||
inclusionList [][]byte
|
||||
}
|
||||
|
||||
// inclusionListQueue tracks the latest handful of constructed inclusion lists to be retrieved
|
||||
|
@ -201,7 +201,7 @@ func newInclusionListQueue() *inclusionListQueue {
|
|||
|
||||
// put inserts a new inclusion list into the queue at the given parent hash that
|
||||
// the inclusion list is built upon.
|
||||
func (q *inclusionListQueue) put(parentHash common.Hash, inclusionList *engine.InclusionListV1) {
|
||||
func (q *inclusionListQueue) put(parentHash common.Hash, inclusionList [][]byte) {
|
||||
q.lock.Lock()
|
||||
defer q.lock.Unlock()
|
||||
|
||||
|
@ -213,7 +213,7 @@ func (q *inclusionListQueue) put(parentHash common.Hash, inclusionList *engine.I
|
|||
}
|
||||
|
||||
// get retrieves a previously stored inclusion list item or nil if it does not exist.
|
||||
func (q *inclusionListQueue) get(parentHash common.Hash) *engine.InclusionListV1 {
|
||||
func (q *inclusionListQueue) get(parentHash common.Hash) [][]byte {
|
||||
q.lock.RLock()
|
||||
defer q.lock.RUnlock()
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ type BuildInclusionListArgs struct {
|
|||
Parent common.Hash // The parent block to build inclusion list on top
|
||||
}
|
||||
|
||||
func (miner *Miner) BuildInclusionList(args *BuildInclusionListArgs) (*engine.InclusionListV1, error) {
|
||||
func (miner *Miner) BuildInclusionList(args *BuildInclusionListArgs) ([][]byte, error) {
|
||||
params := &generateParams{
|
||||
timestamp: uint64(time.Now().Unix()),
|
||||
forceTime: false,
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestBuildInclusionList(t *testing.T) {
|
|||
|
||||
// Verify inclusion list size.
|
||||
inclusionListSize := uint64(0)
|
||||
for _, tx := range inclusionList.Transactions {
|
||||
for _, tx := range inclusionList {
|
||||
inclusionListSize += uint64(len(tx))
|
||||
}
|
||||
require.LessOrEqual(t, inclusionListSize, engine.MaxBytesPerInclusionList)
|
||||
|
|
Loading…
Reference in New Issue