Skip to content

Commit 3ae30e3

Browse files
committed
chore: Adjust the stability window
1 parent 44b7d6f commit 3ae30e3

File tree

5 files changed

+51
-11
lines changed

5 files changed

+51
-11
lines changed

applications/cli/config/node.properties

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#protocolMagic=42
22
#maxKESEvolutions=60
3-
#securityParam=300
3+
#securityParam=80
44
#slotsPerKESPeriod=129600
55
#updateQuorum=1
66
#peerSharing=true
@@ -79,3 +79,21 @@
7979
## CC Members
8080
#ccMembers[0].hash=scriptHash-8fc13431159fdda66347a38c55105d50d77d67abc1c368b876d52ad1
8181
#ccMembers[0].term=340
82+
83+
########################################################################################################
84+
# Workaround for : https://github.com/bloxbean/yaci-devkit/issues/65
85+
#
86+
# The following parameters are enabled for a V2 cost model-related issue where there are 10 extra elements if the devnet
87+
# is started with the Conway era at epoch 0. The following parameters are enabled to configure the Conway era hard fork (HF) at epoch 1.
88+
# The network will start in the Babbage era and then hard fork (HF) to the Conway era at epoch 1.
89+
90+
# The shiftStartTimeBehind=true flag is enabled to shift the start time of the network to a time behind the current time by adjusting security parameter
91+
# which changes the stability window. This is to speed up the process of reaching the Conway era.
92+
#
93+
# This should only be done in a development environment because if the stability window is larger than the epoch length, the reward/treasury calculations will be incorrect or ignored.
94+
# Therefore, for a real multi-node network, you should start the network at the current time and allow it to reach the Conway era at epoch 1.
95+
# So, the shiftStartTimeBehind flag should be "false" for non-development / multi-node networks.
96+
#
97+
#########################################################################################################
98+
conwayHardForkAtEpoch=1
99+
shiftStartTimeBehind=true

applications/cli/src/main/java/com/bloxbean/cardano/yacicli/localcluster/ClusterService.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,17 @@ private void updateGenesis(Path clusterFolder, String clusterName, ClusterInfo c
321321

322322
//Derive security param
323323
long securityParam = genesisConfigCopy.getSecurityParam();
324-
if (securityParam == 0) {
325-
//For stabilityWindow = epochLength * stabilityWindowFactory (0-1) , k = (epochLength * coefficient) / (3 * 2)
326-
securityParam = Math.round(((epochLength * activeSlotsCoeff) / 3) * genesisConfig.getStabilityWindowFactor());
324+
325+
if (genesisConfig.getConwayHardForkAtEpoch() > 0 && genesisConfig.isShiftStartTimeBehind()) {
326+
//Workaround for https://github.com/bloxbean/yaci-devkit/issues/65
327+
//Calculate required securityParam to jump directly to epoch = 1
328+
long expectedStabilityWindow = Math.round(epochLength * 1.5);
329+
securityParam = Math.round(expectedStabilityWindow * activeSlotsCoeff) / 3;
330+
} else {
331+
if (securityParam == 0) {
332+
//For stabilityWindow = epochLength * stabilityWindowFactory (0-1) , k = (epochLength * coefficient) / (3 * 2)
333+
securityParam = Math.round(((epochLength * activeSlotsCoeff) / 3) * genesisConfig.getStabilityWindowFactor());
334+
}
327335
}
328336

329337
values.put("securityParam", securityParam);

applications/cli/src/main/java/com/bloxbean/cardano/yacicli/localcluster/ClusterStartService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,8 @@ private boolean setupFirstRun(ClusterInfo clusterInfo, Path clusterFolder, Consu
262262
maxBehindBySecond = clusterInfo.getEpochLength();
263263
}
264264

265-
long shiftTimeBehindSeconds = genesisConfig.getShiftStartTimeBehindBySecs() > 0 ? genesisConfig.getShiftStartTimeBehindBySecs() : maxBehindBySecond;
266-
byronStartTime = byronStartTime - shiftTimeBehindSeconds;
267-
writer.accept(success("Updating Start time to current time - " + shiftTimeBehindSeconds + " in byron-genesis.json"));
265+
byronStartTime = byronStartTime - maxBehindBySecond;
266+
writer.accept(success("Updating Start time to current time - " + maxBehindBySecond + " in byron-genesis.json"));
268267
}
269268
jsonNode.set("startTime", new LongNode(byronStartTime));
270269
objectMapper.writer(new DefaultPrettyPrinter()).writeValue(byronGenesis.toFile(), jsonNode);

applications/cli/src/main/java/com/bloxbean/cardano/yacicli/localcluster/config/GenesisConfig.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ public class GenesisConfig {
162162
//Introduced for the issue https://github.com/bloxbean/yaci-devkit/issues/65
163163
private int conwayHardForkAtEpoch = 0;
164164
private boolean shiftStartTimeBehind = false;
165-
private int shiftStartTimeBehindBySecs = 0; //By default, it will be epochLength
166165

167166
@PostConstruct
168167
public void postInit() {
@@ -347,7 +346,6 @@ public Map getConfigMap() {
347346

348347
map.put("conwayHardForkAtEpoch", conwayHardForkAtEpoch);
349348
map.put("shiftStartTimeBehind", shiftStartTimeBehind);
350-
map.put("shiftStartTimeBehindBySecs", shiftStartTimeBehindBySecs);
351349

352350
return map;
353351
}
@@ -438,7 +436,6 @@ public GenesisConfig copy() {
438436

439437
genesisConfig.setConwayHardForkAtEpoch(conwayHardForkAtEpoch);
440438
genesisConfig.setShiftStartTimeBehind(shiftStartTimeBehind);
441-
genesisConfig.setShiftStartTimeBehindBySecs(shiftStartTimeBehindBySecs);
442439

443440
return genesisConfig;
444441
}

config/node.properties

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#################################################################################################################
77

88
#maxKESEvolutions=60
9-
#securityParam=300
9+
#securityParam=80
1010
#slotsPerKESPeriod=129600
1111
#updateQuorum=1
1212
#peerSharing=true
@@ -85,3 +85,21 @@
8585
## CC Members
8686
#ccMembers[0].hash=scriptHash-8fc13431159fdda66347a38c55105d50d77d67abc1c368b876d52ad1
8787
#ccMembers[0].term=340
88+
89+
########################################################################################################
90+
# Workaround for : https://github.com/bloxbean/yaci-devkit/issues/65
91+
#
92+
# The following parameters are enabled for a V2 cost model-related issue where there are 10 extra elements if the devnet
93+
# is started with the Conway era at epoch 0. The following parameters are enabled to configure the Conway era hard fork (HF) at epoch 1.
94+
# The network will start in the Babbage era and then hard fork (HF) to the Conway era at epoch 1.
95+
96+
# The shiftStartTimeBehind=true flag is enabled to shift the start time of the network to a time behind the current time by adjusting security parameter
97+
# which changes the stability window. This is to speed up the process of reaching the Conway era.
98+
#
99+
# This should only be done in a development environment because if the stability window is larger than the epoch length, the reward/treasury calculations will be incorrect or ignored.
100+
# Therefore, for a real multi-node network, you should start the network at the current time and allow it to reach the Conway era at epoch 1.
101+
# So, the shiftStartTimeBehind flag should be "false" for non-development / multi-node networks.
102+
#
103+
#########################################################################################################
104+
conwayHardForkAtEpoch=1
105+
shiftStartTimeBehind=true

0 commit comments

Comments
 (0)