Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tools] refactor rescue cli 6.9.1 #137

Merged
merged 90 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e8111b3
add rescue tests to ci
0o-de-lally Dec 7, 2023
22e6cfa
rescue tests failing, stake::remove_validators was removed. Reintrodu…
0o-de-lally Dec 7, 2023
d6ab64e
clean
0o-de-lally Dec 7, 2023
4231057
release head.mrb
0o-de-lally Dec 7, 2023
012b947
tests: rescue cli produces a valid genesis from smoke db
0o-de-lally Dec 7, 2023
b0d1f63
add meta test for stopping network
0o-de-lally Dec 7, 2023
367cfbf
split up e2e tests
0o-de-lally Dec 7, 2023
152d229
can apply tx to database at rest and restart
0o-de-lally Dec 7, 2023
3b67e1a
adding debug print to epoch boundary
0o-de-lally Dec 7, 2023
e9d8d12
refactor stake::remove_validators for 0L case
0o-de-lally Dec 7, 2023
4eb5062
testing restart works. adapt to issue where swarm can't drop a valida…
0o-de-lally Dec 7, 2023
83816a6
add full e2e test including catch up
0o-de-lally Dec 7, 2023
31a3c53
update rust min stack
0o-de-lally Dec 8, 2023
0af2663
scaffold framework test
0o-de-lally Dec 8, 2023
91f360a
make rescue ci only run a single test at a time to prevent multiple c…
0o-de-lally Dec 8, 2023
f1be5e0
patch ci yaml
0o-de-lally Dec 8, 2023
a9c94d9
fmt
0o-de-lally Dec 8, 2023
4a03217
cleanig up rescue cli
0o-de-lally Dec 8, 2023
0345a9c
wip try to bump epoch
0o-de-lally Dec 8, 2023
3d88139
add emitting of epoch to reconfigure for test
0o-de-lally Dec 8, 2023
61af7ce
add debugger commands
0o-de-lally Dec 8, 2023
130bcb0
add a framework upgrade script
0o-de-lally Dec 8, 2023
0cee636
create framework upgrade test from script
0o-de-lally Dec 8, 2023
c8f4915
remove deprecated admin_script_builder, remove deprecated templates.
0o-de-lally Dec 8, 2023
468e24d
cleanup ci
0o-de-lally Dec 9, 2023
b7acf9d
try disabling reconfiguration
0o-de-lally Dec 9, 2023
f3a89dd
revert cargo.toml dev profile
0o-de-lally Dec 10, 2023
e873455
cleanup. remove option of upgrades via move vm session
0o-de-lally Dec 10, 2023
ba98233
clean up reconfiguration logic. Add apis for calling a reconfiguratio…
0o-de-lally Dec 10, 2023
061cadb
allow diem governance to call stake::maybe_reconfigure
0o-de-lally Dec 10, 2023
13a7332
notes
0o-de-lally Dec 10, 2023
554136e
use black magic on rescue.move
0o-de-lally Dec 10, 2023
868ceac
wip refactor upgrade test fixtures
0o-de-lally Dec 10, 2023
c155ea3
builds txs tests
0o-de-lally Dec 10, 2023
55b2680
remove duplicate smoke test for upgrade
0o-de-lally Dec 10, 2023
b634739
organize and create fresh fixtures
0o-de-lally Dec 10, 2023
c1c1f43
new rescue.move test script using all_your_base.move
0o-de-lally Dec 10, 2023
fd3d24c
add e2e test for framework
0o-de-lally Dec 10, 2023
77559ae
try getting new module function
0o-de-lally Dec 10, 2023
07f46a1
patch txs upgrade tests
0o-de-lally Dec 11, 2023
59282c5
wip tracing if module is published.
0o-de-lally Dec 11, 2023
050eccb
wip debug publishing code
0o-de-lally Dec 12, 2023
8dab7c7
debug modules being published with empty vec
0o-de-lally Dec 12, 2023
19cf531
adding sources to framework publishing
0o-de-lally Dec 12, 2023
ab1d61d
clean
0o-de-lally Dec 12, 2023
ce497c0
clean
0o-de-lally Dec 12, 2023
c817252
clean rescue main
0o-de-lally Dec 12, 2023
0a67a53
add debugger setting
0o-de-lally Dec 12, 2023
73ffbfd
remove prints from code.move
0o-de-lally Dec 12, 2023
b8b5053
update upgrade fixtures
0o-de-lally Dec 12, 2023
c69fa20
update rescue.move
0o-de-lally Dec 12, 2023
4396108
add debugger, sleep to close db, rescue example
0o-de-lally Dec 14, 2023
fb866f4
create a rescue template. add reproduction of issue
0o-de-lally Dec 14, 2023
6063fad
upgrade framework
0o-de-lally Dec 14, 2023
ff16828
template
0o-de-lally Dec 14, 2023
5519e47
testing open db
0o-de-lally Dec 15, 2023
5ea15f4
opendb
0o-de-lally Dec 15, 2023
7655f6b
can publish bundle and call function
0o-de-lally Dec 15, 2023
295e141
try to return writeset
0o-de-lally Dec 15, 2023
ba522e7
add deps
0o-de-lally Dec 15, 2023
48102cb
fmt
0o-de-lally Dec 15, 2023
576b591
patch
0o-de-lally Dec 15, 2023
4c90174
connect to cli
0o-de-lally Dec 15, 2023
e56dbad
refactor open_db
0o-de-lally Dec 15, 2023
6f54b3e
fmt
0o-de-lally Dec 15, 2023
cd27f69
refactoring APIs
0o-de-lally Dec 15, 2023
ddf3c7b
remove async
0o-de-lally Dec 15, 2023
11629da
can get a new genesis
0o-de-lally Dec 15, 2023
3395a8d
database writeset with upgrade being applied
0o-de-lally Dec 15, 2023
65c537a
clean
0o-de-lally Dec 15, 2023
2353e18
clean
0o-de-lally Dec 15, 2023
7e73bed
Merge branch 'rescue-cli-refactor' into rescue-ci-rebase
0o-de-lally Dec 15, 2023
661d4c3
patch
0o-de-lally Dec 15, 2023
46cdc0e
patch
0o-de-lally Dec 15, 2023
9e33c8f
patch smoke tests
0o-de-lally Dec 15, 2023
ac3dae5
fmt
0o-de-lally Dec 15, 2023
c5438d6
patch tests
0o-de-lally Dec 15, 2023
5af5e30
patch to work on db 6.9.0
0o-de-lally Dec 18, 2023
ce50888
export txs validator entry functions
0o-de-lally Dec 16, 2023
f27bdec
rescue twin
0o-de-lally Dec 16, 2023
5f199ef
able to set new validators
0o-de-lally Dec 18, 2023
c1f48ac
able to set debug validators to replace validator set
0o-de-lally Dec 18, 2023
acb5be9
fmt
0o-de-lally Dec 18, 2023
7e9d4ab
can get registration script
0o-de-lally Dec 19, 2023
84dc49e
fmt
0o-de-lally Dec 20, 2023
6b64b54
smoke test for replacing validator
0o-de-lally Dec 20, 2023
c052173
fmt
0o-de-lally Dec 20, 2023
75579f3
patch test
0o-de-lally Dec 20, 2023
5637a3d
patch and ignore tests
0o-de-lally Dec 20, 2023
28da1a0
clippy
0o-de-lally Dec 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:

jobs:
build-framework:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -34,6 +35,7 @@ jobs:
name: framework-build
path: framework/*
types:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -46,6 +48,7 @@ jobs:
working-directory: ./types
run: cargo test --no-fail-fast
wallet:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -59,6 +62,7 @@ jobs:

# NOTE: all jobs below need the fresh framework build
smoke:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -75,9 +79,10 @@ jobs:
- name: smoke-tests # NOTE: needs working DIEM_FORGE_NODE_BIN_PATH
if: always()
working-directory: ./smoke-tests
run: cargo test --no-fail-fast
run: cargo test --no-fail-fast -- --test-threads=1

query:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -96,6 +101,7 @@ jobs:
run: cargo test --no-fail-fast

genesis:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -110,8 +116,8 @@ jobs:
if: always()
working-directory: ./tools/genesis
run: cargo test --no-fail-fast

tower:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -128,6 +134,7 @@ jobs:
run: cargo test --no-fail-fast

txs:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
Expand All @@ -143,3 +150,20 @@ jobs:
working-directory: ./tools/txs
# NOTE: upgrade tests which compile Move code, and then submit in the same thread will cause a stack overflow with the default rust stack size.
run: RUST_MIN_STACK=104857600 cargo test --no-fail-fast

rescue:
timeout-minutes: 60
needs: [build-framework]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: setup env
uses: ./.github/actions/build_env
- uses: actions/download-artifact@master
with:
name: framework-build
path: framework/
- name: rescue
if: always()
working-directory: ./tools/rescue
run: RUST_MIN_STACK=104857600 cargo test --no-fail-fast -- --test-threads=1
63 changes: 54 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,69 @@
// target/debug/ol-genesis-tools --fork --output-path /opt/genesis_from_snapshot.blob --snapshot-path /Users/gsimsek/code/libra-main/ol/devnet/snapshot/state_ver_267.54ab`
"configurations": [
{
"name": "framework-upgrade",
"name": "rescue-script",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
// "--release",
"-p",
"libra-framework"
"rescue"
],
},
"args": [
"upgrade",
"-o",
"${workspaceFolder}/framework/releases/framework_upgrade",
"--core-modules", "move-stdlib",
"-f",
"${workspaceFolder}/framework",
"rescue-tx",
"--data-path",
// "/root/test-db/db",
"/root/dbarchive/data_bak_2023-12-11/db",
// "--script-path",
// "${workspaceFolder}/tools/rescue/fixtures/rescue_framework_script",
"--framework-upgrade"
],
"cwd": "${workspaceFolder}"
},
{
"name": "rescue-verify",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"rescue"
],
},
"args": [
"bootstrap",
// "/root/test-db/db",
"/root/dbarchive/data_bak_2023-12-11/db",
"--genesis-txn-file",
"/root/dbarchive/data_bak_2023-12-11/db/rescue.blob",
"--waypoint-to-verify",
"2471146:3d54561e00f0dccaf696467ec2ea47f9bf6149536e9e4e66f4bf742742f5a0cc"
],
"cwd": "${workspaceFolder}"
},
{
"name": "rescue-apply",
"type": "lldb",
"request": "launch",
"cargo": {
"args": [
"build",
"-p",
"rescue"
],
},
"args": [
"bootstrap",
// "/root/test-db/db",
"/root/dbarchive/data_bak_2023-12-11/db",
"--genesis-txn-file",
"/root/dbarchive/data_bak_2023-12-11/db/rescue.blob",
"--waypoint-to-verify",
"2471146:3d54561e00f0dccaf696467ec2ea47f9bf6149536e9e4e66f4bf742742f5a0cc",
"--commit",
],
"cwd": "${workspaceFolder}"
},
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ rust-version = "1.70.0"
libra-cached-packages = { path = "framework/cached-packages" }
libra-config = { path = "tools/config" }
libra-framework = { path = "framework" }
libra-genesis-tools = { path = "tools/genesis" }
libra-query = { path = "tools/query" }
libra-smoke-tests = { path = "smoke-tests" }
libra-tower = { path = "tools/tower" }
Expand Down Expand Up @@ -63,6 +64,7 @@ diem-types = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db
diem-gas = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
diem-vm = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
diem-vm-genesis = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
diem-vm-types = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
diem-executor = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
diem-framework = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
diem-cached-packages = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
Expand Down Expand Up @@ -320,6 +322,7 @@ move-command-line-common = { git = "https://github.com/0LNetworkCommunity/diem.g
move-compiler = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
move-model = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
move-vm-test-utils = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }
move-vm-types = { git = "https://github.com/0LNetworkCommunity/diem.git", rev = "db1137ba1" }

# uses a profile similar to `cli` in Diem/Cargo.toml
# optimized for performance and size
Expand All @@ -342,8 +345,11 @@ split-debuginfo = "unpacked"
lto = false
incremental = true

[profile.test]
inherits = "dev"

# # This is a temporary workaround to avoid multiple library
# # definitions for LZ4 (caused by rust-rocksdb).
# # This will be removed once our pull requests land.
[patch.crates-io]
serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection", rev = "839aed62a20ddccf043c08961cfe74875741ccba" }
serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection", rev = "839aed62a20ddccf043c08961cfe74875741ccba" }
53 changes: 34 additions & 19 deletions framework/libra-framework/sources/code.move
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module diem_framework::code {
use std::error;
use std::signer;
use std::vector;
use std::features;

use diem_framework::util;
use diem_framework::system_addresses;
use diem_std::copyable_any::Any;
Expand Down Expand Up @@ -130,7 +128,8 @@ module diem_framework::code {
/// Publishes a package at the given signer's address. The caller must provide package metadata describing the
/// package.
public fun publish_package(owner: &signer, pack: PackageMetadata, code: vector<vector<u8>>) acquires PackageRegistry {
// Disallow incompatible upgrade mode. Governance can decide later if this should be reconsidered.
// Disallow incompatible upgrade mode. Governance can decide later if
// this should be reconsidered.
assert!(
pack.upgrade_policy.policy > upgrade_policy_arbitrary().policy,
error::invalid_argument(EINCOMPATIBLE_POLICY_DISABLED),
Expand All @@ -146,15 +145,24 @@ module diem_framework::code {

// Check package against conflicts
let module_names = get_module_names(&pack);
let packages = &mut borrow_global_mut<PackageRegistry>(addr).packages;
let len = vector::length(packages);
let index = len;

// E.g (stdlib, diem-stdlib, libra-framework)
let current_packages = &mut borrow_global_mut<PackageRegistry>(addr).packages;
let current_package_len = vector::length(current_packages);

let index = current_package_len;
let i = 0;
let upgrade_number = 0;
while (i < len) {
let old = vector::borrow(packages, i);
// for every package (e.g. stdlib, libra-framework) we have installed (old)
// let's check to see if the package can either:
// a) be upgraded to new using same namespace
// b) can coexist with new existing installation
while (i < current_package_len) {
let old = vector::borrow(current_packages, i);
if (old.name == pack.name) {

upgrade_number = old.upgrade_number + 1;

check_upgradability(old, &pack, &module_names);
index = i;
} else {
Expand All @@ -168,19 +176,15 @@ module diem_framework::code {

// Update registry
let policy = pack.upgrade_policy;
if (index < len) {
*vector::borrow_mut(packages, index) = pack
if (index < current_package_len) {
*vector::borrow_mut(current_packages, index) = pack
} else {
vector::push_back(packages, pack)
vector::push_back(current_packages, pack)
};

// Request publish
if (features::code_dependency_check_enabled())
request_publish_with_allowed_deps(addr, module_names, allowed_deps, code, policy.policy)
else
// The new `request_publish_with_allowed_deps` has not yet rolled out, so call downwards
// compatible code.
request_publish(addr, module_names, code, policy.policy)
// Commit note: there is only this option since other `request_publish`
// is deprecated
request_publish_with_allowed_deps(addr, module_names, allowed_deps,code, policy.policy);
}

/// Same as `publish_package` but as an entry function which can be called as a transaction. Because
Expand All @@ -195,7 +199,9 @@ module diem_framework::code {

/// Checks whether the given package is upgradable, and returns true if a compatibility check is needed.
fun check_upgradability(
old_pack: &PackageMetadata, new_pack: &PackageMetadata, new_modules: &vector<String>) {
old_pack: &PackageMetadata, new_pack: &PackageMetadata, new_modules:
&vector<String>) {

assert!(old_pack.upgrade_policy.policy < upgrade_policy_immutable().policy,
error::invalid_argument(EUPGRADE_IMMUTABLE));
assert!(can_change_upgrade_policy_to(old_pack.upgrade_policy, new_pack.upgrade_policy),
Expand Down Expand Up @@ -304,6 +310,15 @@ module diem_framework::code {
module_names
}

#[view]
public fun get_module_names_for_package_index(addr: address, idx: u64): vector<String>
acquires PackageRegistry {
let current_packages =
&borrow_global<PackageRegistry>(addr).packages;
let pack = vector::borrow(current_packages, idx);
get_module_names(pack)
}

/// Native function to initiate module loading
native fun request_publish(
owner: address,
Expand Down
Loading
Loading