Die Bedeutung/Spezifikation von „config“ in genesis.json

Als ich versuchte, über Google zu suchen, gibt es einige genesis.json-Beispieldateien, um den Parameter des Genesis-Blocks in der privaten Blockchain von Ethereum anzupassen.

In der Datei gibt es einen Teil namens "config".

"config": {
    "chainId": 1,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
}

Was ist die Bedeutung oder Spezifikation für diese Parameter in "config"? Darf ich einen Teil der Parameter nur bei Bedarf einrichten?

Antworten (1)

Dies ist das Kettenkonfigurationsfeld, definiert in config.go:

// ChainConfig is the core config which determines the blockchain settings.
//
// ChainConfig is stored in the database on a per block basis. This means
// that any network, identified by its genesis block, can have its own
// set of configuration options.

Die verfügbaren Felder und ihre Beschreibungen sind unten aufgeführt:

type ChainConfig struct {
    ChainId *big.Int `json:"chainId"` // Chain id identifies the current chain and is used for replay protection

    HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
    DAOForkBlock   *big.Int `json:"daoForkBlock,omitempty"`   // TheDAO hard-fork switch block (nil = no fork)
    DAOForkSupport bool     `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork

    // EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
    EIP150Block *big.Int    `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
    EIP150Hash  common.Hash `json:"eip150Hash,omitempty"`  // EIP150 HF hash (fast sync aid)

    EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
    EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block

    // Various consensus engines
    Ethash *EthashConfig `json:"ethash,omitempty"`
    Clique *CliqueConfig `json:"clique,omitempty"`
}

Die Konfiguration für die Hauptkette sieht wie folgt aus (wieder in config.go ):

MainnetChainConfig = &ChainConfig{
    ChainId:        MainNetChainID,
    HomesteadBlock: MainNetHomesteadBlock,
    DAOForkBlock:   MainNetDAOForkBlock,
    DAOForkSupport: true,
    EIP150Block:    MainNetHomesteadGasRepriceBlock,
    EIP150Hash:     MainNetHomesteadGasRepriceHash,
    EIP155Block:    MainNetSpuriousDragon,
    EIP158Block:    MainNetSpuriousDragon,
    Ethash:         new(EthashConfig),

Mit den in definierten Istwerten util.go.


Also als Antwort auf deine Fragen...

"config": { "chainId": 1, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }

Was ist die Bedeutung oder Spezifikation für diese Parameter in "config"?

  • Chain id- identifiziert die aktuelle Kette und dient dem Replay-Schutz. Sie sollten es auf einen eindeutigen Wert für Ihre private Kette setzen.
  • homesteadBlock- Ihre Kette wird nicht auf Homestead umgestellt, also belassen Sie dies als 0.
  • eip155Block- Ihre Kette wird für diese Änderungen nicht hart forken, also lassen Sie es als 0.
  • eip158Block- Ihre Kette wird für diese Änderungen nicht hart forken, also lassen Sie es als 0.

Darf ich einen Teil der Parameter nur bei Bedarf einrichten?

Ja. Alle Werte, die eine Block- oder Hash-Nummer festlegen, können für eine private Kette ignoriert werden – sie sind nur für die öffentliche Hauptkette wirklich relevant.

Weitere Informationen zur Auswahl eines chainIdfür Ihre private Kette geeigneten finden Sie hier .
Danke für den Hinweis, @rustyx! :-) (Originalquelle der Liste, bevor sie hinzugefügt wurde, ist EIP-155: github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md )