Skip to content

Commit 17922ac

Browse files
0xzoz0o-de-lally
authored andcommitted
[fix] revert commits causing 6.9.6 backwards compatibility errors (#180)
1 parent 6c78b8e commit 17922ac

File tree

25 files changed

+13224
-13218
lines changed

25 files changed

+13224
-13218
lines changed

framework/libra-framework/sources/block.move

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module diem_framework::block {
33
use std::error;
44
use std::vector;
55
use std::option;
6+
use std::features;
67
use std::string;
78
use diem_framework::account;
89
use diem_framework::event::{Self, EventHandle};
@@ -16,7 +17,6 @@ module diem_framework::block {
1617

1718
//////// 0L ////////
1819
use ol_framework::epoch_boundary;
19-
use ol_framework::ol_features;
2020

2121
friend diem_framework::genesis;
2222

@@ -233,12 +233,8 @@ module diem_framework::block {
233233
return
234234
};
235235

236-
if (timestamp - reconfiguration::last_reconfiguration_time() >=
237-
block_metadata_ref.epoch_interval) {
238-
// do automatic epochs in testnet.
239-
// in main or stage, check if the feature flag is enabled for
240-
// manual epochs
241-
if (!ol_features::epoch_trigger_enabled() || testnet::is_testnet()) {
236+
if (timestamp - reconfiguration::last_reconfiguration_time() >= block_metadata_ref.epoch_interval) {
237+
if (!features::epoch_trigger_enabled() || testnet::is_not_mainnet()) {
242238
epoch_boundary::epoch_boundary(
243239
vm,
244240
reconfiguration::get_current_epoch(),

framework/libra-framework/sources/modified_source/genesis.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ module diem_framework::genesis {
262262
let sig = create_signer(validator.validator_config.owner_address);
263263
proof_of_fee::set_bid(&sig, 0900, 1000); // make the genesis
264264

265-
if (testnet::is_testnet()) {
265+
if (testnet::is_not_mainnet()) {
266266
// TODO: this is for testnet purposes only
267267
// unlock some of the genesis validators coins so they can issue
268268
// transactions from epoch 0 in test runners.

framework/libra-framework/sources/multisig_account.move

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ module diem_framework::multisig_account {
456456
metadata_keys: vector<String>,
457457
metadata_values: vector<vector<u8>>,
458458
) acquires MultisigAccount {
459-
// commit note: multisig accounts enabled permanently
459+
assert!(features::multisig_accounts_enabled(), error::unavailable(EMULTISIG_ACCOUNTS_NOT_ENABLED_YET));
460460
assert!(
461461
num_signatures_required > 0 && num_signatures_required <= vector::length(&owners),
462462
error::invalid_argument(EINVALID_SIGNATURES_REQUIRED),
@@ -957,7 +957,6 @@ module diem_framework::multisig_account {
957957
use diem_std::multi_ed25519;
958958
#[test_only]
959959
use std::string::utf8;
960-
#[test_only]
961960
use std::features;
962961

963962
#[test_only]
@@ -1097,7 +1096,13 @@ module diem_framework::multisig_account {
10971096
vector[]);
10981097
}
10991098

1100-
// commit note: not a relevant test, now that it is enabled permanently
1099+
#[test(owner = @0x123)]
1100+
#[expected_failure(abort_code = 0xD000E, location = Self)]
1101+
public entry fun test_create_with_without_feature_flag_enabled_should_fail(
1102+
owner: &signer) acquires MultisigAccount {
1103+
create_account(address_of(owner));
1104+
create(owner, 2, vector[], vector[]);
1105+
}
11011106

11021107
#[test(owner_1 = @0x123, owner_2 = @0x124, owner_3 = @0x125)]
11031108
#[expected_failure(abort_code = 0x10001, location = Self)]

framework/libra-framework/sources/ol_sources/epoch_boundary.move

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ module diem_framework::epoch_boundary {
223223
/// by a user, would not cause a halt.
224224
public(friend) fun trigger_epoch(framework_signer: &signer) acquires BoundaryBit,
225225
BoundaryStatus {
226-
// must be mainnet or stage
227-
assert!(!testnet::is_testnet(), ETRIGGER_EPOCH_MAINNET);
226+
// must be mainnet
227+
assert!(!testnet::is_not_mainnet(), ETRIGGER_EPOCH_MAINNET);
228228
// must get root permission from governance.move
229229
system_addresses::assert_ol(framework_signer);
230230
let _ = can_trigger(); // will abort if false

framework/libra-framework/sources/ol_sources/globals.move

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ module ol_framework::globals {
1515
struct GlobalConstants has drop {
1616
// For validator set.
1717
epoch_length: u64,
18-
val_set_at_genesis: u64,// deprecated?
19-
subsidy_ceiling_gas: u64, // deprecated?
18+
val_set_at_genesis: u64,
19+
subsidy_ceiling_gas: u64,
2020
vdf_difficulty_baseline: u64,
2121
vdf_security_baseline: u64,
2222
epoch_mining_thres_lower: u64,
2323
epoch_mining_thres_upper: u64,
2424
epoch_slow_wallet_unlock: u64,
25-
min_blocks_per_epoch: u64, // deprecated?
25+
min_blocks_per_epoch: u64,
2626
validator_vouch_threshold: u64,
2727
signing_threshold_pct: u64,
2828
}
@@ -95,9 +95,32 @@ module ol_framework::globals {
9595
get_constants().signing_threshold_pct
9696
}
9797

98-
fun get_mainnet(): GlobalConstants {
98+
/// Get the constants for the current network
99+
fun get_constants(): GlobalConstants {
100+
101+
if (testnet::is_testnet()) {
102+
return GlobalConstants {
103+
epoch_length: 60, // seconds
104+
val_set_at_genesis: 10,
105+
subsidy_ceiling_gas: 296 * get_coin_scaling_factor(),
106+
vdf_difficulty_baseline: 100,
107+
vdf_security_baseline: 512,
108+
epoch_mining_thres_lower: 2, // many tests depend on two proofs because
109+
// the test harness already gives one at
110+
// genesis to validators
111+
epoch_mining_thres_upper: 1000, // upper bound unlimited
112+
epoch_slow_wallet_unlock: 10,
113+
min_blocks_per_epoch: 0,
114+
validator_vouch_threshold: 0,
115+
signing_threshold_pct: 3,
116+
}
117+
};
118+
119+
if (testnet::is_staging_net()) {
120+
// All numbers like MAINNET except shorter epochs of 30 mins
121+
// and minimum mining of 1 proof
99122
return GlobalConstants {
100-
epoch_length: 60 * 60 * 24, // approx 24 hours
123+
epoch_length: 60 * 30, // 30 mins, enough for a hard miner proof.
101124
val_set_at_genesis: 100, // max expected for BFT limits.
102125
// See DiemVMConfig for gas constants:
103126
// Target max gas units per transaction 100000000
@@ -108,46 +131,33 @@ module ol_framework::globals {
108131
vdf_difficulty_baseline: 120000000, // wesolowski proof, new parameters. Benchmark available in docs/delay_tower/benchmarking
109132
vdf_security_baseline: 512,
110133
// NOTE Reviewers: this goes back to v5 params since the VDF cryptograpy will actually not be changed
111-
epoch_mining_thres_lower: 7, // lower bound, allows for some operator error
134+
epoch_mining_thres_lower: 1, // lower bound, allows for some operator error
112135
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof
113136
epoch_slow_wallet_unlock: 1000 * get_coin_scaling_factor(), // approx 10 years for largest accounts in genesis.
114137
min_blocks_per_epoch: 10000,
115138
validator_vouch_threshold: 2, // Production must be more than 1 vouch validator (at least 2)
116139
signing_threshold_pct: 3,
117140
}
118-
}
119-
120-
fun get_testnet(): GlobalConstants {
141+
} else {
121142
return GlobalConstants {
122-
epoch_length: 60, // seconds
123-
val_set_at_genesis: 10,
124-
subsidy_ceiling_gas: 296 * get_coin_scaling_factor(),
125-
vdf_difficulty_baseline: 100,
143+
epoch_length: 60 * 60 * 24, // approx 24 hours at 1.4 vdf_proofs/sec
144+
val_set_at_genesis: 100, // max expected for BFT limits.
145+
// See DiemVMConfig for gas constants:
146+
// Target max gas units per transaction 100000000
147+
// target max block time: 2 secs
148+
// target transaction per sec max gas: 20
149+
// uses "scaled representation", since there are no decimals.
150+
subsidy_ceiling_gas: 8640000 * get_coin_scaling_factor(), // subsidy amount assumes 24 hour epoch lengths. Also needs to be adjusted for coin_scale the onchain representation of human readable value.
151+
vdf_difficulty_baseline: 120000000, // wesolowski proof, new parameters. Benchmark available in docs/delay_tower/benchmarking
126152
vdf_security_baseline: 512,
127-
epoch_mining_thres_lower: 2, // many tests depend on two proofs because
128-
// the test harness already gives one at
129-
// genesis to validators
130-
epoch_mining_thres_upper: 1000, // upper bound unlimited
131-
epoch_slow_wallet_unlock: 10,
132-
min_blocks_per_epoch: 0,
133-
validator_vouch_threshold: 0,
153+
// NOTE Reviewers: this goes back to v5 params since the VDF cryptograpy will actually not be changed
154+
epoch_mining_thres_lower: 7, // lower bound, allows for some operator error
155+
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof
156+
epoch_slow_wallet_unlock: 1000 * get_coin_scaling_factor(), // approx 10 years for largest accounts in genesis.
157+
min_blocks_per_epoch: 10000,
158+
validator_vouch_threshold: 2, // Production must be more than 1 vouch validator (at least 2)
134159
signing_threshold_pct: 3,
135160
}
161+
}
136162
}
137-
138-
/// Get the constants for the current network
139-
fun get_constants(): GlobalConstants {
140-
if (testnet::is_testnet()) {
141-
return get_testnet()
142-
};
143-
// staging net is for upgrade verification.
144-
// we want check epoch boundary behavior without waiting 24h
145-
if (testnet::is_staging_net()) {
146-
let c = get_mainnet();
147-
c.epoch_length = 60 * 15; // 15 mins
148-
return c
149-
};
150-
151-
get_mainnet()
152-
}
153-
}
163+
}

framework/libra-framework/sources/ol_sources/ol_features.move

Lines changed: 0 additions & 25 deletions
This file was deleted.

framework/libra-framework/sources/ol_sources/testnet.move

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ module ol_framework::testnet {
1616
chain_id::get() == 4
1717
}
1818

19-
//commit note: confusing is_not_mainnet
19+
public fun is_not_mainnet(): bool {
20+
chain_id::get() != 1
21+
}
2022

2123
public fun assert_testnet(root: &signer): bool {
2224
system_addresses::assert_ol(root);
@@ -25,8 +27,7 @@ module ol_framework::testnet {
2527
}
2628

2729
public fun is_staging_net(): bool {
28-
// NOTE: confusingly in vendor's rust code chain=2 is called TESTNET
29-
chain_id::get() == 2
30+
chain_id::get() == 2 // TESTNET named chain
3031
}
3132

3233
#[test_only]

framework/libra-framework/sources/ol_sources/tests/boundary.test.move

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#[test_only]
33
module ol_framework::test_boundary {
44
use std::vector;
5+
use std::features;
56
use diem_std::bls12381;
67
use ol_framework::mock;
78
use ol_framework::proof_of_fee;
@@ -11,17 +12,15 @@ module ol_framework::test_boundary {
1112
use ol_framework::testnet;
1213
use ol_framework::validator_universe;
1314
use ol_framework::epoch_boundary;
14-
use ol_framework::block;
15+
use ol_framework::block;
1516
use ol_framework::ol_account;
1617
use diem_framework::stake;
1718
use diem_framework::reconfiguration;
1819
use diem_framework::timestamp;
1920
use diem_framework::diem_governance;
20-
use ol_framework::ol_features;
21-
21+
2222
// use diem_std::debug::print;
2323

24-
// TODO: let's make these consts all caps
2524
const Alice: address = @0x1000a;
2625
const Bob: address = @0x1000b;
2726
const Carol: address = @0x1000c;
@@ -220,22 +219,22 @@ module ol_framework::test_boundary {
220219
// testing mainnet, so change the chainid
221220
testnet::unset(root);
222221

223-
//verify trigger is not enabled
224-
assert!(!ol_features::epoch_trigger_enabled(), 7357001);
222+
//verify trigger is not enabled
223+
assert!(!features::epoch_trigger_enabled(), 101);
225224

226225
// test setup advances to epoch #2
227226
let epoch = reconfiguration::get_current_epoch();
228-
assert!(epoch == 2, 7357002);
227+
assert!(epoch == 2, 7357001);
229228
epoch_boundary::test_set_boundary_ready(root, epoch);
230-
229+
231230

232231
// case: trigger not set and flipped
233232
timestamp::fast_forward_seconds(1); // needed for reconfig
234233
block::test_maybe_advance_epoch(root, 602000001, 602000000);
235234

236235
// test epoch advances
237236
let epoch = reconfiguration::get_current_epoch();
238-
assert!(epoch == 3, 7357003);
237+
assert!(epoch == 3, 7357002);
239238

240239
}
241240

@@ -250,7 +249,7 @@ module ol_framework::test_boundary {
250249
epoch_boundary::test_set_boundary_ready(root, epoch);
251250

252251
// case: epoch trigger set
253-
ol_features::change_feature_flags(root, vector[ol_features::get_epoch_trigger()], vector[]);
252+
features::change_feature_flags(root, vector[features::get_epoch_trigger()], vector[]);
254253
timestamp::fast_forward_seconds(1); // needed for reconfig
255254
block::test_maybe_advance_epoch(root, 603000001, 602000000);
256255

framework/libra-framework/sources/ol_sources/tower_state.move

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ module ol_framework::tower_state {
381381
diff.prev_sec = diff.security; // NOTE: this shouldn't change unless in testing
382382

383383
// VDF proofs must be even numbers.
384-
let rando = if (testnet::is_testnet()) { toy_rng(0, 1, 0) }
384+
let rando = if (testnet::is_not_mainnet()) { toy_rng(0, 1, 0) }
385385
else { toy_rng(3, 2, 10) };
386386
if (rando > 0) {
387387
rando = rando * 2;
@@ -585,7 +585,7 @@ module ol_framework::tower_state {
585585
// pick the next miner
586586
// make sure we get an n smaller than list of miners
587587

588-
// Current case: if miner_index = count_miners could lead to overflow
588+
// Current case: if miner_index = count_miners could lead to overflow
589589

590590
// let k = 0; // k keeps track of this loop, abort if loops too much
591591
// while (this_miner_index >= count_miners) {
@@ -678,6 +678,36 @@ module ol_framework::tower_state {
678678
};
679679
}
680680

681+
// // Returns if the miner is above the account creation rate-limit
682+
// // Permissions: PUBLIC, ANYONE
683+
// public fun can_create_val_account(node_addr: address): bool acquires TowerProofHistory {
684+
// if(testnet::is_testnet() || testnet::is_staging_net()) return true;
685+
// // check if rate limited, needs 7 epochs of validating.
686+
// if (exists<TowerProofHistory>(node_addr)) {
687+
// return
688+
// borrow_global<TowerProofHistory>(node_addr).epochs_since_last_account_creation
689+
// >= EPOCHS_UNTIL_ACCOUNT_CREATION
690+
// };
691+
// false
692+
// }
693+
694+
// #[view]
695+
// ///
696+
// public fun get_validator_proofs_in_epoch(): u64 acquires TowerCounter{
697+
// let state = borrow_global<TowerCounter>(@ol_framework);
698+
// state.validator_proofs_in_epoch
699+
// }
700+
701+
// public fun get_fullnode_proofs_in_epoch(): u64 acquires TowerCounter{
702+
// let state = borrow_global<TowerCounter>(@ol_framework);
703+
// state.fullnode_proofs_in_epoch
704+
// }
705+
706+
// public fun get_fullnode_proofs_in_epoch_above_thresh(): u64 acquires TowerCounter{
707+
// let state = borrow_global<TowerCounter>(@ol_framework);
708+
// state.fullnode_proofs_in_epoch_above_thresh
709+
// }
710+
681711
#[view]
682712
/// number of proof submitted over lifetime of chain
683713
public fun get_lifetime_proof_count(): u64 acquires TowerCounter{

framework/move-stdlib/sources/configs/features.move

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ module std::features {
209209
is_enabled(DIEM_UNIQUE_IDENTIFIERS)
210210
}
211211

212+
/// Whether the new epoch trigger logic is enabled.
213+
/// Lifetime: transient
214+
const EPOCH_TRIGGER_ENABLED: u64 = 24;
215+
public fun get_epoch_trigger(): u64 { EPOCH_TRIGGER_ENABLED }
216+
public fun epoch_trigger_enabled(): bool acquires Features {
217+
is_enabled(EPOCH_TRIGGER_ENABLED)
218+
}
219+
212220
// ============================================================================================
213221
// Feature Flag Implementation
214222

@@ -236,10 +244,8 @@ module std::features {
236244
});
237245
}
238246

239-
// commit note: breaking change to ABI because of visibility
240-
#[view]
241247
/// Check whether the feature is enabled.
242-
public fun is_enabled(feature: u64): bool acquires Features {
248+
fun is_enabled(feature: u64): bool acquires Features {
243249
exists<Features>(@std) &&
244250
contains(&borrow_global<Features>(@std).features, feature)
245251
}

0 commit comments

Comments
 (0)