Skip to content

Subroutine calls using the new JAL instruction #7085

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
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
3,987 changes: 722 additions & 3,265 deletions Cargo.lock

Large diffs are not rendered by default.

84 changes: 50 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ resolver = "2"
members = [
"forc",
"forc-pkg",
"forc-plugins/forc-client",
"forc-plugins/forc-crypto",
"forc-plugins/forc-debug",
"forc-plugins/forc-doc",
"forc-plugins/forc-fmt",
"forc-plugins/forc-lsp",
"forc-plugins/forc-node",
"forc-plugins/forc-migrate",
"forc-plugins/forc-publish",
"forc-plugins/forc-tx",
"forc-test",
# "forc-plugins/forc-client",
# "forc-plugins/forc-crypto",
# "forc-plugins/forc-debug",
# "forc-plugins/forc-doc",
# "forc-plugins/forc-fmt",
# "forc-plugins/forc-lsp",
# "forc-plugins/forc-node",
# "forc-plugins/forc-migrate",
# "forc-plugins/forc-publish",
# "forc-plugins/forc-tx",
# "forc-test",
"forc-tracing",
"forc-util",
"scripts/mdbook-forc-documenter",
Expand All @@ -28,7 +28,7 @@ members = [
"sway-types",
"sway-utils",
"swayfmt",
"test",
# "test",
]
exclude = ["examples/*", "swayfmt/test_macros", "forc-test/test_data"]

Expand All @@ -47,21 +47,21 @@ repository = "https://github.com/FuelLabs/sway"

forc = { path = "forc/", version = "0.67.0" }
forc-pkg = { path = "forc-pkg/", version = "0.67.0" }
forc-test = { path = "forc-test/", version = "0.67.0" }
# forc-test = { path = "forc-test/", version = "0.67.0" }
forc-tracing = { path = "forc-tracing/", version = "0.67.0" }
forc-util = { path = "forc-util/", version = "0.67.0" }

# Forc plugins
forc-plugins = { path = "forc-plugins/", version = "0.67.0" }
forc-client = { path = "forc-plugins/forc-client/", version = "0.67.0" }
forc-crypto = { path = "forc-plugins/forc-crypto/", version = "0.67.0" }
forc-debug = { path = "forc-plugins/forc-debug/", version = "0.67.0" }
forc-doc = { path = "forc-plugins/forc-doc/", version = "0.67.0" }
forc-fmt = { path = "forc-plugins/forc-fmt/", version = "0.67.0" }
forc-lsp = { path = "forc-plugins/forc-lsp/", version = "0.67.0" }
forc-migrate = { path = "forc-plugins/forc-migrate/", version = "0.67.0" }
forc-publish = { path = "forc-plugins/forc-publish/", version = "0.67.0" }
forc-tx = { path = "forc-plugins/forc-tx/", version = "0.67.0" }
# forc-plugins = { path = "forc-plugins/", version = "0.67.0" }
# forc-client = { path = "forc-plugins/forc-client/", version = "0.67.0" }
# forc-crypto = { path = "forc-plugins/forc-crypto/", version = "0.67.0" }
# forc-debug = { path = "forc-plugins/forc-debug/", version = "0.67.0" }
# forc-doc = { path = "forc-plugins/forc-doc/", version = "0.67.0" }
# forc-fmt = { path = "forc-plugins/forc-fmt/", version = "0.67.0" }
# forc-lsp = { path = "forc-plugins/forc-lsp/", version = "0.67.0" }
# forc-migrate = { path = "forc-plugins/forc-migrate/", version = "0.67.0" }
# forc-publish = { path = "forc-plugins/forc-publish/", version = "0.67.0" }
# forc-tx = { path = "forc-plugins/forc-tx/", version = "0.67.0" }

sway-ast = { path = "sway-ast/", version = "0.67.0" }
sway-core = { path = "sway-core/", version = "0.67.0" }
Expand Down Expand Up @@ -89,24 +89,24 @@ fuel-abi-types = "0.8"
# Although ALL verions are "X.Y", we need the complete semver for
# fuel-core-client as the GitHub Actions workflow parses this value to pull down
# the correct tarball
fuel-core-client = { version = "0.41.4", default-features = false }
fuel-core-types = { version = "0.41", default-features = false }
fuel-core-client = { version = "0.42", default-features = false }
fuel-core-types = { version = "0.42", default-features = false }

# Dependencies from the `fuels-rs` repository:

fuels = "0.70"
fuels-core = "0.70"
fuels-accounts = "0.70"
fuels = "0.71"
fuels-core = "0.71"
fuels-accounts = "0.71"

# Dependencies from the `fuel-vm` repository:
fuel-asm = "0.59"
fuel-crypto = "0.59"
fuel-types = "0.59"
fuel-tx = "0.59"
fuel-vm = "0.59"
fuel-asm = "0.60"
fuel-crypto = "0.60"
fuel-types = "0.60"
fuel-tx = "0.60"
fuel-vm = "0.60"

# Dependencies from the `forc-wallet` repository:
forc-wallet = "0.12"
forc-wallet = "0.13"

#
# External dependencies
Expand Down Expand Up @@ -255,3 +255,19 @@ vte = "0.13"
walkdir = "2.3"
whoami = "1.5"
wiremock = "0.6"

[patch.crates-io]
fuel-asm = { path = "../fuel-vm/fuel-asm" }
fuel-crypto = { path = "../fuel-vm/fuel-crypto" }
fuel-tx = { path = "../fuel-vm/fuel-tx" }
fuel-vm = { path = "../fuel-vm/fuel-vm" }
fuel-types = { path = "../fuel-vm/fuel-types" }
fuel-core-storage = { path = "../fuel-core/crates/storage" }
fuel-core-poa = { path = "../fuel-core/crates/services/consensus_module/poa" }
fuel-core-client = { path = "../fuel-core/crates/client" }
fuel-core-types = { path = "../fuel-core/crates/types" }
# fuel-core = { path = "../fuel-core" }
fuels = { path = "../fuels-rs/packages/fuels" }
fuels-core = { path = "../fuels-rs/packages/fuels-core" }
fuels-test-helpers = { path = "../fuels-rs/packages/fuels-test-helpers" }
fuels-accounts = { path = "../fuels-rs/packages/fuels-accounts" }
13 changes: 3 additions & 10 deletions forc-plugins/forc-crypto/src/keys/vanity.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use fuel_crypto::{fuel_types::Address, PublicKey, SecretKey};
use fuels_accounts::wallet::{generate_mnemonic_phrase, DEFAULT_DERIVATION_PATH_PREFIX};
// use fuels_accounts::wallet::{generate_mnemonic_phrase, DEFAULT_DERIVATION_PATH_PREFIX};
use fuels_core::types::{
bech32::{Bech32Address, FUEL_BECH32_HRP},
checksum_address::checksum_encode,
Expand Down Expand Up @@ -269,16 +269,9 @@ fn wallet_generator(
fn generate_wallet(use_mnemonic: bool) -> anyhow::Result<(Address, SecretKey, Option<String>)> {
let mut rng = rand::thread_rng();

let (private_key, mnemonic) = if use_mnemonic {
let mnemonic = generate_mnemonic_phrase(&mut rng, 24)?;
let account_ix = 0;
let derivation_path = format!("{DEFAULT_DERIVATION_PATH_PREFIX}/{account_ix}'/0/0");
let private_key =
SecretKey::new_from_mnemonic_phrase_with_path(&mnemonic, &derivation_path)?;
(private_key, Some(mnemonic))
} else {
let (private_key, mnemonic) =
(SecretKey::random(&mut rng), None)
};
;

let public = PublicKey::from(&private_key);
let hashed = public.hash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fn ra(instruction: Instruction) -> Option<String> {
Instruction::BAL(op) => Some(op.ra()),
Instruction::JMP(op) => Some(op.ra()),
Instruction::JNE(op) => Some(op.ra()),
Instruction::JAL(op) => Some(op.ra()),
Instruction::SMO(op) => Some(op.ra()),
Instruction::ADDI(op) => Some(op.ra()),
Instruction::ANDI(op) => Some(op.ra()),
Expand Down
2 changes: 1 addition & 1 deletion forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ clap = { workspace = true, features = ["cargo", "derive", "env"] }
clap_complete.workspace = true
clap_complete_fig.workspace = true
forc-pkg.workspace = true
forc-test.workspace = true
# forc-test.workspace = true
forc-tracing.workspace = true
forc-util = { workspace = true, features = ["tx"] }
fs_extra.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion forc/src/cli/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pub mod parse_bytecode;
pub mod plugins;
pub mod predicate_root;
pub mod template;
pub mod test;
// pub mod test;
pub mod update;
16 changes: 9 additions & 7 deletions forc/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use self::commands::{
addr2line, build, check, clean, completions, contract_id, init, new, parse_bytecode, plugins,
predicate_root, template, test, update,
predicate_root, template,
// test,
update,
};
use addr2line::Command as Addr2LineCommand;
use anyhow::anyhow;
Expand All @@ -19,7 +21,7 @@ pub use plugins::Command as PluginsCommand;
pub(crate) use predicate_root::Command as PredicateRootCommand;
use std::str::FromStr;
pub use template::Command as TemplateCommand;
pub use test::Command as TestCommand;
// pub use test::Command as TestCommand;
use tracing::metadata::LevelFilter;
pub use update::Command as UpdateCommand;

Expand All @@ -30,9 +32,9 @@ pub mod shared;
fn help() -> &'static str {
Box::leak(
format!(
"Examples:\n{}{}{}{}",
"Examples:\n{}{}{}",
plugins::examples(),
test::examples(),
// test::examples(),
build::examples(),
check::examples(),
)
Expand Down Expand Up @@ -74,8 +76,8 @@ enum Forc {
New(NewCommand),
Init(InitCommand),
ParseBytecode(ParseBytecodeCommand),
#[clap(visible_alias = "t")]
Test(TestCommand),
// #[clap(visible_alias = "t")]
// Test(TestCommand),
Update(UpdateCommand),
Plugins(PluginsCommand),
Template(TemplateCommand),
Expand Down Expand Up @@ -136,7 +138,7 @@ pub async fn run_cli() -> ForcResult<()> {
Forc::New(command) => new::exec(command),
Forc::ParseBytecode(command) => parse_bytecode::exec(command),
Forc::Plugins(command) => plugins::exec(command),
Forc::Test(command) => test::exec(command),
// Forc::Test(command) => test::exec(command),
Forc::Update(command) => update::exec(command),
Forc::Template(command) => template::exec(command),
Forc::ContractId(command) => contract_id::exec(command),
Expand Down
1 change: 1 addition & 0 deletions sway-core/src/asm_generation/finalized_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ fn print_instruction(op: &Instruction) {
Instruction::BAL(x) => f("BAL", x.unpack()),
Instruction::JMP(x) => f("JMP", x.unpack()),
Instruction::JNE(x) => f("JNE", x.unpack()),
Instruction::JAL(x) => f("JAL", x.unpack()),
Instruction::SMO(x) => f("SMO", x.unpack()),
Instruction::ADDI(x) => f("ADDI", x.unpack()),
Instruction::ANDI(x) => f("ANDI", x.unpack()),
Expand Down
Loading