github.com/kotalco/kotal@v0.3.0/apis/ethereum/v1alpha1/genesis.go (about)

     1  package v1alpha1
     2  
     3  import "github.com/kotalco/kotal/apis/shared"
     4  
     5  // Genesis is genesis block sepcficition
     6  type Genesis struct {
     7  	// Accounts is array of accounts to fund or associate with code and storage
     8  	Accounts []Account `json:"accounts,omitempty"`
     9  
    10  	// NetworkID is network id
    11  	NetworkID uint `json:"networkId"`
    12  
    13  	// ChainID is the the chain ID used in transaction signature to prevent reply attack
    14  	// more details https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
    15  	ChainID uint `json:"chainId"`
    16  
    17  	// Address to pay mining rewards to
    18  	Coinbase shared.EthereumAddress `json:"coinbase,omitempty"`
    19  
    20  	// Difficulty is the diffculty of the genesis block
    21  	Difficulty HexString `json:"difficulty,omitempty"`
    22  
    23  	// MixHash is hash combined with nonce to prove effort spent to create block
    24  	MixHash Hash `json:"mixHash,omitempty"`
    25  
    26  	// Ethash PoW engine configuration
    27  	Ethash *Ethash `json:"ethash,omitempty"`
    28  
    29  	// Clique PoA engine cinfiguration
    30  	Clique *Clique `json:"clique,omitempty"`
    31  
    32  	// IBFT2 PoA engine configuration
    33  	IBFT2 *IBFT2 `json:"ibft2,omitempty"`
    34  
    35  	// Forks is supported forks (network upgrade) and corresponding block number
    36  	Forks *Forks `json:"forks,omitempty"`
    37  
    38  	// GastLimit is the total gas limit for all transactions in a block
    39  	GasLimit HexString `json:"gasLimit,omitempty"`
    40  
    41  	// Nonce is random number used in block computation
    42  	Nonce HexString `json:"nonce,omitempty"`
    43  
    44  	// Timestamp is block creation date
    45  	Timestamp HexString `json:"timestamp,omitempty"`
    46  }
    47  
    48  // PoA is Shared PoA engine config
    49  type PoA struct {
    50  	// BlockPeriod is block time in seconds
    51  	BlockPeriod uint `json:"blockPeriod,omitempty"`
    52  
    53  	// EpochLength is the Number of blocks after which to reset all votes
    54  	EpochLength uint `json:"epochLength,omitempty"`
    55  }
    56  
    57  // IBFT2 configuration
    58  type IBFT2 struct {
    59  	PoA `json:",inline"`
    60  
    61  	// Validators are initial ibft2 validators
    62  	// +kubebuilder:validation:MinItems=1
    63  	Validators []shared.EthereumAddress `json:"validators,omitempty"`
    64  
    65  	// RequestTimeout is the timeout for each consensus round in seconds
    66  	RequestTimeout uint `json:"requestTimeout,omitempty"`
    67  
    68  	// MessageQueueLimit is the message queue limit
    69  	MessageQueueLimit uint `json:"messageQueueLimit,omitempty"`
    70  
    71  	// DuplicateMessageLimit is duplicate messages limit
    72  	DuplicateMessageLimit uint `json:"duplicateMessageLimit,omitempty"`
    73  
    74  	// futureMessagesLimit is future messages buffer limit
    75  	FutureMessagesLimit uint `json:"futureMessagesLimit,omitempty"`
    76  
    77  	// FutureMessagesMaxDistance is maximum height from current chain height for buffering future messages
    78  	FutureMessagesMaxDistance uint `json:"futureMessagesMaxDistance,omitempty"`
    79  }
    80  
    81  // Clique configuration
    82  type Clique struct {
    83  	PoA `json:",inline"`
    84  
    85  	// Signers are PoA initial signers, at least one signer is required
    86  	// +kubebuilder:validation:MinItems=1
    87  	Signers []shared.EthereumAddress `json:"signers,omitempty"`
    88  }
    89  
    90  // Ethash configurations
    91  type Ethash struct {
    92  	// FixedDifficulty is fixed difficulty to be used in private PoW networks
    93  	FixedDifficulty *uint `json:"fixedDifficulty,omitempty"`
    94  }
    95  
    96  // Forks is the supported forks by the network
    97  type Forks struct {
    98  	// Homestead fork
    99  	Homestead uint `json:"homestead,omitempty"`
   100  
   101  	// DAO fork
   102  	DAO *uint `json:"dao,omitempty"`
   103  
   104  	// EIP150 (Tangerine Whistle) fork
   105  	EIP150 uint `json:"eip150,omitempty"`
   106  
   107  	// EIP155 (Spurious Dragon) fork
   108  	EIP155 uint `json:"eip155,omitempty"`
   109  
   110  	// EIP158 (state trie clearing) fork
   111  	EIP158 uint `json:"eip158,omitempty"`
   112  
   113  	// Byzantium fork
   114  	Byzantium uint `json:"byzantium,omitempty"`
   115  
   116  	// Constantinople fork
   117  	Constantinople uint `json:"constantinople,omitempty"`
   118  
   119  	// Petersburg fork
   120  	Petersburg uint `json:"petersburg,omitempty"`
   121  
   122  	// Istanbul fork
   123  	Istanbul uint `json:"istanbul,omitempty"`
   124  
   125  	// MuirGlacier fork
   126  	MuirGlacier uint `json:"muirglacier,omitempty"`
   127  
   128  	// Berlin fork
   129  	Berlin uint `json:"berlin,omitempty"`
   130  
   131  	// London fork
   132  	London uint `json:"london,omitempty"`
   133  
   134  	// ArrowGlacier fork
   135  	ArrowGlacier uint `json:"arrowGlacier,omitempty"`
   136  }
   137  
   138  // Account is Ethereum account
   139  type Account struct {
   140  	// Address is account address
   141  	Address shared.EthereumAddress `json:"address"`
   142  
   143  	// Balance is account balance in wei
   144  	Balance HexString `json:"balance,omitempty"`
   145  
   146  	// Code is account contract byte code
   147  	Code HexString `json:"code,omitempty"`
   148  
   149  	// Storage is account contract storage as key value pair
   150  	Storage map[HexString]HexString `json:"storage,omitempty"`
   151  }