Skip to content

Commit f09e181

Browse files
0o-de-lallyCholmondeley StaccatoCaro Andante
authored andcommitted
[bug] patch duplicate migrate bug (#425)
Co-authored-by: Cholmondeley Staccato <[email protected]> Co-authored-by: Caro Andante <[email protected]>
1 parent 1f0b5ce commit f09e181

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

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

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@ module ol_framework::filo_migration {
33
use ol_framework::donor_voice;
44
use ol_framework::founder;
55
use ol_framework::page_rank_lazy;
6+
use ol_framework::reauthorization;
67
use ol_framework::slow_wallet;
7-
88
use ol_framework::vouch;
99
use std::signer;
1010
use std::error;
1111

1212
friend diem_framework::transaction_validation;
13+
#[test_only]
14+
friend ol_framework::mock;
1315

16+
/// Error codes
1417
/// Cannot be used by donor voice accounts
1518
const EDONOR_VOICE: u64 = 1;
19+
/// Cannot be used by accounts that have already been authorized for v8
20+
const EALREADY_AUTHORIZED: u64 = 2;
1621

1722
// Welcome to Level 8
1823

@@ -22,8 +27,17 @@ module ol_framework::filo_migration {
2227
// It's a journey, it's a race.
2328
public entry fun maybe_migrate(user_sig: &signer) {
2429
// community wallets should not do this migration
25-
assert!(!donor_voice::is_donor_voice(signer::address_of(user_sig)), error::invalid_argument(EDONOR_VOICE));
30+
let addr = signer::address_of(user_sig);
31+
assert!(!donor_voice::is_donor_voice(addr), error::invalid_argument(EDONOR_VOICE));
32+
33+
// don't allow a v8-migrated account to accidentally migrate again
34+
assert!(!reauthorization::is_v8_authorized(addr), error::invalid_argument(EALREADY_AUTHORIZED));
2635

36+
migration_impl(user_sig);
37+
}
38+
39+
// FILO FTW
40+
fun migration_impl(user_sig: &signer) {
2741
// Rising up, back on the street
2842
// Did my time, took my chances
2943
// Went the distance, now I'm back on my feet
@@ -38,18 +52,6 @@ module ol_framework::filo_migration {
3852
// I'm the spark, I'm the first, I'm the one who created the fire.
3953
founder::migrate(user_sig);
4054

41-
42-
// All I want is to see you smile
43-
// If it takes just a little while
44-
// I know you don't believe that it's true
45-
// I never meant any harm to you
46-
47-
// Don't stop thinking about tomorrow
48-
// Don't stop, it'll soon be here
49-
// It'll be better than before
50-
// Yesterday's gone, yesterday's gone
51-
slow_wallet::filo_migration_reset(user_sig);
52-
5355
// Good evening
5456
// You know my name
5557
// Look, look, look up the number
@@ -70,6 +72,25 @@ module ol_framework::filo_migration {
7072
// I'm still standing. Yeah, yeah, yeah
7173
page_rank_lazy::maybe_initialize_trust_record(user_sig);
7274

75+
76+
// All I want is to see you smile
77+
// If it takes just a little while
78+
// I know you don't believe that it's true
79+
// I never meant any harm to you
80+
81+
// Don't stop thinking about tomorrow
82+
// Don't stop, it'll soon be here
83+
// It'll be better than before
84+
// Yesterday's gone, yesterday's gone
85+
slow_wallet::filo_migration_reset(user_sig);
7386
}
74-
// FILO FTW
87+
88+
89+
#[test_only]
90+
public(friend) fun test_unchecked_migration(user_sig: &signer) {
91+
// This is a test-only function to allow migration without checks.
92+
// It should not be used in production code.
93+
migration_impl(user_sig);
94+
}
95+
7596
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ public fun mock_vouch_score_50(framework: &signer, target_account: address): vec
579579
public fun simulate_v8_migration(sender: &signer) {
580580
// run migrations
581581
// Note, Activity and Founder struct should have been set above
582-
filo_migration::maybe_migrate(sender);
582+
filo_migration::test_unchecked_migration(sender);
583583
// touching the account will also increment activity
584584
activity::increment(sender);
585585
}

0 commit comments

Comments
 (0)