From 65ce68bde2a3ae999d6d4c02417e9e3071eef3ad Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Fri, 29 Nov 2024 11:18:50 +0100 Subject: [PATCH] aptos: upgrade to 4.5.0 (libs + toolchain) This change bumps libraries and toolchain of Aptos to the Aptos CLI v4.5.0 version. The tests are slightly changed to accommodate the recent changes in the coin library that disallows coin operations on unitialized coins. --- aptos/Dockerfile.base | 2 +- aptos/coin/Move.toml | 2 +- aptos/deployer/Move.toml | 2 +- aptos/examples/core_messages/sources/sender.move | 4 ++-- aptos/nft_bridge/Move.toml | 8 ++++---- aptos/token_bridge/Move.toml | 8 ++++---- aptos/wormhole/Move.toml | 8 ++++---- aptos/wormhole/sources/wormhole.move | 15 +++++++++++++-- 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/aptos/Dockerfile.base b/aptos/Dockerfile.base index b6dc5cac99..daa128ca0d 100644 --- a/aptos/Dockerfile.base +++ b/aptos/Dockerfile.base @@ -8,7 +8,7 @@ RUN git clone https://github.com/aptos-labs/aptos-core.git WORKDIR /tmp/aptos-core # Build aptos 2.0.3 -RUN git reset --hard 6f83bc6d02207298b2dee91133d75538789bf582 +RUN git reset --hard 47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3 RUN cargo build -p aptos --profile cli FROM rust:1.62@sha256:5777f201f507075309c4d2d1c1e8d8219e654ae1de154c844341050016a64a0c as export-stage diff --git a/aptos/coin/Move.toml b/aptos/coin/Move.toml index 87b0c047b1..7e7a49573a 100644 --- a/aptos/coin/Move.toml +++ b/aptos/coin/Move.toml @@ -4,7 +4,7 @@ version = "0.0.1" upgrade_policy = "compatible" [dependencies] -MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } +MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } [dev-addresses] wrapped_coin = "0xBEEF" diff --git a/aptos/deployer/Move.toml b/aptos/deployer/Move.toml index 31d0c3bb3d..52e42a6b5e 100644 --- a/aptos/deployer/Move.toml +++ b/aptos/deployer/Move.toml @@ -4,7 +4,7 @@ version = '1.0.0' [dependencies.AptosFramework] git = 'https://github.com/aptos-labs/aptos-core.git' -rev = '6f83bc6d02207298b2dee91133d75538789bf582' +rev = '47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3' subdir = 'aptos-move/framework/aptos-framework' [dev-addresses] diff --git a/aptos/examples/core_messages/sources/sender.move b/aptos/examples/core_messages/sources/sender.move index fb0b64844f..cd382f3939 100644 --- a/aptos/examples/core_messages/sources/sender.move +++ b/aptos/examples/core_messages/sources/sender.move @@ -60,6 +60,8 @@ module core_messages::sender_test { public fun test_send_message(aptos_framework: &signer, user: &signer) { let message_fee = 100; timestamp::set_time_has_started_for_testing(aptos_framework); + let (burn_cap, mint_cap) = aptos_coin::initialize_for_test(aptos_framework); + wormhole::init_test( 22, 1, @@ -69,8 +71,6 @@ module core_messages::sender_test { ); sender::init_module_test(); - let (burn_cap, mint_cap) = aptos_coin::initialize_for_test(aptos_framework); - // create user account and airdrop coins account::create_account_for_test(signer::address_of(user)); coin::register(user); diff --git a/aptos/nft_bridge/Move.toml b/aptos/nft_bridge/Move.toml index ef97924d1c..2c1f123020 100644 --- a/aptos/nft_bridge/Move.toml +++ b/aptos/nft_bridge/Move.toml @@ -3,10 +3,10 @@ name = "NFTBridge" version = "0.0.1" [dependencies] -AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } +AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } Wormhole = { local = "../wormhole/" } TokenBridge = { local = "../token_bridge/" } Deployer = { local = "../deployer/" } diff --git a/aptos/token_bridge/Move.toml b/aptos/token_bridge/Move.toml index 0e7e36b3e3..5dc4c280df 100644 --- a/aptos/token_bridge/Move.toml +++ b/aptos/token_bridge/Move.toml @@ -3,10 +3,10 @@ name = "TokenBridge" version = "0.0.1" [dependencies] -AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } +AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } Wormhole = { local = "../wormhole/" } Deployer = { local = "../deployer/" } diff --git a/aptos/wormhole/Move.toml b/aptos/wormhole/Move.toml index 83f24fdc40..05faea5247 100644 --- a/aptos/wormhole/Move.toml +++ b/aptos/wormhole/Move.toml @@ -4,10 +4,10 @@ version = "0.0.1" upgrade_policy = "compatible" [dependencies] -AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } -AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "6f83bc6d02207298b2dee91133d75538789bf582" } +AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-framework/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +MoveStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/move-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +AptosStdlib = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-stdlib/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } +AptosToken = { git = "https://github.com/aptos-labs/aptos-core.git", subdir = "aptos-move/framework/aptos-token/", rev = "47f0bf397eb5ca43257bfa775a6b28e7b7faf8b3" } Deployer = { local = "../deployer/" } # U256 = { git = "https://github.com/pontem-network/u256", rev = "main" } diff --git a/aptos/wormhole/sources/wormhole.move b/aptos/wormhole/sources/wormhole.move index 99c6bb238a..625a019ad3 100644 --- a/aptos/wormhole/sources/wormhole.move +++ b/aptos/wormhole/sources/wormhole.move @@ -128,6 +128,17 @@ module wormhole::wormhole { initial_guardian: vector, message_fee: u64, ): signer { + // Wormhole requires AptosCoin to be initialized; so we iniatilize it + // if it's not initialized already. If you need AptosCoin in the tests + // initialize it before calling this function because AptosCoin can be + // initialized only once. + if (!coin::is_coin_initialized()) { + let aptos_framework = std::account::create_account_for_test(@aptos_framework); + let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(&aptos_framework); + coin::destroy_mint_cap(mint_cap); + coin::destroy_burn_cap(burn_cap); + }; + let deployer = account::create_account_for_test(@deployer); let (wormhole, signer_cap) = account::create_resource_account(&deployer, b"wormhole"); init_internal( @@ -172,9 +183,9 @@ module wormhole::wormhole_test { #[test(aptos_framework = @aptos_framework)] public fun test_publish_message(aptos_framework: &signer) { - setup(100); - let (burn_cap, mint_cap) = aptos_coin::initialize_for_test(aptos_framework); + + setup(100); let fees = coin::mint(100, &mint_cap); let emitter_cap = wormhole::register_emitter();