github.com/LampardNguyen234/go-ethereum@v1.10.16-0.20220117140830-b6a3b0260724/eth/catalyst/api_types.go (about)

     1  // Copyright 2020 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package catalyst
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/LampardNguyen234/go-ethereum/common"
    23  	"github.com/LampardNguyen234/go-ethereum/common/hexutil"
    24  )
    25  
    26  //go:generate go run github.com/fjl/gencodec -type PayloadAttributesV1 -field-override payloadAttributesMarshaling -out gen_blockparams.go
    27  
    28  // Structure described at https://github.com/ethereum/execution-apis/pull/74
    29  type PayloadAttributesV1 struct {
    30  	Timestamp             uint64         `json:"timestamp"     gencodec:"required"`
    31  	Random                common.Hash    `json:"random"        gencodec:"required"`
    32  	SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient"  gencodec:"required"`
    33  }
    34  
    35  // JSON type overrides for PayloadAttributesV1.
    36  type payloadAttributesMarshaling struct {
    37  	Timestamp hexutil.Uint64
    38  }
    39  
    40  //go:generate go run github.com/fjl/gencodec -type ExecutableDataV1 -field-override executableDataMarshaling -out gen_ed.go
    41  
    42  // Structure described at https://github.com/ethereum/execution-apis/src/engine/specification.md
    43  type ExecutableDataV1 struct {
    44  	ParentHash    common.Hash    `json:"parentHash"    gencodec:"required"`
    45  	FeeRecipient  common.Address `json:"feeRecipient"  gencodec:"required"`
    46  	StateRoot     common.Hash    `json:"stateRoot"     gencodec:"required"`
    47  	ReceiptsRoot  common.Hash    `json:"receiptsRoot"   gencodec:"required"`
    48  	LogsBloom     []byte         `json:"logsBloom"     gencodec:"required"`
    49  	Random        common.Hash    `json:"random"        gencodec:"required"`
    50  	Number        uint64         `json:"blockNumber"   gencodec:"required"`
    51  	GasLimit      uint64         `json:"gasLimit"      gencodec:"required"`
    52  	GasUsed       uint64         `json:"gasUsed"       gencodec:"required"`
    53  	Timestamp     uint64         `json:"timestamp"     gencodec:"required"`
    54  	ExtraData     []byte         `json:"extraData"     gencodec:"required"`
    55  	BaseFeePerGas *big.Int       `json:"baseFeePerGas" gencodec:"required"`
    56  	BlockHash     common.Hash    `json:"blockHash"     gencodec:"required"`
    57  	Transactions  [][]byte       `json:"transactions"  gencodec:"required"`
    58  }
    59  
    60  // JSON type overrides for executableData.
    61  type executableDataMarshaling struct {
    62  	Number        hexutil.Uint64
    63  	GasLimit      hexutil.Uint64
    64  	GasUsed       hexutil.Uint64
    65  	Timestamp     hexutil.Uint64
    66  	BaseFeePerGas *hexutil.Big
    67  	ExtraData     hexutil.Bytes
    68  	LogsBloom     hexutil.Bytes
    69  	Transactions  []hexutil.Bytes
    70  }
    71  
    72  //go:generate go run github.com/fjl/gencodec -type PayloadResponse -field-override payloadResponseMarshaling -out gen_payload.go
    73  
    74  type PayloadResponse struct {
    75  	PayloadID uint64 `json:"payloadId"`
    76  }
    77  
    78  // JSON type overrides for payloadResponse.
    79  type payloadResponseMarshaling struct {
    80  	PayloadID hexutil.Uint64
    81  }
    82  
    83  type NewBlockResponse struct {
    84  	Valid bool `json:"valid"`
    85  }
    86  
    87  type GenericResponse struct {
    88  	Success bool `json:"success"`
    89  }
    90  
    91  type GenericStringResponse struct {
    92  	Status string `json:"status"`
    93  }
    94  
    95  type ExecutePayloadResponse struct {
    96  	Status          string      `json:"status"`
    97  	LatestValidHash common.Hash `json:"latestValidHash"`
    98  }
    99  
   100  type ConsensusValidatedParams struct {
   101  	BlockHash common.Hash `json:"blockHash"`
   102  	Status    string      `json:"status"`
   103  }
   104  
   105  type ForkChoiceResponse struct {
   106  	Status    string         `json:"status"`
   107  	PayloadID *hexutil.Bytes `json:"payloadId"`
   108  }
   109  
   110  type ForkchoiceStateV1 struct {
   111  	HeadBlockHash      common.Hash `json:"headBlockHash"`
   112  	SafeBlockHash      common.Hash `json:"safeBlockHash"`
   113  	FinalizedBlockHash common.Hash `json:"finalizedBlockHash"`
   114  }