Skip to content

Commit

Permalink
chore: Adjust the stability window
Browse files Browse the repository at this point in the history
  • Loading branch information
satran004 committed Aug 29, 2024
1 parent 44b7d6f commit 3ae30e3
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
20 changes: 19 additions & 1 deletion applications/cli/config/node.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#protocolMagic=42
#maxKESEvolutions=60
#securityParam=300
#securityParam=80
#slotsPerKESPeriod=129600
#updateQuorum=1
#peerSharing=true
Expand Down Expand Up @@ -79,3 +79,21 @@
## CC Members
#ccMembers[0].hash=scriptHash-8fc13431159fdda66347a38c55105d50d77d67abc1c368b876d52ad1
#ccMembers[0].term=340

########################################################################################################
# Workaround for : https://github.com/bloxbean/yaci-devkit/issues/65
#
# The following parameters are enabled for a V2 cost model-related issue where there are 10 extra elements if the devnet
# 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.
# The network will start in the Babbage era and then hard fork (HF) to the Conway era at epoch 1.

# 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
# which changes the stability window. This is to speed up the process of reaching the Conway era.
#
# 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.
# 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.
# So, the shiftStartTimeBehind flag should be "false" for non-development / multi-node networks.
#
#########################################################################################################
conwayHardForkAtEpoch=1
shiftStartTimeBehind=true
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,17 @@ private void updateGenesis(Path clusterFolder, String clusterName, ClusterInfo c

//Derive security param
long securityParam = genesisConfigCopy.getSecurityParam();
if (securityParam == 0) {
//For stabilityWindow = epochLength * stabilityWindowFactory (0-1) , k = (epochLength * coefficient) / (3 * 2)
securityParam = Math.round(((epochLength * activeSlotsCoeff) / 3) * genesisConfig.getStabilityWindowFactor());

if (genesisConfig.getConwayHardForkAtEpoch() > 0 && genesisConfig.isShiftStartTimeBehind()) {
//Workaround for https://github.com/bloxbean/yaci-devkit/issues/65
//Calculate required securityParam to jump directly to epoch = 1
long expectedStabilityWindow = Math.round(epochLength * 1.5);
securityParam = Math.round(expectedStabilityWindow * activeSlotsCoeff) / 3;
} else {
if (securityParam == 0) {
//For stabilityWindow = epochLength * stabilityWindowFactory (0-1) , k = (epochLength * coefficient) / (3 * 2)
securityParam = Math.round(((epochLength * activeSlotsCoeff) / 3) * genesisConfig.getStabilityWindowFactor());
}
}

values.put("securityParam", securityParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ private boolean setupFirstRun(ClusterInfo clusterInfo, Path clusterFolder, Consu
maxBehindBySecond = clusterInfo.getEpochLength();
}

long shiftTimeBehindSeconds = genesisConfig.getShiftStartTimeBehindBySecs() > 0 ? genesisConfig.getShiftStartTimeBehindBySecs() : maxBehindBySecond;
byronStartTime = byronStartTime - shiftTimeBehindSeconds;
writer.accept(success("Updating Start time to current time - " + shiftTimeBehindSeconds + " in byron-genesis.json"));
byronStartTime = byronStartTime - maxBehindBySecond;
writer.accept(success("Updating Start time to current time - " + maxBehindBySecond + " in byron-genesis.json"));
}
jsonNode.set("startTime", new LongNode(byronStartTime));
objectMapper.writer(new DefaultPrettyPrinter()).writeValue(byronGenesis.toFile(), jsonNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public class GenesisConfig {
//Introduced for the issue https://github.com/bloxbean/yaci-devkit/issues/65
private int conwayHardForkAtEpoch = 0;
private boolean shiftStartTimeBehind = false;
private int shiftStartTimeBehindBySecs = 0; //By default, it will be epochLength

@PostConstruct
public void postInit() {
Expand Down Expand Up @@ -347,7 +346,6 @@ public Map getConfigMap() {

map.put("conwayHardForkAtEpoch", conwayHardForkAtEpoch);
map.put("shiftStartTimeBehind", shiftStartTimeBehind);
map.put("shiftStartTimeBehindBySecs", shiftStartTimeBehindBySecs);

return map;
}
Expand Down Expand Up @@ -438,7 +436,6 @@ public GenesisConfig copy() {

genesisConfig.setConwayHardForkAtEpoch(conwayHardForkAtEpoch);
genesisConfig.setShiftStartTimeBehind(shiftStartTimeBehind);
genesisConfig.setShiftStartTimeBehindBySecs(shiftStartTimeBehindBySecs);

return genesisConfig;
}
Expand Down
20 changes: 19 additions & 1 deletion config/node.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#################################################################################################################

#maxKESEvolutions=60
#securityParam=300
#securityParam=80
#slotsPerKESPeriod=129600
#updateQuorum=1
#peerSharing=true
Expand Down Expand Up @@ -85,3 +85,21 @@
## CC Members
#ccMembers[0].hash=scriptHash-8fc13431159fdda66347a38c55105d50d77d67abc1c368b876d52ad1
#ccMembers[0].term=340

########################################################################################################
# Workaround for : https://github.com/bloxbean/yaci-devkit/issues/65
#
# The following parameters are enabled for a V2 cost model-related issue where there are 10 extra elements if the devnet
# 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.
# The network will start in the Babbage era and then hard fork (HF) to the Conway era at epoch 1.

# 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
# which changes the stability window. This is to speed up the process of reaching the Conway era.
#
# 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.
# 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.
# So, the shiftStartTimeBehind flag should be "false" for non-development / multi-node networks.
#
#########################################################################################################
conwayHardForkAtEpoch=1
shiftStartTimeBehind=true

0 comments on commit 3ae30e3

Please sign in to comment.