Skip to content

Commit be13470

Browse files
committed
Compile panic expression to ABI error codes
1 parent cd86555 commit be13470

File tree

31 files changed

+664
-156
lines changed

31 files changed

+664
-156
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.68.1" }
8282
#
8383

8484
# Dependencies from the `fuel-abi-types` repository:
85-
fuel-abi-types = "0.8"
85+
fuel-abi-types = "0.11"
8686

8787
# Dependencies from the `fuel-core` repository:
8888
#
89-
# Although ALL verions are "X.Y", we need the complete semver for
89+
# Although ALL versions are "X.Y", we need the complete semver for
9090
# fuel-core-client as the GitHub Actions workflow parses this value to pull down
91-
# the correct tarball
91+
# the correct tarball.
9292
fuel-core-client = { version = "0.43.2", default-features = false }
9393
fuel-core-types = { version = "0.43", default-features = false }
9494

@@ -256,3 +256,9 @@ vte = "0.13"
256256
walkdir = "2.3"
257257
whoami = "1.5"
258258
wiremock = "0.6"
259+
260+
[patch.crates-io]
261+
fuels = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/abi-errors" }
262+
fuels-core = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/abi-errors" }
263+
fuels-accounts = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/abi-errors" }
264+
fuels-code-gen = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/abi-errors" }

forc-pkg/src/pkg.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,9 +1768,15 @@ pub fn compile(
17681768
metrics
17691769
);
17701770

1771+
let mut asm = match asm_res {
1772+
Err(_) => return fail(handler),
1773+
Ok(asm) => asm,
1774+
};
1775+
17711776
const ENCODING_V0: &str = "0";
17721777
const ENCODING_V1: &str = "1";
17731778
const SPEC_VERSION: &str = "1";
1779+
const SPEC_VERSION_ERROR_TYPE: &str = "1.1";
17741780

17751781
let mut program_abi = match pkg.target {
17761782
BuildTarget::Fuel => {
@@ -1782,6 +1788,7 @@ pub fn compile(
17821788
&handler,
17831789
&mut AbiContext {
17841790
program: typed_program,
1791+
panic_locations: &asm.panic_locations,
17851792
abi_with_callpaths: true,
17861793
type_ids_to_full_type_str: HashMap::<String, String>::new(),
17871794
},
@@ -1791,7 +1798,11 @@ pub fn compile(
17911798
} else {
17921799
ENCODING_V0.into()
17931800
},
1794-
SPEC_VERSION.into(),
1801+
if experimental.error_type {
1802+
SPEC_VERSION_ERROR_TYPE.into()
1803+
} else {
1804+
SPEC_VERSION.into()
1805+
}
17951806
),
17961807
Some(sway_build_config.clone()),
17971808
metrics
@@ -1805,11 +1816,8 @@ pub fn compile(
18051816
BuildTarget::EVM => {
18061817
// Merge the ABI output of ASM gen with ABI gen to handle internal constructors
18071818
// generated by the ASM backend.
1808-
let mut ops = match &asm_res {
1809-
Ok(ref asm) => match &asm.0.abi {
1810-
Some(ProgramABI::Evm(ops)) => ops.clone(),
1811-
_ => vec![],
1812-
},
1819+
let mut ops = match &asm.finalized_asm.abi {
1820+
Some(ProgramABI::Evm(ops)) => ops.clone(),
18131821
_ => vec![],
18141822
};
18151823

@@ -1828,20 +1836,13 @@ pub fn compile(
18281836
}
18291837
};
18301838

1831-
let entries = asm_res
1832-
.as_ref()
1833-
.map(|asm| asm.0.entries.clone())
1834-
.unwrap_or_default();
1835-
let entries = entries
1839+
let entries = asm
1840+
.finalized_asm
1841+
.entries
18361842
.iter()
18371843
.map(|finalized_entry| PkgEntry::from_finalized_entry(finalized_entry, engines))
18381844
.collect::<anyhow::Result<_>>()?;
18391845

1840-
let mut asm = match asm_res {
1841-
Err(_) => return fail(handler),
1842-
Ok(asm) => asm,
1843-
};
1844-
18451846
let bc_res = time_expr!(
18461847
pkg.name,
18471848
"compile asm to bytecode",
@@ -1976,12 +1977,16 @@ fn report_assembly_information(
19761977
data_section: sway_core::asm_generation::DataSectionInformation {
19771978
size: data_section_size,
19781979
used: compiled_asm
1979-
.0
1980+
.finalized_asm
19801981
.data_section
19811982
.iter_all_entries()
19821983
.map(|entry| calculate_entry_size(&entry))
19831984
.sum(),
1984-
value_pairs: compiled_asm.0.data_section.iter_all_entries().collect(),
1985+
value_pairs: compiled_asm
1986+
.finalized_asm
1987+
.data_section
1988+
.iter_all_entries()
1989+
.collect(),
19851990
},
19861991
};
19871992

0 commit comments

Comments
 (0)