Skip to content

Commit

Permalink
Fix init cmd aura seal signature import (#12844)
Browse files Browse the repository at this point in the history
Accommodate the genesis file format specifying aura seal, like so:
```
  "seal": {
    "authorityRound": {
      "step": 0,
      "signature": "0x00"
    }
  }
```
With this change gnosis devnets can directly be started with the `init`
command
  • Loading branch information
somnathb1 authored Nov 22, 2024
1 parent 0273320 commit c5d69cb
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 14 deletions.
10 changes: 6 additions & 4 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func GnosisGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.GnosisChainConfig,
Timestamp: 0,
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
AuRaSeal: types.NewAuraSeal(0, common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")),
GasLimit: 0x989680,
Difficulty: big.NewInt(0x20000),
Alloc: readPrealloc("allocs/gnosis.json"),
Expand All @@ -450,7 +450,7 @@ func ChiadoGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.ChiadoChainConfig,
Timestamp: 0,
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
AuRaSeal: types.NewAuraSeal(0, common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")),
GasLimit: 0x989680,
Difficulty: big.NewInt(0x20000),
Alloc: readPrealloc("allocs/chiado.json"),
Expand Down Expand Up @@ -506,10 +506,12 @@ func GenesisToBlock(g *types.Genesis, tmpDir string, logger log.Logger) (*types.
BaseFee: g.BaseFee,
BlobGasUsed: g.BlobGasUsed,
ExcessBlobGas: g.ExcessBlobGas,
AuRaStep: g.AuRaStep,
AuRaSeal: g.AuRaSeal,
RequestsHash: g.RequestsHash,
}
if g.AuRaSeal != nil && len(g.AuRaSeal.AuthorityRound.Signature) > 0 {
head.AuRaSeal = g.AuRaSeal.AuthorityRound.Signature
head.AuRaStep = uint64(g.AuRaSeal.AuthorityRound.Step)
}
if g.GasLimit == 0 {
head.GasLimit = params.GenesisGasLimit
}
Expand Down
41 changes: 41 additions & 0 deletions core/types/gen_aura_seal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 2 additions & 8 deletions core/types/gen_genesis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions core/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (

//go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go
//go:generate gencodec -type GenesisAccount -field-override genesisAccountMarshaling -out gen_genesis_account.go
//go:generate gencodec -type AuRaSeal -out gen_aura_seal.go

var ErrGenesisNoConfig = errors.New("genesis has no chain configuration")

Expand All @@ -51,8 +52,7 @@ type Genesis struct {
Coinbase common.Address `json:"coinbase"`
Alloc GenesisAlloc `json:"alloc" gencodec:"required"`

AuRaStep uint64 `json:"auRaStep"`
AuRaSeal []byte `json:"auRaSeal"`
AuRaSeal *AuRaSeal `json:"seal"`

// These fields are used for consensus tests. Please don't use them
// in actual genesis blocks.
Expand All @@ -68,6 +68,20 @@ type Genesis struct {
RequestsHash *common.Hash `json:"requestsHash"` // EIP-7685
}

type AuRaSeal struct {
AuthorityRound struct {
Step math.HexOrDecimal64 `json:"step"`
Signature hexutility.Bytes `json:"signature"`
} `json:"authorityRound"`
}

func NewAuraSeal(step uint64, signature []byte) *AuRaSeal {
a := AuRaSeal{}
a.AuthorityRound.Step = math.HexOrDecimal64(step)
a.AuthorityRound.Signature = append([]byte{}, signature...)
return &a
}

// GenesisAlloc specifies the initial state that is part of the genesis block.
type GenesisAlloc map[common.Address]GenesisAccount

Expand Down

0 comments on commit c5d69cb

Please sign in to comment.