Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
172 changes: 50 additions & 122 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ bcs = { git = "https://github.com/movementlabsxyz/bcs.git", rev = "bc16d2d39caba
better_any = "0.1.1"
bellman = { version = "0.13.1", default-features = false }
# Bumped down to 0.3 due to https://github.com/diesel-rs/diesel/issues/4477
bigdecimal = { version = "0.4.0", features = ["serde"] }
bigdecimal = { version = "0.3.0", features = ["serde"] }
version-compare = "0.1.1"
bitvec = "1.0.1"
blake2 = "0.10.4"
Expand Down
12 changes: 6 additions & 6 deletions aptos-move/framework/aptos-framework/doc/aptos_coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Only callable in tests and testnets where the core resources account exists.
Create delegated token for the address so the account could claim MintCapability later.


<pre><code><b>public</b> entry <b>fun</b> <a href="aptos_coin.md#0x1_aptos_coin_delegate_mint_capability">delegate_mint_capability</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <b>to</b>: <b>address</b>)
<pre><code><b>public</b> entry <b>fun</b> <a href="aptos_coin.md#0x1_aptos_coin_delegate_mint_capability">delegate_mint_capability</a>(<a href="account.md#0x1_account">account</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <b>to</b>: <b>address</b>)
</code></pre>


Expand All @@ -405,11 +405,11 @@ Create delegated token for the address so the account could claim MintCapability
<summary>Implementation</summary>


<pre><code><b>public</b> entry <b>fun</b> <a href="aptos_coin.md#0x1_aptos_coin_delegate_mint_capability">delegate_mint_capability</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <b>to</b>: <b>address</b>) <b>acquires</b> <a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a> {
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(<a href="account.md#0x1_account">account</a>);
<pre><code><b>public</b> entry <b>fun</b> <a href="aptos_coin.md#0x1_aptos_coin_delegate_mint_capability">delegate_mint_capability</a>(<a href="account.md#0x1_account">account</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <b>to</b>: <b>address</b>) <b>acquires</b> <a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a> {
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(&<a href="account.md#0x1_account">account</a>);
<b>let</b> delegations = &<b>mut</b> <b>borrow_global_mut</b>&lt;<a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a>&gt;(@aptos_framework).inner;
<b>if</b> (!<b>exists</b>&lt;<a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a>&gt;(<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(<a href="account.md#0x1_account">account</a>))) {
<b>move_to</b>(<a href="account.md#0x1_account">account</a>, <a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a> { inner: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>[] });
<b>if</b> (!<b>exists</b>&lt;<a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a>&gt;(<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(&<a href="account.md#0x1_account">account</a>))) {
<b>move_to</b>(&<a href="account.md#0x1_account">account</a>, <a href="aptos_coin.md#0x1_aptos_coin_Delegations">Delegations</a> { inner: <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>[] });
};
<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_for_each_ref">vector::for_each_ref</a>(delegations, |element| {
<b>let</b> element: &<a href="aptos_coin.md#0x1_aptos_coin_DelegatedMintCapability">DelegatedMintCapability</a> = element;
Expand Down Expand Up @@ -633,7 +633,7 @@ Claim the delegated mint capability and destroy the delegated token.
### Function `delegate_mint_capability`


<pre><code><b>public</b> entry <b>fun</b> <a href="aptos_coin.md#0x1_aptos_coin_delegate_mint_capability">delegate_mint_capability</a>(<a href="account.md#0x1_account">account</a>: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <b>to</b>: <b>address</b>)
<pre><code><b>public</b> entry <b>fun</b> <a href="aptos_coin.md#0x1_aptos_coin_delegate_mint_capability">delegate_mint_capability</a>(<a href="account.md#0x1_account">account</a>: <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <b>to</b>: <b>address</b>)
</code></pre>


Expand Down
2 changes: 0 additions & 2 deletions aptos-move/framework/aptos-framework/doc/aptos_governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -1885,8 +1885,6 @@ Only called in testnet where the core resources account exists and has been gran
<pre><code><b>public</b> <b>fun</b> <a href="aptos_governance.md#0x1_aptos_governance_get_signer_testnet_only">get_signer_testnet_only</a>(
core_resources: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, signer_address: <b>address</b>): <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a> <b>acquires</b> <a href="aptos_governance.md#0x1_aptos_governance_GovernanceResponsbility">GovernanceResponsbility</a> {
<a href="system_addresses.md#0x1_system_addresses_assert_core_resource">system_addresses::assert_core_resource</a>(core_resources);
// Core resources <a href="account.md#0x1_account">account</a> only <b>has</b> mint capability in tests/testnets.
<b>assert</b>!(<a href="aptos_coin.md#0x1_aptos_coin_has_mint_capability">aptos_coin::has_mint_capability</a>(core_resources), <a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_unauthenticated">error::unauthenticated</a>(<a href="aptos_governance.md#0x1_aptos_governance_EUNAUTHORIZED">EUNAUTHORIZED</a>));
<a href="aptos_governance.md#0x1_aptos_governance_get_signer">get_signer</a>(signer_address)
}
</code></pre>
Expand Down
5 changes: 5 additions & 0 deletions aptos-move/framework/aptos-framework/doc/governed_gas_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ Initializes the governed gas pool around a resource account creation seed.
) {
<a href="system_addresses.md#0x1_system_addresses_assert_aptos_framework">system_addresses::assert_aptos_framework</a>(aptos_framework);

// <b>return</b> <b>if</b> the governed gas pool <b>has</b> already been initialized
<b>if</b> (<b>exists</b>&lt;<a href="governed_gas_pool.md#0x1_governed_gas_pool_GovernedGasPool">GovernedGasPool</a>&gt;(<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(aptos_framework))) {
<b>return</b>
};

// generate a seed <b>to</b> be used <b>to</b> create the resource <a href="account.md#0x1_account">account</a> hosting the delegation pool
<b>let</b> seed = <a href="governed_gas_pool.md#0x1_governed_gas_pool_create_resource_account_seed">create_resource_account_seed</a>(delegation_pool_creation_seed);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ fungible asset to it. This emits an deposit event.
- [Module-level Specification](#module-level-spec)


<pre><code><b>use</b> <a href="dispatchable_fungible_asset.md#0x1_dispatchable_fungible_asset">0x1::dispatchable_fungible_asset</a>;
<pre><code><b>use</b> <a href="account.md#0x1_account">0x1::account</a>;
<b>use</b> <a href="dispatchable_fungible_asset.md#0x1_dispatchable_fungible_asset">0x1::dispatchable_fungible_asset</a>;
<b>use</b> <a href="fungible_asset.md#0x1_fungible_asset">0x1::fungible_asset</a>;
<b>use</b> <a href="object.md#0x1_object">0x1::object</a>;
<b>use</b> <a href="../../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option">0x1::option</a>;
Expand Down Expand Up @@ -558,6 +559,8 @@ Transfer <code>amount</code> of fungible asset from sender's primary store to re
recipient: <b>address</b>,
amount: u64,
) <b>acquires</b> <a href="primary_fungible_store.md#0x1_primary_fungible_store_DeriveRefPod">DeriveRefPod</a> {
// Create <a href="account.md#0x1_account">account</a> <b>if</b> it does not yet exist, otherwise funds may get stuck in new accounts.
<a href="account.md#0x1_account_create_account_if_does_not_exist">account::create_account_if_does_not_exist</a>(recipient);
<b>let</b> sender_store = <a href="primary_fungible_store.md#0x1_primary_fungible_store_ensure_primary_store_exists">ensure_primary_store_exists</a>(<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(sender), metadata);
// Check <b>if</b> the sender store <a href="object.md#0x1_object">object</a> <b>has</b> been burnt or not. If so, unburn it first.
<a href="primary_fungible_store.md#0x1_primary_fungible_store_may_be_unburn">may_be_unburn</a>(sender, sender_store);
Expand Down
89 changes: 46 additions & 43 deletions crates/aptos-runtimes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,57 @@ const MAX_THREAD_NAME_LENGTH: usize = 12;
/// Returns a tokio runtime with named threads.
/// This is useful for tracking threads when debugging.
pub fn spawn_named_runtime(thread_name: String, num_worker_threads: Option<usize>) -> Runtime {
spawn_named_runtime_with_start_hook(thread_name, num_worker_threads, || {})
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Failed to build dummy runtime")
}

pub fn spawn_named_runtime_with_start_hook<F>(
thread_name: String,
num_worker_threads: Option<usize>,
on_thread_start: F,
) -> Runtime
where
F: Fn() + Send + Sync + 'static,
{
const MAX_BLOCKING_THREADS: usize = 64;
// pub fn spawn_named_runtime_with_start_hook<F>(
// thread_name: String,
// num_worker_threads: Option<usize>,
// on_thread_start: F,
// ) -> Runtime
// where
// F: Fn() + Send + Sync + 'static,
// {
// const MAX_BLOCKING_THREADS: usize = 64;

// Verify the given name has an appropriate length
if thread_name.len() > MAX_THREAD_NAME_LENGTH {
panic!(
"The given runtime thread name is too long! Max length: {}, given name: {}",
MAX_THREAD_NAME_LENGTH, thread_name
);
}
// // Verify the given name has an appropriate length
// if thread_name.len() > MAX_THREAD_NAME_LENGTH {
// panic!(
// "The given runtime thread name is too long! Max length: {}, given name: {}",
// MAX_THREAD_NAME_LENGTH, thread_name
// );
// }

// Create the runtime builder
let atomic_id = AtomicUsize::new(0);
let thread_name_clone = thread_name.clone();
let mut builder = Builder::new_multi_thread();
builder
.thread_name_fn(move || {
let id = atomic_id.fetch_add(1, Ordering::SeqCst);
format!("{}-{}", thread_name_clone, id)
})
.on_thread_start(on_thread_start)
.disable_lifo_slot()
// Limit concurrent blocking tasks from spawn_blocking(), in case, for example, too many
// Rest API calls overwhelm the node.
.max_blocking_threads(MAX_BLOCKING_THREADS)
.enable_all();
if let Some(num_worker_threads) = num_worker_threads {
builder.worker_threads(num_worker_threads);
}
// // Create the runtime builder
// let atomic_id = AtomicUsize::new(0);
// let thread_name_clone = thread_name.clone();
// let mut builder = Builder::new_multi_thread();
// builder
// .thread_name_fn(move || {
// let id = atomic_id.fetch_add(1, Ordering::SeqCst);
// format!("{}-{}", thread_name_clone, id)
// })
// .on_thread_start(on_thread_start)
// .disable_lifo_slot()
// // Limit concurrent blocking tasks from spawn_blocking(), in case, for example, too many
// // Rest API calls overwhelm the node.
// .max_blocking_threads(MAX_BLOCKING_THREADS)
// .enable_all();
// if let Some(num_worker_threads) = num_worker_threads {
// builder.worker_threads(num_worker_threads);
// }

// Spawn and return the runtime
builder.build().unwrap_or_else(|error| {
panic!(
"Failed to spawn named runtime! Name: {:?}, Error: {:?}",
thread_name, error
)
})
}
// // Spawn and return the runtime
// builder.build().unwrap_or_else(|error| {
// panic!(
// "Failed to spawn named runtime! Name: {:?}, Error: {:?}",
// thread_name, error
// )
// })
// }

/// Returns a rayon threadpool with threads.
/// This is useful for tracking threads when debugging.
Expand Down
42 changes: 17 additions & 25 deletions crates/aptos/src/common/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ impl CliCommand<()> for InitTool {
network
} else {
eprintln!(
"Choose network from [devnet, testnet, local, custom | defaults to devnet]. For testnet, start over and run movement init --skip-faucet"
"Choose network from [mainnet, testnet, local, custom]. For testnet, start over and run movement init --skip-faucet"
);
let input = read_line("network")?;
let input = input.trim();
if input.is_empty() {
eprintln!("No network given, using devnet...");
Network::Devnet
eprintln!("No network given, using testnet...");
Network::Testnet
} else {
Network::from_str(input)?
}
Expand All @@ -137,20 +137,15 @@ impl CliCommand<()> for InitTool {

// Ensure that there is at least a REST URL set for the network
match network {
// Network::Mainnet => {
// profile_config.rest_url =
// Some("https://fullnode.mainnet.aptoslabs.com".to_string());
// profile_config.faucet_url = None;
// },
Network::Testnet => {
Network::Mainnet => {
profile_config.rest_url =
Some("https://aptos.testnet.suzuka.movementlabs.xyz/v1/".to_string());
profile_config.faucet_url =
Some("https://faucet.testnet.suzuka.movementlabs.xyz/".to_string());
Some("https://mainnet.movementnetwork.xyz/v1".to_string());
profile_config.faucet_url = None;
},
Network::Devnet => {
profile_config.rest_url = Some("https://aptos.devnet.inola.movementlabs.xyz/v1".to_string());
profile_config.faucet_url = Some("https://faucet.devnet.inola.movementlabs.xyz".to_string());
Network::Testnet => {
profile_config.rest_url =
Some("https://testnet.bardock.movementnetwork.xyz/v1".to_string());
profile_config.faucet_url = None;
},
Network::Local => {
profile_config.rest_url = Some("http://localhost:8080".to_string());
Expand Down Expand Up @@ -334,9 +329,9 @@ impl CliCommand<()> for InitTool {
}
} else if account_exists {
eprintln!("Account {} has been already found onchain", address);
} /* else if network == Network::Mainnet {
} else if network == Network::Mainnet {
eprintln!("Account {} does not exist, you will need to create and fund the account by transferring funds from another account", address);
} */ else {
} else {
eprintln!("Account {} has been initialized locally, but you must transfer coins to it to create the account onchain", address);
}

Expand Down Expand Up @@ -448,19 +443,17 @@ impl InitTool {
/// Any command using this, will be simpler to setup as profiles
#[derive(Copy, Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub enum Network {
// Mainnet,
Mainnet,
Testnet,
Devnet,
Local,
Custom,
}

impl Display for Network {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
// Network::Mainnet => "mainnet",
Network::Mainnet => "mainnet",
Network::Testnet => "testnet",
Network::Devnet => "devnet",
Network::Local => "local",
Network::Custom => "custom",
})
Expand All @@ -472,14 +465,13 @@ impl FromStr for Network {

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s.to_lowercase().trim() {
// "mainnet" => Self::Mainnet,
"mainnet" => Self::Mainnet,
"testnet" => Self::Testnet,
"devnet" => Self::Devnet,
"local" => Self::Local,
"custom" => Self::Custom,
str => {
return Err(CliError::CommandArgumentError(format!(
"Invalid network {}. Must be one of [devnet, testnet, local, custom]",
"Invalid network {}. Must be one of [mainnet, testnet, local, custom]",
str
)));
},
Expand All @@ -489,6 +481,6 @@ impl FromStr for Network {

impl Default for Network {
fn default() -> Self {
Self::Devnet
Self::Testnet
}
}
42 changes: 18 additions & 24 deletions crates/aptos/src/move_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ impl FrameworkPackageArgs {
prompt_options: PromptOptions,
) -> CliTypedResult<()> {
const APTOS_FRAMEWORK: &str = "AptosFramework";
const APTOS_GIT_PATH: &str = "https://github.com/aptos-labs/aptos-core.git";
const APTOS_GIT_PATH: &str = "https://github.com/movementlabsxyz/aptos-core.git";
const SUBDIR_PATH: &str = "aptos-move/framework/aptos-framework";
const DEFAULT_BRANCH: &str = "mainnet";
const DEFAULT_BRANCH: &str = "movement";

let move_toml = package_dir.join(SourcePackageLayout::Manifest.path());
check_if_file_exists(move_toml.as_path(), prompt_options)?;
Expand All @@ -209,30 +209,24 @@ impl FrameworkPackageArgs {
// Add the framework dependency if it's provided
let mut dependencies = BTreeMap::new();
if let Some(ref path) = self.framework_local_dir {
dependencies.insert(
APTOS_FRAMEWORK.to_string(),
Dependency {
local: Some(path.display().to_string()),
git: None,
rev: None,
subdir: None,
aptos: None,
address: None,
},
);
dependencies.insert(APTOS_FRAMEWORK.to_string(), Dependency {
local: Some(path.display().to_string()),
git: None,
rev: None,
subdir: None,
aptos: None,
address: None,
});
} else {
let git_rev = self.framework_git_rev.as_deref().unwrap_or(DEFAULT_BRANCH);
dependencies.insert(
APTOS_FRAMEWORK.to_string(),
Dependency {
local: None,
git: Some(APTOS_GIT_PATH.to_string()),
rev: Some(git_rev.to_string()),
subdir: Some(SUBDIR_PATH.to_string()),
aptos: None,
address: None,
},
);
dependencies.insert(APTOS_FRAMEWORK.to_string(), Dependency {
local: None,
git: Some(APTOS_GIT_PATH.to_string()),
rev: Some(git_rev.to_string()),
subdir: Some(SUBDIR_PATH.to_string()),
aptos: None,
address: None,
});
}

let manifest = MovePackageManifest {
Expand Down
18 changes: 18 additions & 0 deletions movement.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Movement < Formula
desc "Movement CLI for interacting with the Movement network"
homepage "https://github.com/movementlabsxyz/aptos-core"
url "file://#{Dir.pwd}/movement-cli-v3.5.tar.gz"
sha256 "0626826ffb341498fe6184de96d1a24f30d91f21904a4a105d527d85d874a7f9"
version "0.0.1-alpha"

depends_on "rust" => :build
depends_on "cmake" => :build

def install
system "cargo", "install", *std_cargo_args(path: "crates/aptos"), "--bin", "movement"
end

test do
system "#{bin}/movement", "--help"
end
end
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.78.0"
channel = "stable"

# Note: we don't specify cargofmt in our toolchain because we rely on
# the nightly version of cargofmt and verify formatting in CI/CD.
Expand Down