Skip to content

Commit e8b0526

Browse files
committed
fix: slot length is a float
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent a6c4a3b commit e8b0526

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ledger/shelley/genesis.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ import (
1818
"encoding/hex"
1919
"encoding/json"
2020
"io"
21+
"math/big"
2122
"os"
2223
"time"
2324

@@ -35,7 +36,7 @@ type ShelleyGenesis struct {
3536
EpochLength int `json:"epochLength"`
3637
SlotsPerKESPeriod int `json:"slotsPerKESPeriod"`
3738
MaxKESEvolutions int `json:"maxKESEvolutions"`
38-
SlotLength int `json:"slotLength"`
39+
SlotLength common.GenesisRat `json:"slotLength"`
3940
UpdateQuorum int `json:"updateQuorum"`
4041
MaxLovelaceSupply uint64 `json:"maxLovelaceSupply"`
4142
ProtocolParameters ShelleyGenesisProtocolParams `json:"protocolParams"`
@@ -71,6 +72,7 @@ func (g ShelleyGenesis) MarshalCBOR() ([]byte, error) {
7172
map[any]any{},
7273
}
7374
}
75+
slotLengthMs := &big.Rat{}
7476
tmpData := []any{
7577
[]any{
7678
g.SystemStart.Year(),
@@ -87,7 +89,7 @@ func (g ShelleyGenesis) MarshalCBOR() ([]byte, error) {
8789
g.EpochLength,
8890
g.SlotsPerKESPeriod,
8991
g.MaxKESEvolutions,
90-
g.SlotLength * 1_000_000,
92+
slotLengthMs.Mul(g.SlotLength.Rat, big.NewRat(1_000_000, 1)),
9193
g.UpdateQuorum,
9294
g.MaxLovelaceSupply,
9395
g.ProtocolParameters,

ledger/shelley/genesis_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -117,7 +117,9 @@ var expectedGenesisObj = shelley.ShelleyGenesis{
117117
EpochLength: 432000,
118118
SlotsPerKESPeriod: 129600,
119119
MaxKESEvolutions: 62,
120-
SlotLength: 1,
120+
SlotLength: common.GenesisRat{
121+
Rat: big.NewRat(1, 1),
122+
},
121123
UpdateQuorum: 5,
122124
MaxLovelaceSupply: 45000000000000000,
123125
ProtocolParameters: shelley.ShelleyGenesisProtocolParams{

0 commit comments

Comments
 (0)