You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Steps comes from here https://github.com/opentensor/subtensor/pull/982/files#diff-7261bf1c7f19fc66a74c1c644ec2b4b277a341609710132fb9cd5f622350a6f5R120-R131
32
36
// 1 Instantiate payload
@@ -50,18 +54,45 @@ async fn generate_commit(
50
54
.unwrap()
51
55
.as_secs();
52
56
53
-
let current_round = (now - genesis_time) / period;
54
-
// tempo is amount of blocks in 1 epoch
55
-
// block_time is length the block in seconds
56
-
// subnet_reveal_period_epochs means after how many epochs to make a commit reveal
57
-
let delay_seconds = tempo * block_time * subnet_reveal_period_epochs;
58
-
let rounds_to_wait = (delay_seconds + period - 1) / period;
59
-
let reveal_round = current_round + rounds_to_wait;
57
+
// Compute the current epoch index
58
+
let tempo_plus_one = tempo + 1;
59
+
let netuid_plus_one = (netuid asu64) + 1;
60
+
let block_with_offset = current_block + netuid_plus_one;
61
+
let current_epoch = block_with_offset / tempo_plus_one;
62
+
63
+
// Compute the reveal epoch
64
+
let reveal_epoch = current_epoch + subnet_reveal_period_epochs;
65
+
66
+
// Compute the block number when the reveal epoch starts
67
+
let reveal_block_number = reveal_epoch * tempo_plus_one - netuid_plus_one;
68
+
69
+
// Compute the number of blocks until the reveal epoch
70
+
let blocks_until_reveal = reveal_block_number.saturating_sub(current_block);
71
+
72
+
// Compute the time until the reveal in seconds
73
+
let time_until_reveal = blocks_until_reveal * block_time;
60
74
61
-
// 3 Encrypt
62
-
let pub_key_bytes = hex::decode(public_key).expect("Decoding failed");
75
+
// Compute the reveal time in seconds since UNIX_EPOCH
76
+
let reveal_time = now + time_until_reveal;
77
+
78
+
// Compute the reveal round, ensuring we round up
79
+
let reveal_round = ((reveal_time - genesis_time + period - 1) / period) - SUBTENSOR_PULSE_DELAY;
80
+
81
+
// 3. Deserialize the public key
82
+
let pub_key_bytes = hex::decode(public_key).map_err(|e| {
0 commit comments