Skip to content

Commit 8f34d61

Browse files
authored
Merge branch 'l-monninger/accounts-citerion-redux' into l-monninger/pre-l1-merge-redux
2 parents a1ecaba + 2c90f0c commit 8f34d61

File tree

26 files changed

+442
-178
lines changed

26 files changed

+442
-178
lines changed

.github/workflows/nix-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919

2020
jobs:
2121
run-command:
22-
runs-on: buildjet-16vcpu-ubuntu-2204
22+
runs-on: movement-runner
2323
steps:
2424
- name: Free Disk Space (Ubuntu)
2525
uses: jlumbroso/free-disk-space@main

Cargo.lock

Lines changed: 32 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ libp2p = { version = "0.55.0", features = ["tcp", "quic"] }
8484
chrono = "0.4.31"
8585
rand = "0.7.3"
8686
uuid = "1.10.0"
87+
glob = "0.3.2"
8788

8889
poem = { version = "=3.1.3", features = ["anyhow", "compression", "rustls"] }
8990
poem-openapi = { version = "=5.1.2", features = ["swagger-ui", "url"] }

checks/migrator/checks/sketchpad/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "mtma-migrator-checks-sketchpad"
2+
name = "migrator-sketchpad"
33
version = { workspace = true }
44
edition = { workspace = true }
55
license = { workspace = true }
@@ -30,6 +30,7 @@ mtma-migrator-pre-l1-merge-core = { workspace = true }
3030
[dev-dependencies]
3131
tracing-test = { workspace = true }
3232
tracing = { workspace = true }
33+
tempfile = { workspace = true }
3334

3435
[lints]
3536
workspace = true

checks/migrator/checks/sketchpad/config.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

checks/migrator/checks/sketchpad/src/accounts_equal.rs

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,72 @@
11
#[cfg(test)]
22
pub mod test {
33

4+
use anyhow::Context;
45
use mtma_migrator_test_accounts_equal_criterion::AccountsEqual;
56
use mtma_migrator_test_types::check::checked_migration;
67
use mtma_migrator_types::migrator::{movement_migrator::Overlays, MovementMigrator};
78
use mtma_node_null_core::config::Config as MtmaNullConfig;
89
use mtma_node_test_types::prelude::Prelude;
10+
use tracing::info;
911

10-
#[tokio::test]
12+
#[tokio::test(flavor = "multi_thread")]
1113
#[tracing_test::traced_test]
1214
async fn test_accounts_equal() -> Result<(), anyhow::Error> {
13-
// Form the migrator.
14-
let mut movement_migrator = MovementMigrator::try_debug_home()?;
15-
movement_migrator.set_overlays(Overlays::default());
16-
17-
// Start the migrator so that it's running in the background.
18-
// In the future, some migrators may be for already running nodes.
19-
let movement_migrator_for_task = movement_migrator.clone();
20-
let movement_migrator_task = kestrel::task(async move {
21-
movement_migrator_for_task.run().await?;
22-
Ok::<_, anyhow::Error>(())
23-
});
24-
25-
tokio::time::sleep(tokio::time::Duration::from_secs(30)).await;
26-
27-
kestrel::end!(movement_migrator_task)?;
28-
29-
// Form the prelude.
30-
// todo: this needs to be updated to use the prelude generator
31-
let prelude = Prelude::new_empty();
32-
33-
// Form the migration.
34-
let migration_config = MtmaNullConfig::default();
35-
let migration = migration_config.build()?;
36-
37-
// Run the checked migration.
38-
let accounts_equal = AccountsEqual::new();
39-
checked_migration(&mut movement_migrator, &prelude, &migration, vec![accounts_equal])
40-
.await?;
15+
// use a scope to ensure everything is dropped
16+
{
17+
// Form the migrator.
18+
let mut movement_migrator = MovementMigrator::try_temp()?;
19+
movement_migrator.set_overlays(Overlays::default());
20+
21+
// Start the migrator so that it's running in the background.
22+
// In the future, some migrators may be for already running nodes.
23+
let movement_migrator_for_task = movement_migrator.clone();
24+
let movement_migrator_task = kestrel::task(async move {
25+
movement_migrator_for_task.run().await?;
26+
Ok::<_, anyhow::Error>(())
27+
});
28+
29+
// wait for the rest client to be ready
30+
// once we have this, there should also be a config, so we can then kill off the migrator and proceed
31+
movement_migrator
32+
.wait_for_rest_client_ready(tokio::time::Duration::from_secs(600)) // we wait for up to ten minutes because the nix flake in .vendors/movementcan be a bit slow the first time
33+
.await
34+
.context(
35+
"failed to wait for movement migrator rest client while running accounts equal manual prelude",
36+
)?;
37+
38+
kestrel::end!(movement_migrator_task)?;
39+
40+
// Form the prelude.
41+
// todo: this needs to be updated to use the prelude generator
42+
let prelude = Prelude::new_empty();
43+
44+
// Form the migration.
45+
let migration_config = MtmaNullConfig::default();
46+
let migration = migration_config.build()?;
47+
48+
// Run the checked migration.
49+
let accounts_equal = AccountsEqual::new();
50+
info!("Running migration");
51+
match checked_migration(
52+
&mut movement_migrator,
53+
&prelude,
54+
&migration,
55+
vec![accounts_equal],
56+
)
57+
.await
58+
{
59+
Ok(()) => {}
60+
Err(e) => {
61+
info!("Migration failed: {:?}", e);
62+
return Err(anyhow::anyhow!("Migration failed: {:?}", e));
63+
}
64+
}
65+
info!("Migration succeeded");
66+
}
67+
68+
// exit the test is fine when you only have one test per crate because when cargo test is run across a workspace, it actually multi-processes the tests by crate
69+
std::process::exit(0);
4170

4271
Ok(())
4372
}

checks/migrator/citeria/accounts-equal/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ mtma-migrator-test-types = { workspace = true }
1313
bcs = { workspace = true }
1414
bcs-ext = { workspace = true }
1515
tokio = { workspace = true }
16-
16+
anyhow = { workspace = true }
17+
tracing = { workspace = true }
1718

1819
[lints]
1920
workspace = true

checks/migrator/citeria/accounts-equal/src/lib.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
use anyhow::Context;
12
use bcs_ext::{comparison::BcsEq, conversion::BcsInto};
23
use mtma_migrator_test_types::criterion::{
34
Criterion, CriterionError, Criterionish, MovementAptosMigrator, MovementMigrator,
45
};
6+
use tracing::info;
57

68
pub struct AccountsEqual;
79

@@ -24,22 +26,36 @@ impl Criterionish for AccountsEqual {
2426
let movement_rest_client = movement_migrator
2527
.wait_for_rest_client_ready(tokio::time::Duration::from_secs(30))
2628
.await
29+
.context(
30+
"failed to wait for movement migrator rest client while checking accounts equal",
31+
)
2732
.map_err(|e| CriterionError::Internal(e.into()))?;
2833
let movement_aptos_rest_client = movement_aptos_migrator
2934
.wait_for_rest_client_ready(tokio::time::Duration::from_secs(30))
3035
.await
36+
.context("failed to wait for movement aptos migrator rest client while checking accounts equal")
3137
.map_err(|e| CriterionError::Internal(e.into()))?;
3238

3339
let movement_node =
3440
movement_migrator.node().await.map_err(|e| CriterionError::Internal(e.into()))?;
3541

36-
for account_address in movement_node
42+
info!("Iterating over movement node accounts");
43+
for account_address_res in movement_node
3744
.iter_account_addresses(0)
3845
.map_err(|e| CriterionError::Internal(e.into()))?
3946
{
40-
let account_address =
41-
account_address.map_err(|e| CriterionError::Internal(e.into()))?;
47+
let account_address = match account_address_res
48+
.context("account address is none")
49+
.map_err(|e| CriterionError::Internal(e.into()))
50+
{
51+
Ok(account_address) => account_address,
52+
Err(e) => {
53+
info!("Transaction has no sender: {:?}", e);
54+
continue;
55+
}
56+
};
4257

58+
info!("Getting movement resource");
4359
let movement_resource = movement_rest_client
4460
.get_account_bcs(account_address)
4561
.await
@@ -48,9 +64,11 @@ impl Criterionish for AccountsEqual {
4864
})?
4965
.into_inner();
5066

67+
info!("Getting movement aptos address");
5168
let movement_aptos_account_address =
5269
account_address.bcs_into().map_err(|e| CriterionError::Internal(e.into()))?;
5370

71+
info!("Getting movement aptos account resource");
5472
let aptos_resource = movement_aptos_rest_client
5573
.get_account_bcs(movement_aptos_account_address)
5674
.await
@@ -59,9 +77,12 @@ impl Criterionish for AccountsEqual {
5977
})?
6078
.into_inner();
6179

80+
info!("Comparing resources");
6281
movement_resource
6382
.bcs_eq(&aptos_resource)
6483
.map_err(|e| CriterionError::Unsatisfied(e.into()))?;
84+
85+
info!("Finished processing block");
6586
}
6687

6788
Ok(())

checks/migrator/util/types/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ thiserror = { workspace = true }
2121
tokio = { workspace = true }
2222
bcs = { workspace = true }
2323
mtma-types = { workspace = true }
24+
kestrel = { workspace = true }
25+
tracing = { workspace = true }
2426

2527
[lints]
2628
workspace = true

0 commit comments

Comments
 (0)