Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit c58790e

Browse files
committed
Added TargetCommitteeSize and SlotsPerEpochExponent to presets_yaml.go
1 parent 33d12ea commit c58790e

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

tools/genesis-snapshot/presets/presets_yaml.go

+18-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"golang.org/x/crypto/blake2b"
88

99
"github.com/iotaledger/hive.go/crypto/ed25519"
10+
"github.com/iotaledger/hive.go/ierrors"
1011
"github.com/iotaledger/hive.go/lo"
1112
"github.com/iotaledger/hive.go/runtime/ioutils"
1213
"github.com/iotaledger/hive.go/runtime/options"
@@ -41,8 +42,10 @@ type BasicOutputYaml struct {
4142
}
4243

4344
type ConfigYaml struct {
44-
NetworkName string `yaml:"networkName"`
45-
Bech32HRP string `yaml:"bech32Hrp"`
45+
NetworkName string `yaml:"networkName"`
46+
Bech32HRP string `yaml:"bech32Hrp"`
47+
TargetCommitteeSize uint8 `yaml:"targetCommitteeSize"`
48+
SlotsPerEpochExponent uint8 `yaml:"slotsPerEpochExponent"`
4649

4750
FilePath string `yaml:"filepath"`
4851

@@ -51,19 +54,19 @@ type ConfigYaml struct {
5154
BasicOutputs []BasicOutputYaml `yaml:"basicOutputs"`
5255
}
5356

54-
func TestnetProtocolParameters(networkName string, bech32HRP iotago.NetworkPrefix) iotago.ProtocolParameters {
57+
func TestnetProtocolParameters(networkName string, bech32HRP iotago.NetworkPrefix, targetCommitteeSize uint8, slotsPerEpochExponent uint8) iotago.ProtocolParameters {
5558
return iotago.NewV3SnapshotProtocolParameters(
5659
iotago.WithNetworkOptions(networkName, bech32HRP),
5760
iotago.WithStorageOptions(100, 1, 100, 1000, 1000, 1000),
5861
iotago.WithWorkScoreOptions(500, 110_000, 7_500, 40_000, 90_000, 50_000, 40_000, 70_000, 5_000, 15_000),
59-
iotago.WithTimeProviderOptions(0, time.Now().Unix(), 10, 8),
62+
iotago.WithTimeProviderOptions(0, time.Now().Unix(), 10, slotsPerEpochExponent),
6063
iotago.WithLivenessOptions(10, 15, 4, 7, 100),
6164
iotago.WithSupplyOptions(4600000000000000, 63, 1, 17, 32, 21, 70),
6265
iotago.WithCongestionControlOptions(1, 1, 1, 400_000_000, 250_000_000, 50_000_000, 1000, 100),
6366
iotago.WithStakingOptions(3, 10, 10),
6467
iotago.WithVersionSignalingOptions(7, 5, 7),
6568
iotago.WithRewardsOptions(8, 11, 2, 384),
66-
iotago.WithTargetCommitteeSize(16),
69+
iotago.WithTargetCommitteeSize(targetCommitteeSize),
6770
iotago.WithChainSwitchingThreshold(10),
6871
)
6972
}
@@ -74,8 +77,16 @@ func GenerateFromYaml(hostsFile string) ([]options.Option[snapshotcreator.Option
7477
return nil, err
7578
}
7679

77-
fmt.Printf("generating protocol parameters for network %s with bech32HRP %s\n", configYaml.NetworkName, configYaml.Bech32HRP)
78-
protocolParams := TestnetProtocolParameters(configYaml.NetworkName, iotago.NetworkPrefix(configYaml.Bech32HRP))
80+
if configYaml.TargetCommitteeSize == 0 {
81+
return nil, ierrors.Errorf("targetCommitteeSize must be greater than 0")
82+
}
83+
84+
if configYaml.SlotsPerEpochExponent == 0 {
85+
return nil, ierrors.Errorf("slotsPerEpochExponent must be greater than 0")
86+
}
87+
88+
fmt.Printf("generating protocol parameters for network: %s, bech32HRP: %s, targetCommitteeSize: %d, slotsPerEpochExponent: %d\n", configYaml.NetworkName, configYaml.Bech32HRP, configYaml.TargetCommitteeSize, configYaml.SlotsPerEpochExponent)
89+
protocolParams := TestnetProtocolParameters(configYaml.NetworkName, iotago.NetworkPrefix(configYaml.Bech32HRP), configYaml.TargetCommitteeSize, configYaml.SlotsPerEpochExponent)
7990

8091
accounts := make([]snapshotcreator.AccountDetails, 0, len(configYaml.Validators)+len(configYaml.BlockIssuers))
8192
for _, validator := range configYaml.Validators {

0 commit comments

Comments
 (0)