Skip to content

Commit 187b56c

Browse files
0o-de-lallyBasil O'FortissimoLucietta De HindGabi De HeronPaoletta Von Ritardando
committed
[patch] fix activity init happening outside migration (#400)
Co-authored-by: Basil O'Fortissimo <basil_o'[email protected]> Co-authored-by: Lucietta De Hind <[email protected]> Co-authored-by: Gabi De Heron <[email protected]> Co-authored-by: Paoletta Von Ritardando <[email protected]> Co-authored-by: Bea LeLento <[email protected]> Co-authored-by: David Boreham <[email protected]> Co-authored-by: xyz <xyz>
1 parent f30ad5e commit 187b56c

File tree

42 files changed

+20278
-16416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+20278
-16416
lines changed

framework/libra-framework/sources/genesis.move

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module diem_framework::genesis {
2828

2929
//////// 0L ////////
3030
use diem_framework::validator_universe;
31+
use diem_framework::activity;
3132
use ol_framework::ol_account;
3233
use ol_framework::musical_chairs;
3334
use ol_framework::proof_of_fee;
@@ -195,6 +196,7 @@ module diem_framework::genesis {
195196
// NOTE: smoke tests will fail without initializing tx fees as in genesis
196197
transaction_fee::initialize_fee_collection_and_distribution(diem_framework, 0);
197198

199+
activity::maybe_onboard(&core_resources);
198200
// NOTE: 0L: the commented code below shows that we are destroying
199201
// there capabilities elsewhere, at libra_coin::initialize
200202
coin::destroy_mint_cap(mint_cap_two);

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
/// Maintains the version number for the blockchain.
33
module ol_framework::activity {
44
use std::signer;
5+
use std::error;
6+
use ol_framework::testnet;
57
use diem_std::timestamp;
68

79
friend ol_framework::filo_migration;
10+
friend ol_framework::genesis;
811
friend ol_framework::ol_account;
912
friend ol_framework::donor_voice_migration;
1013
friend diem_framework::transaction_validation;
@@ -37,8 +40,10 @@ module ol_framework::activity {
3740
}
3841

3942
/// Increment the activity timestamp of a user
43+
// NOTE: this serves to gate users who have not onboarded since v8 upgrade
4044
public(friend) fun increment(user: &signer, timestamp: u64) acquires Activity {
41-
lazy_initialize(user, timestamp);
45+
46+
assert!(exists<Activity>(signer::address_of(user)), error::invalid_state(EACCOUNT_MALFORMED));
4247

4348
let state = borrow_global_mut<Activity>(signer::address_of(user));
4449
state.last_touch_usecs = timestamp;
@@ -54,13 +59,6 @@ module ol_framework::activity {
5459
0
5560
}
5661

57-
fun migrate(user_sig: &signer, timestamp: u64) {
58-
move_to<Activity>(user_sig, Activity {
59-
last_touch_usecs: timestamp,
60-
onboarding_usecs: 0, // also how we identify pre-V8 "founder account",
61-
});
62-
}
63-
6462
public(friend) fun maybe_onboard(user_sig: &signer){
6563

6664
// genesis accounts should not start at 0
@@ -77,6 +75,22 @@ module ol_framework::activity {
7775
}
7876
}
7977

78+
/// migrate or heal a pre-v8 account
79+
public(friend) fun migrate(user_sig: &signer) acquires Activity {
80+
let addr = signer::address_of(user_sig);
81+
if (!exists<Activity>(addr)) {
82+
move_to<Activity>(user_sig, Activity {
83+
last_touch_usecs: 0,
84+
onboarding_usecs: 0,
85+
})
86+
} else if (is_pre_v8(addr)) {
87+
// this is a pre-v8 account that might be malformed
88+
let state = borrow_global_mut<Activity>(addr);
89+
state.last_touch_usecs = 0;
90+
state.onboarding_usecs = 0;
91+
}
92+
}
93+
8094

8195
#[view]
8296
// check if this is an account that has activity
@@ -111,6 +125,17 @@ module ol_framework::activity {
111125
exists<Activity>(user)
112126
}
113127

128+
#[view]
129+
// check the timestamp prior to v8 launch
130+
public fun is_pre_v8(user: address): bool acquires Activity {
131+
if (testnet::is_testnet()) {
132+
return false
133+
};
134+
get_onboarding_usecs(user) < 1747267200 // Date and time (GMT): Thursday, May 15, 2025 12:00:00 AM
135+
}
136+
137+
138+
114139

115140
#[view]
116141
// If the account is a founder/pre-v8 account has been migrated
@@ -122,7 +147,7 @@ module ol_framework::activity {
122147
#[test_only]
123148
/// testnet help for framework account to mock activity
124149
public(friend) fun test_set_activity(framework: &signer, user: address, timestamp: u64) acquires Activity {
125-
ol_framework::testnet::assert_testnet(framework);
150+
testnet::assert_testnet(framework);
126151

127152
let state = borrow_global_mut<Activity>(user);
128153
state.last_touch_usecs = timestamp;

framework/libra-framework/sources/ol_sources/migrations/filo_migration.move

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module ol_framework::filo_migration {
2020
// Just a man and his will to survive.
2121

2222
// did this account exist before level 8?
23-
activity::lazy_initialize(user_sig, 0);
23+
activity::migrate(user_sig);
2424

2525
// I am the eye of the tiger
2626
// I am the founder of my destiny

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module ol_framework::reauthorization {
66
use ol_framework::donor_voice_reauth;
77
use ol_framework::founder;
88

9-
109
/// user account never migrated from V7 to V8
1110
const ENOT_MIGRATED_FROM_V7: u64 = 1;
1211

@@ -56,10 +55,10 @@ module ol_framework::reauthorization {
5655

5756

5857
// case 3: user onboarded since v8 started
59-
// check only if the account is malformed
60-
// i.e. has an activity struct but no activity
58+
// checks for edge cases where accounts were
59+
// partially migrated
6160

62-
if (!activity::is_prehistoric(account)) {
61+
if (!activity::is_pre_v8(account)) {
6362
return true
6463
};
6564

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ module ol_framework::test_boundary {
265265
fun e2e_add_validator_sad_vouches(root: signer, alice: signer, marlon_rando: signer) {
266266
let _vals = common_test_setup(&root);
267267
// this test requires prod settings, since we don't check vouches on testing
268-
testnet::unset(&root);
269268
// generate credentials for validator registration
270269
ol_account::transfer(&alice, @0x12345, 200000);
271270
let (_sk, pk, pop) = stake::generate_identity();
@@ -284,6 +283,9 @@ module ol_framework::test_boundary {
284283

285284
mock::mock_bids(&vals);
286285

286+
// use prod settings on epoch boundary
287+
testnet::unset(&root);
288+
287289
mock::trigger_epoch(&root);
288290

289291
assert!(epoch_boundary::get_reconfig_success(), 7357002);

framework/releases/mainnet.mrb

83.5 KB
Binary file not shown.

framework/src/upgrade_fixtures/fixtures/upgrade-multi-lib-force/1-move-stdlib/Move.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ license = ''
88

99
[dev-addresses]
1010
[dependencies.LibraFramework]
11-
local = '/Users/lucas/code/rust/libra-framework/framework/libra-framework'
11+
local = '/root/libra-framework/framework/libra-framework'
1212

1313
[dev-dependencies]
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8927075a0e1668b26965781f2e53ead5c29bb2ea7499042163015c998e39aa40
1+
e7e92c2fa97352662a34685c191b0c29a4fe5a4a58d3b01ea9486897cfb5990d

framework/src/upgrade_fixtures/fixtures/upgrade-multi-lib-force/1-move-stdlib/sources/1-move-stdlib.move

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Upgrade proposal for package `MoveStdlib`
22

3-
// Framework commit hash: 25053ae3d9da72cee42882ab26e0069875e727ad
4-
// Builder commit hash: e402fe6d60b1fc0c2eecc51bc606c7200a579789
3+
// Framework commit hash: 993b9a240c0efe9ee9f8685d48eee7450b12d9a9
4+
// Builder commit hash: 750f39b5b91114754203d858ec6a758b2f664084
55

6-
// Next step script hash: 48f2a6d4de1b93cada516f57d5fdd098f7e5b1cb2bcefb6448d52e2e19b7c40d
6+
// Next step script hash: 76486da4588174318b7447fce26f3f22455a65b2bc063df6900d93a7f11c252d
77

88
// source digest: 97EF0B8134DCF72CE2FD67755B33A3B35BFB6A557D261B2C89027478E99E231A
99
script {
@@ -17,7 +17,7 @@ script {
1717
let framework_signer = diem_governance::resolve_multi_step_proposal(
1818
proposal_id,
1919
@0000000000000000000000000000000000000000000000000000000000000001,
20-
vector[72u8,242u8,166u8,212u8,222u8,27u8,147u8,202u8,218u8,81u8,111u8,87u8,213u8,253u8,208u8,152u8,247u8,229u8,177u8,203u8,43u8,206u8,251u8,100u8,72u8,213u8,46u8,46u8,25u8,183u8,196u8,13u8,],
20+
vector[118u8,72u8,109u8,164u8,88u8,129u8,116u8,49u8,139u8,116u8,71u8,252u8,226u8,111u8,63u8,34u8,69u8,90u8,101u8,178u8,188u8,6u8,61u8,246u8,144u8,13u8,147u8,167u8,241u8,28u8,37u8,45u8,],
2121
);
2222
let code = vector::empty();
2323
let code_chunk0 =
@@ -636,6 +636,6 @@ script {
636636
112u8,116u8,105u8,111u8,110u8,0u8,0u8,0u8,6u8,115u8,116u8,114u8,105u8,110u8,103u8,0u8,0u8,0u8,0u8,0u8,
637637
];
638638
code::publish_package_txn(&framework_signer, metadata_chunk1, code);
639-
version::upgrade_set_git(&framework_signer, x"25053ae3d9da72cee42882ab26e0069875e727ad")
639+
version::upgrade_set_git(&framework_signer, x"993b9a240c0efe9ee9f8685d48eee7450b12d9a9")
640640
}
641641
}

0 commit comments

Comments
 (0)