github.com/hardtosaygoodbye/go-ethereum@v1.10.16-0.20220122011429-97003b9e6c15/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 "fmt" 21 "math/big" 22 23 "github.com/hardtosaygoodbye/go-ethereum/common" 24 "github.com/hardtosaygoodbye/go-ethereum/common/hexutil" 25 ) 26 27 //go:generate go run github.com/fjl/gencodec -type PayloadAttributesV1 -field-override payloadAttributesMarshaling -out gen_blockparams.go 28 29 // Structure described at https://github.com/ethereum/execution-apis/pull/74 30 type PayloadAttributesV1 struct { 31 Timestamp uint64 `json:"timestamp" gencodec:"required"` 32 Random common.Hash `json:"random" gencodec:"required"` 33 SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"` 34 } 35 36 // JSON type overrides for PayloadAttributesV1. 37 type payloadAttributesMarshaling struct { 38 Timestamp hexutil.Uint64 39 } 40 41 //go:generate go run github.com/fjl/gencodec -type ExecutableDataV1 -field-override executableDataMarshaling -out gen_ed.go 42 43 // Structure described at https://github.com/ethereum/execution-apis/src/engine/specification.md 44 type ExecutableDataV1 struct { 45 ParentHash common.Hash `json:"parentHash" gencodec:"required"` 46 FeeRecipient common.Address `json:"feeRecipient" gencodec:"required"` 47 StateRoot common.Hash `json:"stateRoot" gencodec:"required"` 48 ReceiptsRoot common.Hash `json:"receiptsRoot" gencodec:"required"` 49 LogsBloom []byte `json:"logsBloom" gencodec:"required"` 50 Random common.Hash `json:"random" gencodec:"required"` 51 Number uint64 `json:"blockNumber" gencodec:"required"` 52 GasLimit uint64 `json:"gasLimit" gencodec:"required"` 53 GasUsed uint64 `json:"gasUsed" gencodec:"required"` 54 Timestamp uint64 `json:"timestamp" gencodec:"required"` 55 ExtraData []byte `json:"extraData" gencodec:"required"` 56 BaseFeePerGas *big.Int `json:"baseFeePerGas" gencodec:"required"` 57 BlockHash common.Hash `json:"blockHash" gencodec:"required"` 58 Transactions [][]byte `json:"transactions" gencodec:"required"` 59 } 60 61 // JSON type overrides for executableData. 62 type executableDataMarshaling struct { 63 Number hexutil.Uint64 64 GasLimit hexutil.Uint64 65 GasUsed hexutil.Uint64 66 Timestamp hexutil.Uint64 67 BaseFeePerGas *hexutil.Big 68 ExtraData hexutil.Bytes 69 LogsBloom hexutil.Bytes 70 Transactions []hexutil.Bytes 71 } 72 73 type NewBlockResponse struct { 74 Valid bool `json:"valid"` 75 } 76 77 type GenericResponse struct { 78 Success bool `json:"success"` 79 } 80 81 type GenericStringResponse struct { 82 Status string `json:"status"` 83 } 84 85 type ExecutePayloadResponse struct { 86 Status string `json:"status"` 87 LatestValidHash common.Hash `json:"latestValidHash"` 88 } 89 90 type ConsensusValidatedParams struct { 91 BlockHash common.Hash `json:"blockHash"` 92 Status string `json:"status"` 93 } 94 95 // PayloadID is an identifier of the payload build process 96 type PayloadID [8]byte 97 98 func (b PayloadID) String() string { 99 return hexutil.Encode(b[:]) 100 } 101 102 func (b PayloadID) MarshalText() ([]byte, error) { 103 return hexutil.Bytes(b[:]).MarshalText() 104 } 105 106 func (b *PayloadID) UnmarshalText(input []byte) error { 107 err := hexutil.UnmarshalFixedText("PayloadID", input, b[:]) 108 if err != nil { 109 return fmt.Errorf("invalid payload id %q: %w", input, err) 110 } 111 return nil 112 } 113 114 type ForkChoiceResponse struct { 115 Status string `json:"status"` 116 PayloadID *PayloadID `json:"payloadId"` 117 } 118 119 type ForkchoiceStateV1 struct { 120 HeadBlockHash common.Hash `json:"headBlockHash"` 121 SafeBlockHash common.Hash `json:"safeBlockHash"` 122 FinalizedBlockHash common.Hash `json:"finalizedBlockHash"` 123 }