diff --git a/.typos.toml b/.typos.toml index 61ae2104eb3..8dbeb3babe4 100644 --- a/.typos.toml +++ b/.typos.toml @@ -6,6 +6,7 @@ extend-ignore-identifiers-re = [ "TRO", "tro", "Tro", + "NOOP", "Nam", "typ", ] diff --git a/forc-plugins/forc-client/tests/deploy.rs b/forc-plugins/forc-client/tests/deploy.rs index 83e6c1313c9..43b146583d2 100644 --- a/forc-plugins/forc-client/tests/deploy.rs +++ b/forc-plugins/forc-client/tests/deploy.rs @@ -377,7 +377,7 @@ async fn test_simple_deploy() { node.kill().unwrap(); let expected = vec![DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( - "b338487c480d4c0f69351564659644023aafbcb86e8cbaccf881975a7ec51f12", + "b45b5f58ff2f05c3593ffe4241188c14644aaa1e42dc7defae12b8d09cc6a292", ) .unwrap(), proxy: None, @@ -421,7 +421,7 @@ async fn test_deploy_submit_only() { node.kill().unwrap(); let expected = vec![DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( - "b338487c480d4c0f69351564659644023aafbcb86e8cbaccf881975a7ec51f12", + "b45b5f58ff2f05c3593ffe4241188c14644aaa1e42dc7defae12b8d09cc6a292", ) .unwrap(), proxy: None, @@ -468,12 +468,12 @@ async fn test_deploy_fresh_proxy() { node.kill().unwrap(); let impl_contract = DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( - "b338487c480d4c0f69351564659644023aafbcb86e8cbaccf881975a7ec51f12", + "b45b5f58ff2f05c3593ffe4241188c14644aaa1e42dc7defae12b8d09cc6a292", ) .unwrap(), proxy: Some( ContractId::from_str( - "f10ec690d2439dc4c3ec1c3dda0d97c46c7799f51f4cb6c186b3c7f014c07458", + "58d6efc775fee5c76fa4f28be28cca8c8abe360e4665f4976833dccca13f7ace", ) .unwrap(), ), diff --git a/forc/tests/cli_integration.rs b/forc/tests/cli_integration.rs index 44a1f7097ad..0911e2e0d5b 100644 --- a/forc/tests/cli_integration.rs +++ b/forc/tests/cli_integration.rs @@ -51,10 +51,10 @@ fn test_forc_test_raw_logs() -> Result<(), rexpect::error::Error> { // Assert that the output is correct process.exp_string(" test test_log_4")?; process.exp_string("raw logs:")?; - process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12644,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12448,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; process.exp_string(" test test_log_2")?; process.exp_string("raw logs:")?; - process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12644,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12448,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; process.process.exit()?; Ok(()) @@ -77,12 +77,12 @@ fn test_forc_test_both_logs() -> Result<(), rexpect::error::Error> { process.exp_string("decoded log values:")?; process.exp_string("4, log rb: 1515152261580153489")?; process.exp_string("raw logs:")?; - process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12644,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000004","digest":"8005f02d43fa06e7d0585fb64c961d57e318b27a145c857bcd3a6bdb413ff7fc","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12448,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; process.exp_string(" test test_log_2")?; process.exp_string("decoded log values:")?; process.exp_string("2, log rb: 1515152261580153489")?; process.exp_string("raw logs:")?; - process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12644,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; + process.exp_string(r#"[{"LogData":{"data":"0000000000000002","digest":"cd04a4754498e06db5a13c5f371f1f04ff6d2470f24aa9bd886540e5dce77f70","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":12448,"ptr":67107840,"ra":0,"rb":1515152261580153489}}]"#)?; process.process.exit()?; Ok(()) } diff --git a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs index cb37bddbb0e..e63d5da0dda 100644 --- a/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs +++ b/sway-core/src/asm_generation/fuel/allocated_abstract_instruction_set.rs @@ -13,9 +13,9 @@ use super::{ data_section::{DataSection, Entry}, }; -use fuel_vm::fuel_asm::Imm12; +use fuel_vm::{fuel_asm::Imm12, prelude::Instruction}; use indexmap::{IndexMap, IndexSet}; -use rustc_hash::FxHashSet; +use rustc_hash::FxHashMap; use sway_types::span::Span; use std::collections::{BTreeSet, HashMap}; @@ -198,20 +198,17 @@ impl AllocatedAbstractInstructionSet { pub(crate) fn realize_labels( mut self, data_section: &mut DataSection, - far_jump_indices: &FxHashSet, + far_jump_sizes: &FxHashMap, ) -> Result<(RealizedAbstractInstructionSet, LabeledBlocks), crate::CompileError> { let label_offsets = self.resolve_labels(data_section); let mut curr_offset = 0; let mut realized_ops = vec![]; for (op_idx, op) in self.ops.iter().enumerate() { - let op_size = if far_jump_indices.contains(&op_idx) { - 2 - } else { - Self::instruction_size_not_far_jump(op, data_section) - }; - let rel_offset = - |curr_offset, lab| label_offsets.get(lab).unwrap().offs.abs_diff(curr_offset); + let op_size = far_jump_sizes + .get(&op_idx) + .copied() + .unwrap_or_else(|| Self::instruction_size_not_far_jump(op, data_section)); let AllocatedAbstractOp { opcode, comment, @@ -226,52 +223,32 @@ impl AllocatedAbstractInstructionSet { Either::Right(org_op) => match org_op { ControlFlowOp::Jump { to, type_ } => { let target_offset = label_offsets.get(&to).unwrap().offs; - let ops = compile_jump( - data_section, - curr_offset, - target_offset, - match type_ { - JumpType::NotZero(cond) => Some(cond), - _ => None, - }, - far_jump_indices.contains(&op_idx), - comment, - owning_span, - ); + let ops = if matches!(type_, JumpType::Call) { + compile_call( + data_section, + curr_offset, + target_offset, + far_jump_sizes.get(&op_idx).copied(), + comment, + owning_span, + ) + } else { + compile_jump( + data_section, + curr_offset, + target_offset, + match type_ { + JumpType::NotZero(cond) => Some(cond), + _ => None, + }, + far_jump_sizes.contains_key(&op_idx), + comment, + owning_span, + ) + }; debug_assert_eq!(ops.len() as u64, op_size); realized_ops.extend(ops); } - ControlFlowOp::SaveRetAddr(r1, ref to) => { - let imm = VirtualImmediate12::new_unchecked( - rel_offset(curr_offset, to), - "Programs with more than 2^12 relative offset are unsupported right now", - ); - assert!(curr_offset < label_offsets.get(to).unwrap().offs); - realized_ops.push(RealizedOp { - opcode: AllocatedInstruction::SUB( - r1.clone(), - AllocatedRegister::Constant(ConstantRegister::ProgramCounter), - AllocatedRegister::Constant(ConstantRegister::InstructionStart), - ), - owning_span: owning_span.clone(), - comment: "get current instruction offset from instructions start ($is)" - .into(), - }); - realized_ops.push(RealizedOp { - opcode: AllocatedInstruction::SRLI( - r1.clone(), - r1.clone(), - VirtualImmediate12::new_unchecked(2, "two must fit in 12 bits"), - ), - owning_span: owning_span.clone(), - comment: "get current instruction offset in 32-bit words".into(), - }); - realized_ops.push(RealizedOp { - opcode: AllocatedInstruction::ADDI(r1.clone(), r1, imm), - owning_span, - comment, - }); - } ControlFlowOp::DataSectionOffsetPlaceholder => { realized_ops.push(RealizedOp { opcode: AllocatedInstruction::DataSectionOffsetPlaceholder, @@ -348,14 +325,12 @@ impl AllocatedAbstractInstructionSet { // This is a concrete op, size is fixed Either::Left(_) => 1, - // Worst case for jump is 2 opcodes - Either::Right(Jump { .. }) => 2, - - // We use three instructions to save the absolute address for return. - // SUB r1 $pc $is - // SRLI r1 r1 2 / DIVI r1 r1 4 - // ADDI $r1 $r1 offset - Either::Right(SaveRetAddr(..)) => 3, + // Worst case for jump is 2 opcodes, and 3 for calls + Either::Right(Jump { ref type_, .. }) => match type_ { + JumpType::Unconditional => 2, + JumpType::NotZero(_) => 2, + JumpType::Call => 3, + }, Either::Right(Comment) => 0, @@ -420,12 +395,6 @@ impl AllocatedAbstractInstructionSet { // Far jumps must be handled separately, as they require two instructions. Either::Right(Jump { .. }) => 1, - // We use three instructions to save the absolute address for return. - // SUB r1 $pc $is - // SRLI r1 r1 2 / DIVI r1 r1 4 - // ADDI $r1 $r1 offset - Either::Right(SaveRetAddr(..)) => 3, - Either::Right(Comment) => 0, Either::Right(DataSectionOffsetPlaceholder) => { @@ -445,19 +414,19 @@ impl AllocatedAbstractInstructionSet { /// Go through all jumps and check if they could require a far jump in the worst case. /// For far jumps we have to reserve space for an extra opcode to load target address. + /// For far calls, we need to reserve two extra opcodes. /// Also, this will be mark self-jumps, as they require a noop to be inserted before them. - pub(crate) fn collect_far_jumps(&self) -> FxHashSet { + pub(crate) fn collect_far_jumps(&self) -> FxHashMap { let mut labelled_blocks = LabeledBlocks::new(); let mut cur_offset = 0; let mut cur_basic_block = None; - let mut far_jump_indices = FxHashSet::default(); + let mut far_jump_sizes = FxHashMap::default(); struct JumpInfo { to: Label, offset: u64, op_idx: usize, - limit: u64, } let mut jumps = Vec::new(); @@ -475,16 +444,11 @@ impl AllocatedAbstractInstructionSet { cur_basic_block = Some((cur_lab, op_idx, cur_offset)); } - if let Either::Right(ControlFlowOp::Jump { to, type_, .. }) = &op.opcode { + if let Either::Right(ControlFlowOp::Jump { to, .. }) = &op.opcode { jumps.push(JumpInfo { to: *to, offset: cur_offset, op_idx, - limit: if matches!(type_, JumpType::NotZero(_)) { - consts::TWELVE_BITS - } else { - consts::EIGHTEEN_BITS - }, }); } @@ -498,30 +462,53 @@ impl AllocatedAbstractInstructionSet { } for jump in jumps { - let rel_offset = labelled_blocks - .get(&jump.to) - .unwrap() - .offs - .abs_diff(jump.offset); - // Self jumps need a NOOP inserted before it so that we can jump to the NOOP. - // This is handled by the force_far machinery as well. - if rel_offset == 0 || rel_offset > jump.limit { - debug_assert!(matches!( - self.ops[jump.op_idx].opcode, - Either::Right(ControlFlowOp::Jump { .. }) - )); - far_jump_indices.insert(jump.op_idx); - } + let offs = labelled_blocks.get(&jump.to).unwrap().offs; + let rel_offset = offs.abs_diff(jump.offset); + let Either::Right(ControlFlowOp::Jump { ref type_, .. }) = self.ops[jump.op_idx].opcode + else { + unreachable!("Jump info should only be collected for jumps"); + }; + // Relative self jumps need a NOOP inserted before it so that we can jump to the NOOP. + let is_self_jump = rel_offset == 0; + match type_ { + JumpType::Unconditional => { + // Unconditional jumps have 18-bit immidate offset + if is_self_jump || rel_offset > consts::EIGHTEEN_BITS { + far_jump_sizes.insert(jump.op_idx, 2); + } + } + JumpType::NotZero(_) => { + // Conditional jumps have 12-bit immidate offset + if is_self_jump || rel_offset > consts::TWELVE_BITS { + far_jump_sizes.insert(jump.op_idx, 2); + } + } + JumpType::Call => { + // Use the actual codegen to estimate the size of the call. + // This can never generate a number that's too small, but in some + // corner cases it leads to reserving an extra opcode. + // See `compile_call` that inserts NOOPs to pad the call in these cases. + let len = compile_call_inner( + &mut DataSection::default(), + jump.offset, + offs, + String::new(), + None, + ) + .len(); + far_jump_sizes.insert(jump.op_idx, len as u64); + } + }; } - far_jump_indices + far_jump_sizes } /// Map the labels to their offsets in the program. fn map_label_offsets( &self, data_section: &DataSection, - far_jump_indices: &FxHashSet, + far_jump_sizes: &FxHashMap, ) -> LabeledBlocks { let mut labelled_blocks = LabeledBlocks::new(); let mut cur_offset = 0; @@ -541,11 +528,10 @@ impl AllocatedAbstractInstructionSet { } // Update the offset. - let op_size = if far_jump_indices.contains(&op_idx) { - 2 - } else { - Self::instruction_size_not_far_jump(op, data_section) - }; + let op_size = far_jump_sizes + .get(&op_idx) + .copied() + .unwrap_or_else(|| Self::instruction_size_not_far_jump(op, data_section)); cur_offset += op_size; } @@ -727,3 +713,238 @@ pub(crate) fn compile_jump( }] } } + +/// Compiles a function call into the appropriate operations. +/// Generates 1 to 3 instruction depending on the distance to target. +pub(crate) fn compile_call_inner( + data_section: &mut DataSection, + curr_offset: u64, + target_offset: u64, + comment: String, + owning_span: Option, +) -> Vec { + // Handle forwards and backwards jumps separately + if curr_offset <= target_offset { + let delta = target_offset - curr_offset; + + // If the offset is small enough for a single instruction, do it directly + if let Ok(imm) = VirtualImmediate12::new(delta, Span::dummy()) { + return vec![RealizedOp { + opcode: AllocatedInstruction::JAL( + AllocatedRegister::Constant(ConstantRegister::CallReturnAddress), + AllocatedRegister::Constant(ConstantRegister::ProgramCounter), + imm, + ), + owning_span, + comment, + }]; + } + + // The next approaches require an extra instruction before the PC is used, so we + // subtract 1 from the delta to account for that. It cannot underflow as otherwise the first + // approach would have been used. Then we multiply by instruction size for doing arithmetic + // with the PC register. The overflow cannot occur since programs cannot be 2**60 bytes large. + let delta_instr = (delta - 1) * (Instruction::SIZE as u64); + + // Attempt MOVI-based approach, that has larger immediate size but doesn't require data section. + if let Ok(imm) = VirtualImmediate18::new(delta_instr, Span::dummy()) { + return vec![ + RealizedOp { + opcode: AllocatedInstruction::MOVI( + AllocatedRegister::Constant(ConstantRegister::Scratch), + imm, + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::ADD( + AllocatedRegister::Constant(ConstantRegister::Scratch), + AllocatedRegister::Constant(ConstantRegister::ProgramCounter), + AllocatedRegister::Constant(ConstantRegister::Scratch), + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::JAL( + AllocatedRegister::Constant(ConstantRegister::CallReturnAddress), + AllocatedRegister::Constant(ConstantRegister::Scratch), + VirtualImmediate12::new_unchecked(0, "unreachable()"), + ), + owning_span, + comment, + }, + ]; + } + + // if the offset is too large for MOVI, use data section to store the full offset. + let data_id = data_section.insert_data_value(Entry::new_word( + delta_instr, + EntryName::NonConfigurable, + None, + )); + + return vec![ + RealizedOp { + opcode: AllocatedInstruction::LoadDataId( + AllocatedRegister::Constant(ConstantRegister::Scratch), + data_id, + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::ADD( + AllocatedRegister::Constant(ConstantRegister::Scratch), + AllocatedRegister::Constant(ConstantRegister::ProgramCounter), + AllocatedRegister::Constant(ConstantRegister::Scratch), + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::JAL( + AllocatedRegister::Constant(ConstantRegister::CallReturnAddress), + AllocatedRegister::Constant(ConstantRegister::Scratch), + VirtualImmediate12::new_unchecked(0, "unreachable()"), + ), + owning_span, + comment, + }, + ]; + } + + // This is a jump backwards. The approaches are same as forward jumping, but + // the version with only a single instruction is not possible, and we have to replace + // ADD with SUB instructions. A SUBI-based approach can be used, for a cheap 2-instruction case. + let delta = curr_offset - target_offset; + + // Attempt SUBI-based approach + if let Ok(imm) = VirtualImmediate12::new( + delta.saturating_mul(Instruction::SIZE as u64), + Span::dummy(), + ) { + return vec![ + RealizedOp { + opcode: AllocatedInstruction::SUBI( + AllocatedRegister::Constant(ConstantRegister::Scratch), + AllocatedRegister::Constant(ConstantRegister::ProgramCounter), + imm, + ), + owning_span: owning_span.clone(), + comment: "load far jump target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::JAL( + AllocatedRegister::Constant(ConstantRegister::CallReturnAddress), + AllocatedRegister::Constant(ConstantRegister::Scratch), + VirtualImmediate12::new_unchecked(0, "unreachable()"), + ), + owning_span, + comment, + }, + ]; + } + + // Since the rest of the approaches require an extra instruction before the PC is used, we + // add 1 to the delta to account for that. It cannot underflow as otherwise the first + // approach would have been used. Then we multiply by instruction size for doing arithmetic + // with the PC register. The overflow cannot occur since programs cannot be 2**60 bytes large. + let delta_instr = (delta + 1) * (Instruction::SIZE as u64); + + // Attempt MOVI-based approach. + if let Ok(imm) = VirtualImmediate18::new(delta_instr, Span::dummy()) { + return vec![ + RealizedOp { + opcode: AllocatedInstruction::MOVI( + AllocatedRegister::Constant(ConstantRegister::Scratch), + imm, + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::SUB( + AllocatedRegister::Constant(ConstantRegister::Scratch), + AllocatedRegister::Constant(ConstantRegister::ProgramCounter), + AllocatedRegister::Constant(ConstantRegister::Scratch), + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::JAL( + AllocatedRegister::Constant(ConstantRegister::CallReturnAddress), + AllocatedRegister::Constant(ConstantRegister::Scratch), + VirtualImmediate12::new_unchecked(0, "unreachable()"), + ), + owning_span, + comment, + }, + ]; + } + + // And lastly, fall back to the data section backed approach. + let data_id = data_section.insert_data_value(Entry::new_word( + delta_instr, + EntryName::NonConfigurable, + None, + )); + + vec![ + RealizedOp { + opcode: AllocatedInstruction::LoadDataId( + AllocatedRegister::Constant(ConstantRegister::Scratch), + data_id, + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::SUB( + AllocatedRegister::Constant(ConstantRegister::Scratch), + AllocatedRegister::Constant(ConstantRegister::ProgramCounter), + AllocatedRegister::Constant(ConstantRegister::Scratch), + ), + owning_span: owning_span.clone(), + comment: "load call target address".into(), + }, + RealizedOp { + opcode: AllocatedInstruction::JAL( + AllocatedRegister::Constant(ConstantRegister::CallReturnAddress), + AllocatedRegister::Constant(ConstantRegister::Scratch), + VirtualImmediate12::new_unchecked(0, "unreachable()"), + ), + owning_span, + comment, + }, + ] +} + +/// Compiles a function call into the appropriate operations. +/// Pads the call to the size reserved for it. +pub(crate) fn compile_call( + data_section: &mut DataSection, + curr_offset: u64, + target_offset: u64, + far_size: Option, + comment: String, + owning_span: Option, +) -> Vec { + let mut res = compile_call_inner( + data_section, + curr_offset, + target_offset, + comment.clone(), + owning_span.clone(), + ); + while res.len() < far_size.unwrap_or(1) as usize { + res.push(RealizedOp { + opcode: AllocatedInstruction::NOOP, + owning_span: owning_span.clone(), + comment: comment.clone(), + }); + } + res +} diff --git a/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs b/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs index 468504e3ba6..08b86dcd2e2 100644 --- a/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs +++ b/sway-core/src/asm_generation/fuel/fuel_asm_builder.rs @@ -163,15 +163,6 @@ impl AsmBuilder for FuelAsmBuilder<'_, '_> { owning_span: None, }); - // Set a new return address. - let ret_label = self.reg_seqr.get_label(); - self.before_entries.push(Op::save_ret_addr( - VirtualRegister::Constant(ConstantRegister::CallReturnAddress), - ret_label, - "set new return address", - None, - )); - // call decode self.before_entries.push(Op { opcode: Either::Right(crate::asm_lang::ControlFlowOp::Jump { @@ -181,8 +172,6 @@ impl AsmBuilder for FuelAsmBuilder<'_, '_> { comment: format!("decode configurable {}", name), owning_span: None, }); - - self.before_entries.push(Op::unowned_jump_label(ret_label)); } } } diff --git a/sway-core/src/asm_generation/fuel/functions.rs b/sway-core/src/asm_generation/fuel/functions.rs index 96c8b55479e..c8ba0cf78cb 100644 --- a/sway-core/src/asm_generation/fuel/functions.rs +++ b/sway-core/src/asm_generation/fuel/functions.rs @@ -179,15 +179,6 @@ impl FuelAsmBuilder<'_, '_> { } } - // Set a new return address. - let ret_label = self.reg_seqr.get_label(); - self.cur_bytecode.push(Op::save_ret_addr( - VirtualRegister::Constant(ConstantRegister::CallReturnAddress), - ret_label, - "[call]: set new return address", - None, - )); - // Jump to function and insert return label. let (fn_label, _) = self.func_to_labels(function); self.cur_bytecode.push(Op { @@ -198,7 +189,6 @@ impl FuelAsmBuilder<'_, '_> { comment: format!("[call]: call {}", function.get_name(self.context)), owning_span: None, }); - self.cur_bytecode.push(Op::unowned_jump_label(ret_label)); // Save the return value. let ret_reg = self.reg_seqr.next(); @@ -368,11 +358,15 @@ impl FuelAsmBuilder<'_, '_> { }); // Jump to the return address. - self.cur_bytecode.push(Op::jump_to_register( - VirtualRegister::Constant(ConstantRegister::CallReturnAddress), - "return from call", - None, - )); + self.cur_bytecode.push(Op { + opcode: Either::Left(VirtualOp::JAL( + ConstantRegister::Zero.into(), + ConstantRegister::CallReturnAddress.into(), + VirtualImmediate12::new_unchecked(0, "Zero must fit into 12 bits"), + )), + comment: "return from call".into(), + owning_span: None, + }); } // Save this function. diff --git a/sway-core/src/asm_generation/fuel/optimizations/const_indexed_aggregates.rs b/sway-core/src/asm_generation/fuel/optimizations/const_indexed_aggregates.rs index b1649bea23f..b2c68109fc9 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/const_indexed_aggregates.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/const_indexed_aggregates.rs @@ -2,7 +2,7 @@ use rustc_hash::FxHashMap; use crate::{ asm_generation::fuel::compiler_constants, - asm_lang::{ControlFlowOp, VirtualImmediate12, VirtualOp, VirtualRegister}, + asm_lang::{VirtualImmediate12, VirtualOp, VirtualRegister}, }; use super::super::{abstract_instruction_set::AbstractInstructionSet, data_section::DataSection}; @@ -210,7 +210,6 @@ impl AbstractInstructionSet { } } } - either::Either::Right(ControlFlowOp::SaveRetAddr(..)) => {} either::Either::Right(_) => { clear_state = true; } diff --git a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs index 556352a5863..96a39ec4515 100644 --- a/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs +++ b/sway-core/src/asm_generation/fuel/optimizations/constant_propagate.rs @@ -222,7 +222,6 @@ impl AbstractInstructionSet { }, // These ops mark their outputs properly and cause no control-flow effects ControlFlowOp::Comment - | ControlFlowOp::SaveRetAddr(_, _) | ControlFlowOp::ConfigurablesOffsetPlaceholder | ControlFlowOp::DataSectionOffsetPlaceholder => ResetKnown::Defs, // This changes the stack pointer diff --git a/sway-core/src/asm_generation/fuel/programs/allocated.rs b/sway-core/src/asm_generation/fuel/programs/allocated.rs index a9e7866be0f..a3bfd689044 100644 --- a/sway-core/src/asm_generation/fuel/programs/allocated.rs +++ b/sway-core/src/asm_generation/fuel/programs/allocated.rs @@ -32,9 +32,9 @@ impl AllocatedProgram { .collect(), }; - let far_jump_indices = abstract_ops.collect_far_jumps(); + let far_jump_sizes = abstract_ops.collect_far_jumps(); let (realized_ops, mut label_offsets) = - abstract_ops.realize_labels(&mut self.data_section, &far_jump_indices)?; + abstract_ops.realize_labels(&mut self.data_section, &far_jump_sizes)?; let ops = realized_ops.allocated_ops(); // Collect the entry point offsets. diff --git a/sway-core/src/asm_lang/allocated_ops.rs b/sway-core/src/asm_lang/allocated_ops.rs index f9cf6135ea9..3172f09fc9f 100644 --- a/sway-core/src/asm_lang/allocated_ops.rs +++ b/sway-core/src/asm_lang/allocated_ops.rs @@ -151,6 +151,7 @@ pub(crate) enum AllocatedInstruction { JMPF(AllocatedRegister, VirtualImmediate18), JNZB(AllocatedRegister, AllocatedRegister, VirtualImmediate12), JNZF(AllocatedRegister, AllocatedRegister, VirtualImmediate12), + JAL(AllocatedRegister, AllocatedRegister, VirtualImmediate12), RET(AllocatedRegister), /* Memory Instructions */ @@ -355,6 +356,7 @@ impl AllocatedInstruction { JMPF(_r1, _i) => vec![], JNZB(_r1, _r2, _i) => vec![], JNZF(_r1, _r2, _i) => vec![], + JAL(r1, _r2, _i) => vec![r1], RET(_r1) => vec![], /* Memory Instructions */ @@ -477,7 +479,7 @@ impl fmt::Display for AllocatedInstruction { WQMM(a, b, c, d) => write!(fmtr, "wqmm {a} {b} {c} {d}"), /* Control Flow Instructions */ - JMP(a) => write!(fmtr, "jmp {a}"), + JMP(a) => write!(fmtr, "jmp {a}"), JI(a) => write!(fmtr, "ji {a}"), JNE(a, b, c) => write!(fmtr, "jne {a} {b} {c}"), JNEI(a, b, c) => write!(fmtr, "jnei {a} {b} {c}"), @@ -486,6 +488,7 @@ impl fmt::Display for AllocatedInstruction { JMPF(a, b) => write!(fmtr, "jmpf {a} {b}"), JNZB(a, b, c) => write!(fmtr, "jnzb {a} {b} {c}"), JNZF(a, b, c) => write!(fmtr, "jnzf {a} {b} {c}"), + JAL(a, b, c) => write!(fmtr, "jal {a} {b} {c}"), RET(a) => write!(fmtr, "ret {a}"), /* Memory Instructions */ @@ -689,6 +692,7 @@ impl AllocatedOp { JMPF(a, b) => op::JMPF::new(a.to_reg_id(), b.value().into()).into(), JNZB(a, b, c) => op::JNZB::new(a.to_reg_id(), b.to_reg_id(), c.value().into()).into(), JNZF(a, b, c) => op::JNZF::new(a.to_reg_id(), b.to_reg_id(), c.value().into()).into(), + JAL(a, b, c) => op::JAL::new(a.to_reg_id(), b.to_reg_id(), c.value().into()).into(), RET(a) => op::RET::new(a.to_reg_id()).into(), /* Memory Instructions */ diff --git a/sway-core/src/asm_lang/mod.rs b/sway-core/src/asm_lang/mod.rs index 7c54a30eee2..14f22fd6bef 100644 --- a/sway-core/src/asm_lang/mod.rs +++ b/sway-core/src/asm_lang/mod.rs @@ -209,20 +209,6 @@ impl Op { } } - /// Move an address at a label into a register. - pub(crate) fn save_ret_addr( - reg: VirtualRegister, - label: Label, - comment: impl Into, - owning_span: Option, - ) -> Self { - Op { - opcode: Either::Right(OrganizationalOp::SaveRetAddr(reg, label)), - comment: comment.into(), - owning_span, - } - } - /// Moves the register in the second argument into the register in the first argument pub(crate) fn register_move( r1: VirtualRegister, @@ -295,19 +281,6 @@ impl Op { } } - /// Dynamically jumps to a register value. - pub(crate) fn jump_to_register( - reg: VirtualRegister, - comment: impl Into, - owning_span: Option, - ) -> Self { - Op { - opcode: Either::Left(VirtualOp::JMP(reg)), - comment: comment.into(), - owning_span, - } - } - pub(crate) fn parse_opcode( handler: &Handler, name: &Ident, @@ -1211,6 +1184,7 @@ impl fmt::Display for VirtualOp { JNE(a, b, c) => write!(fmtr, "jne {a} {b} {c}"), JNEI(a, b, c) => write!(fmtr, "jnei {a} {b} {c}"), JNZI(a, b) => write!(fmtr, "jnzi {a} {b}"), + JAL(a, b, c) => write!(fmtr, "jal {a} {b} {c}"), RET(a) => write!(fmtr, "ret {a}"), /* Memory Instructions */ @@ -1314,8 +1288,6 @@ pub(crate) enum ControlFlowOp { /// Jump type type_: JumpType, }, - // Save a return label address in a register. - SaveRetAddr(Reg, Label), // Placeholder for the offset into the configurables section. ConfigurablesOffsetPlaceholder, // placeholder for the DataSection offset @@ -1342,7 +1314,6 @@ impl fmt::Display for ControlFlowOp { JumpType::Call => format!("fncall {to}"), }, Comment => "".into(), - SaveRetAddr(r1, lab) => format!("mova {r1} {lab}"), DataSectionOffsetPlaceholder => "DATA SECTION OFFSET[0..32]\nDATA SECTION OFFSET[32..64]".into(), ConfigurablesOffsetPlaceholder => @@ -1365,8 +1336,6 @@ impl ControlFlowOp { | PushAll(_) | PopAll(_) => vec![], - SaveRetAddr(r1, _) => vec![r1], - Jump { type_, .. } => match type_ { JumpType::Unconditional => vec![], JumpType::NotZero(r1) => vec![r1], @@ -1382,7 +1351,6 @@ impl ControlFlowOp { (match self { Label(_) | Comment - | SaveRetAddr(..) | DataSectionOffsetPlaceholder | ConfigurablesOffsetPlaceholder | PushAll(_) @@ -1403,7 +1371,6 @@ impl ControlFlowOp { (match self { Label(_) | Comment - | SaveRetAddr(..) | DataSectionOffsetPlaceholder | ConfigurablesOffsetPlaceholder | PushAll(_) @@ -1419,20 +1386,7 @@ impl ControlFlowOp { } pub(crate) fn def_registers(&self) -> BTreeSet<&Reg> { - use ControlFlowOp::*; - (match self { - SaveRetAddr(reg, _) => vec![reg], - - Label(_) - | Comment - | Jump { .. } - | DataSectionOffsetPlaceholder - | ConfigurablesOffsetPlaceholder - | PushAll(_) - | PopAll(_) => vec![], - }) - .into_iter() - .collect() + BTreeSet::new() } pub(crate) fn def_const_registers(&self) -> BTreeSet<&VirtualRegister> { @@ -1458,8 +1412,6 @@ impl ControlFlowOp { }, _ => self.clone(), }, - - SaveRetAddr(r1, label) => Self::SaveRetAddr(update_reg(r1), *label), } } @@ -1476,7 +1428,6 @@ impl ControlFlowOp { match self { Label(_) | Comment - | SaveRetAddr(..) | DataSectionOffsetPlaceholder | ConfigurablesOffsetPlaceholder | PushAll(_) @@ -1560,8 +1511,6 @@ impl ControlFlowOp { ConfigurablesOffsetPlaceholder => ConfigurablesOffsetPlaceholder, PushAll(label) => PushAll(*label), PopAll(label) => PopAll(*label), - - SaveRetAddr(r1, label) => SaveRetAddr(map_reg(r1), *label), } } } diff --git a/sway-core/src/asm_lang/virtual_ops.rs b/sway-core/src/asm_lang/virtual_ops.rs index 794500185e5..135567e4090 100644 --- a/sway-core/src/asm_lang/virtual_ops.rs +++ b/sway-core/src/asm_lang/virtual_ops.rs @@ -106,6 +106,7 @@ pub(crate) enum VirtualOp { JNE(VirtualRegister, VirtualRegister, VirtualRegister), JNEI(VirtualRegister, VirtualRegister, VirtualImmediate12), JNZI(VirtualRegister, VirtualImmediate18), + JAL(VirtualRegister, VirtualRegister, VirtualImmediate12), RET(VirtualRegister), /* Memory Instructions */ @@ -305,6 +306,7 @@ impl VirtualOp { JNE(r1, r2, r3) => vec![r1, r2, r3], JNEI(r1, r2, _i) => vec![r1, r2], JNZI(r1, _i) => vec![r1], + JAL(r1, r2, _i) => vec![r1, r2], RET(r1) => vec![r1], /* Memory Instructions */ @@ -446,6 +448,7 @@ impl VirtualOp { | JNE(_, _, _) | JNEI(_, _, _) | JNZI(_, _) + | JAL(_, _, _) | RET(_) | ALOC(..) | CFEI(..) @@ -557,6 +560,7 @@ impl VirtualOp { | JNE(_, _, _) | JNEI(_, _, _) | JNZI(_, _) + | JAL(_, _, _) | RET(_) | LB(_, _, _) | LW(_, _, _) @@ -664,6 +668,7 @@ impl VirtualOp { JNE(r1, r2, r3) => vec![r1, r2, r3], JNEI(r1, r2, _i) => vec![r1, r2], JNZI(r1, _i) => vec![r1], + JAL(_r1, r2, _i) => vec![r2], RET(r1) => vec![r1], /* Memory Instructions */ @@ -791,6 +796,7 @@ impl VirtualOp { JNE(r1, r2, r3) => vec![r1, r2, r3], JNEI(r1, r2, _i) => vec![r1, r2], JNZI(r1, _i) => vec![r1], + JAL(_r1, r2, _i) => vec![r2], RET(r1) => vec![r1], /* Memory Instructions */ @@ -916,6 +922,7 @@ impl VirtualOp { JNE(_r1, _r2, _r3) => vec![], JNEI(_r1, _r2, _i) => vec![], JNZI(_r1, _i) => vec![], + JAL(r1, _r2, _i) => vec![r1], RET(_r1) => vec![], /* Memory Instructions */ @@ -1219,6 +1226,11 @@ impl VirtualOp { i.clone(), ), JNZI(r1, i) => Self::JNZI(update_reg(reg_to_reg_map, r1), i.clone()), + JAL(r1, r2, i) => Self::JAL( + update_reg(reg_to_reg_map, r1), + update_reg(reg_to_reg_map, r2), + i.clone(), + ), RET(r1) => Self::RET(update_reg(reg_to_reg_map, r1)), /* Memory Instructions */ @@ -1727,6 +1739,11 @@ impl VirtualOp { imm.clone(), ), JNZI(reg1, imm) => AllocatedInstruction::JNZI(map_reg(&mapping, reg1), imm.clone()), + JAL(reg1, reg2, imm) => AllocatedInstruction::JAL( + map_reg(&mapping, reg1), + map_reg(&mapping, reg2), + imm.clone(), + ), RET(reg) => AllocatedInstruction::RET(map_reg(&mapping, reg)), /* Memory Instructions */ diff --git a/test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics/stdout.snap index 489958fc376..c8b0e93b214 100644 --- a/test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics/stdout.snap @@ -28,4 +28,4 @@ output: Building test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics Compiling library std (sway-lib-std) Compiling script const_generics (test/src/e2e_vm_tests/test_programs/should_fail/language/const_generics) - Finished debug [unoptimized + fuel] target(s) [304 B] in ??? + Finished debug [unoptimized + fuel] target(s) [288 B] in ??? diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_deprecated/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_deprecated/stdout.snap index 7cd3ddefa66..917acd0ea92 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_deprecated/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_deprecated/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/attributes_deprecated --release exit status: 0 @@ -183,4 +182,4 @@ warning: Function is deprecated ____ Compiled contract "attributes_deprecated" with 19 warnings. - Finished release [optimized + fuel] target(s) [848 B] in ??? + Finished release [optimized + fuel] target(s) [752 B] in ??? diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle_new_encoding.json b/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle_new_encoding.json index 2f0f533773a..85b45d611ae 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle_new_encoding.json +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle_new_encoding.json @@ -63,97 +63,97 @@ "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", "indirect": false, "name": "BOOL", - "offset": 5016 + "offset": 4576 }, { "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", "indirect": false, "name": "U8", - "offset": 5208 + "offset": 4768 }, { "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", "indirect": false, "name": "ANOTHER_U8", - "offset": 4944 + "offset": 4504 }, { "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", "indirect": false, "name": "U16", - "offset": 5152 + "offset": 4712 }, { "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", "indirect": false, "name": "U32", - "offset": 5192 + "offset": 4752 }, { "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", "indirect": false, "name": "U64", - "offset": 5200 + "offset": 4760 }, { "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", "indirect": false, "name": "U256", - "offset": 5160 + "offset": 4720 }, { "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", "indirect": false, "name": "B256", - "offset": 4984 + "offset": 4544 }, { "concreteTypeId": "81fc10c4681a3271cf2d66b2ec6fbc8ed007a442652930844fcf11818c295bff", "indirect": false, "name": "CONFIGURABLE_STRUCT", - "offset": 5104 + "offset": 4664 }, { "concreteTypeId": "a2922861f03be8a650595dd76455b95383a61b46dd418f02607fa2e00dc39d5c", "indirect": false, "name": "CONFIGURABLE_ENUM_A", - "offset": 5024 + "offset": 4584 }, { "concreteTypeId": "a2922861f03be8a650595dd76455b95383a61b46dd418f02607fa2e00dc39d5c", "indirect": false, "name": "CONFIGURABLE_ENUM_B", - "offset": 5064 + "offset": 4624 }, { "concreteTypeId": "4926d35d1a5157936b0a29bc126b8aace6d911209a5c130e9b716b0c73643ea6", "indirect": false, "name": "ARRAY_BOOL", - "offset": 4952 + "offset": 4512 }, { "concreteTypeId": "776fb5a3824169d6736138565fdc20aad684d9111266a5ff6d5c675280b7e199", "indirect": false, "name": "ARRAY_U64", - "offset": 4960 + "offset": 4520 }, { "concreteTypeId": "c998ca9a5f221fe7b5c66ae70c8a9562b86d964408b00d17f883c906bc1fe4be", "indirect": false, "name": "TUPLE_BOOL_U64", - "offset": 5136 + "offset": 4696 }, { "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a", "indirect": false, "name": "STR_4", - "offset": 5128 + "offset": 4688 }, { "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", "indirect": false, "name": "NOT_USED", - "offset": 5120 + "offset": 4680 } ], "encodingVersion": "1", diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_dedup_decode/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_dedup_decode/stdout.snap index abe65e2f5eb..493b395c3da 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_dedup_decode/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_dedup_decode/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_dedup_decode --release --ir final --asm final exit status: 0 @@ -325,24 +324,15 @@ cfei i16 ; allocate stack space for globals addr $$arg0 data_Configurable_0; get pointer to configurable TUPLE default value addi $$arg1 $zero i8 ; get length of configurable TUPLE default value addi $$arg2 $ssp i0 ; get pointer to configurable TUPLE stack address -sub $$reta $pc $is ; get current instruction offset from instructions start ($is) -srli $$reta $$reta i2 ; get current instruction offset in 32-bit words -addi $$reta $$reta i4 ; set new return address -jmpf $zero i79 ; decode configurable TUPLE +jal $$reta $pc i74 ; decode configurable TUPLE addr $$arg0 data_Configurable_1; get pointer to configurable WRAPPED default value addi $$arg1 $zero i8 ; get length of configurable WRAPPED default value addi $$arg2 $ssp i8 ; get pointer to configurable WRAPPED stack address -sub $$reta $pc $is ; get current instruction offset from instructions start ($is) -srli $$reta $$reta i2 ; get current instruction offset in 32-bit words -addi $$reta $$reta i4 ; set new return address -jmpf $zero i72 ; decode configurable WRAPPED +jal $$reta $pc i70 ; decode configurable WRAPPED move $$locbase $sp ; save locals base register for function __entry cfei i360 ; allocate 360 bytes for locals and 0 slots for call arguments addi $r0 $$locbase i272 ; get offset to local -sub $$reta $pc $is ; get current instruction offset from instructions start ($is) -srli $$reta $$reta i2 ; get current instruction offset in 32-bit words -addi $$reta $$reta i4 ; [call]: set new return address -jmpf $zero i81 ; [call]: call main_8 +jal $$reta $pc i82 ; [call]: call main_8 move $r1 $$retv ; [call]: copy the return value movi $r2 i1024 ; initialize constant into register aloc $r2 @@ -423,7 +413,7 @@ cfsi i8 ; free 8 bytes for locals and 0 slots for extra ca move $$reta $r1 ; restore return address poph i524288 ; restore registers 40..64 popl i7 ; restore registers 16..40 -jmp $$reta ; return from call +jal $zero $$reta i0 ; return from call pshl i3 ; save registers 16..40 pshh i524288 ; save registers 40..64 move $$locbase $sp ; save locals base register for function main_8 @@ -433,10 +423,10 @@ add $r0 $r0 $r1 move $$retv $r0 ; set return value poph i524288 ; restore registers 40..64 popl i3 ; restore registers 16..40 -jmp $$reta ; return from call +jal $zero $$reta i0 ; return from call .data: data__0 .bytes[8] 00 00 00 00 00 00 00 02 ........ data__1 .bytes[8] 00 00 00 00 00 00 00 01 ........ - Finished release [optimized + fuel] target(s) [504 B] in ??? + Finished release [optimized + fuel] target(s) [464 B] in ??? diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics/stdout.snap index 9ceff14abdc..026154da3a2 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics --release exit status: 1 @@ -293,12 +292,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics Compiling library std (sway-lib-std) Compiling script const_generics (test/src/e2e_vm_tests/test_programs/should_pass/language/const_generics) - Finished debug [unoptimized + fuel] target(s) [7.736 KB] in ??? + Finished debug [unoptimized + fuel] target(s) [6.952 KB] in ??? Running 1 test, filtered 0 tests tested -- const_generics - test run_main ... ok (???, 14112 gas) + test run_main ... ok (???, 13705 gas) debug output: [src/main.sw:65:13] a = [1, 2] [src/main.sw:69:13] [C {}].len() = 1 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap index b90031bb580..425ff9f7d8e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc build --path test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg --asm final | sub ecal ecal $r1 $r0 $zero $zero ; ecal id fd zero zero @@ -72,12 +71,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg Compiling library std (sway-lib-std) Compiling script dbg (test/src/e2e_vm_tests/test_programs/should_pass/language/intrinsics/dbg) - Finished debug [unoptimized + fuel] target(s) [44.016 KB] in ??? + Finished debug [unoptimized + fuel] target(s) [41.536 KB] in ??? Running 1 test, filtered 0 tests tested -- dbg - test call_main ... ok (???, 121654 gas) + test call_main ... ok (???, 118154 gas) debug output: [src/main.sw:13:13] () = () [src/main.sw:15:13] true = true diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/stdout.snap index 26686a15f65..8ffa778d6dc 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests --logs --raw-logs --dbgs --reverts passing_ exit status: 0 @@ -19,12 +18,12 @@ warning: Error message is empty ____ Compiled script "panic_handling_in_unit_tests" with 1 warning. - Finished debug [unoptimized + fuel] target(s) [10.456 KB] in ??? + Finished debug [unoptimized + fuel] target(s) [9.504 KB] in ??? Running 2 tests, filtered 18 tests tested -- panic_handling_in_unit_tests - test passing_dbgs_and_logs ... ok (???, 2244 gas) + test passing_dbgs_and_logs ... ok (???, 2162 gas) debug output: [src/main.sw:23:13] "This is a passing test containing `__dbg` outputs." = "This is a passing test containing `__dbg` outputs." [src/main.sw:25:13] x = 42 @@ -32,7 +31,7 @@ tested -- panic_handling_in_unit_tests AsciiString { data: "This is a log from the passing test." }, log rb: 10098701174489624218 42, log rb: 1515152261580153489 raw logs: -[{"LogData":{"data":"0000000000000024546869732069732061206c6f672066726f6d207468652070617373696e6720746573742e","digest":"29d742ad9093cdf81404ff756467a44448729b85ab3c0d65197829fb61d2dd29","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":44,"pc":16900,"ptr":67107840,"ra":0,"rb":10098701174489624218}},{"LogData":{"data":"000000000000002a","digest":"a6bb133cb1e3638ad7b8a3ff0539668e9e56f9b850ef1b2a810f5422eaa6c323","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":17364,"ptr":67106816,"ra":0,"rb":1515152261580153489}}] +[{"LogData":{"data":"0000000000000024546869732069732061206c6f672066726f6d207468652070617373696e6720746573742e","digest":"29d742ad9093cdf81404ff756467a44448729b85ab3c0d65197829fb61d2dd29","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":44,"pc":16104,"ptr":67107840,"ra":0,"rb":10098701174489624218}},{"LogData":{"data":"000000000000002a","digest":"a6bb133cb1e3638ad7b8a3ff0539668e9e56f9b850ef1b2a810f5422eaa6c323","id":"0000000000000000000000000000000000000000000000000000000000000000","is":10368,"len":8,"pc":16540,"ptr":67106816,"ra":0,"rb":1515152261580153489}}] test passing_no_dbgs_or_logs ... ok (???, 18 gas) test result: OK. 2 passed; 0 failed; finished in ??? @@ -56,31 +55,31 @@ warning: Error message is empty ____ Compiled script "panic_handling_in_unit_tests" with 1 warning. - Finished debug [unoptimized + fuel] target(s) [10.456 KB] in ??? + Finished debug [unoptimized + fuel] target(s) [9.504 KB] in ??? Running 20 tests, filtered 0 tests tested -- panic_handling_in_unit_tests - test passing_dbgs_and_logs ... ok (???, 2244 gas) + test passing_dbgs_and_logs ... ok (???, 2162 gas) test passing_no_dbgs_or_logs ... ok (???, 18 gas) test failing_revert_intrinsic ... FAILED (???, 19 gas) - test failing_revert_function_with_dbgs_and_logs ... FAILED (???, 2318 gas) - test failing_error_signal_assert ... FAILED (???, 507 gas) - test failing_error_signal_assert_eq ... FAILED (???, 1443 gas) - test failing_error_signal_assert_ne ... FAILED (???, 1438 gas) - test failing_error_signal_require_str_error ... FAILED (???, 328 gas) - test failing_error_signal_require_enum_error ... FAILED (???, 421 gas) - test failing_panic_no_arg ... FAILED (???, 203 gas) - test failing_panic_unit_arg ... FAILED (???, 203 gas) + test failing_revert_function_with_dbgs_and_logs ... FAILED (???, 2246 gas) + test failing_error_signal_assert ... FAILED (???, 480 gas) + test failing_error_signal_assert_eq ... FAILED (???, 1374 gas) + test failing_error_signal_assert_ne ... FAILED (???, 1369 gas) + test failing_error_signal_require_str_error ... FAILED (???, 318 gas) + test failing_error_signal_require_enum_error ... FAILED (???, 412 gas) + test failing_panic_no_arg ... FAILED (???, 194 gas) + test failing_panic_unit_arg ... FAILED (???, 194 gas) test failing_panic_const_eval_str_arg ... FAILED (???, 19 gas) test failing_panic_const_eval_empty_str_arg ... FAILED (???, 19 gas) test failing_panic_const_eval_whitespace_str_arg ... FAILED (???, 19 gas) - test failing_panic_non_const_eval_str_arg ... FAILED (???, 306 gas) - test failing_panic_non_const_eval_str_empty_arg ... FAILED (???, 300 gas) - test failing_panic_non_const_eval_str_whitespace_arg ... FAILED (???, 306 gas) - test failing_panic_error_enum_arg ... FAILED (???, 403 gas) - test failing_panic_error_enum_arg_with_empty_msg ... FAILED (???, 497 gas) - test failing_panic_error_enum_arg_with_whitespace_msg ... FAILED (???, 514 gas) + test failing_panic_non_const_eval_str_arg ... FAILED (???, 297 gas) + test failing_panic_non_const_eval_str_empty_arg ... FAILED (???, 291 gas) + test failing_panic_non_const_eval_str_whitespace_arg ... FAILED (???, 297 gas) + test failing_panic_error_enum_arg ... FAILED (???, 394 gas) + test failing_panic_error_enum_arg_with_empty_msg ... FAILED (???, 486 gas) + test failing_panic_error_enum_arg_with_whitespace_msg ... FAILED (???, 503 gas) failures: test failing_revert_intrinsic, "test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panic_handling_in_unit_tests/src/main.sw":34 @@ -103,7 +102,7 @@ AsciiString { data: "This is a log from the reverting test." }, log rb: 10098701 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 46, - "pc": 16900, + "pc": 16104, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -137,7 +136,7 @@ AsciiString { data: "We will get logged the asserted values and this message." } "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 64, - "pc": 16900, + "pc": 16104, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -150,7 +149,7 @@ AsciiString { data: "We will get logged the asserted values and this message." } "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 8, - "pc": 17364, + "pc": 16540, "ptr": 67106816, "ra": 0, "rb": 1515152261580153489 @@ -163,7 +162,7 @@ AsciiString { data: "We will get logged the asserted values and this message." } "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 8, - "pc": 17364, + "pc": 16540, "ptr": 67105792, "ra": 0, "rb": 1515152261580153489 @@ -190,7 +189,7 @@ AsciiString { data: "We will get logged the asserted values and this message." } "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 64, - "pc": 16900, + "pc": 16104, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -203,7 +202,7 @@ AsciiString { data: "We will get logged the asserted values and this message." } "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 8, - "pc": 17364, + "pc": 16540, "ptr": 67106816, "ra": 0, "rb": 1515152261580153489 @@ -216,7 +215,7 @@ AsciiString { data: "We will get logged the asserted values and this message." } "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 8, - "pc": 17364, + "pc": 16540, "ptr": 67105792, "ra": 0, "rb": 1515152261580153489 @@ -239,7 +238,7 @@ AsciiString { data: "This is an error message in a `require` call." }, log rb: 1 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 53, - "pc": 16900, + "pc": 16104, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -262,7 +261,7 @@ B(true), log rb: 8516346929033386016 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 9, - "pc": 14216, + "pc": 13676, "ptr": 67107840, "ra": 0, "rb": 8516346929033386016 @@ -286,7 +285,7 @@ B(true), log rb: 8516346929033386016 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 0, - "pc": 14300, + "pc": 13748, "ptr": 67107840, "ra": 0, "rb": 3330666440490685604 @@ -310,7 +309,7 @@ B(true), log rb: 8516346929033386016 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 0, - "pc": 14372, + "pc": 13808, "ptr": 67107840, "ra": 0, "rb": 3330666440490685604 @@ -352,7 +351,7 @@ AsciiString { data: "Panicked with a non-const evaluated string argument." }, lo "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 60, - "pc": 19348, + "pc": 18388, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -376,7 +375,7 @@ AsciiString { data: "" }, log rb: 10098701174489624218 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 8, - "pc": 19348, + "pc": 18388, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -400,7 +399,7 @@ AsciiString { data: " " }, log rb: 10098701174489624218 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 12, - "pc": 19348, + "pc": 18388, "ptr": 67107840, "ra": 0, "rb": 10098701174489624218 @@ -425,7 +424,7 @@ B(true), log rb: 8516346929033386016 "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 9, - "pc": 14908, + "pc": 14260, "ptr": 67107840, "ra": 0, "rb": 8516346929033386016 @@ -450,7 +449,7 @@ C(AsciiString { data: "This is an error with an empty error message." }), log rb "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 61, - "pc": 15048, + "pc": 14388, "ptr": 67107840, "ra": 0, "rb": 8516346929033386016 @@ -475,7 +474,7 @@ D(AsciiString { data: "This is an error with a whitespace error message." }), lo "id": "0000000000000000000000000000000000000000000000000000000000000000", "is": 10368, "len": 65, - "pc": 15188, + "pc": 14516, "ptr": 67107840, "ra": 0, "rb": 8516346929033386016 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap index 3c6261138e5..9a314ba012e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract --release --test-threads 1 --logs --reverts exit status: 0 @@ -9,78 +8,78 @@ output: Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib) Compiling contract panicking_contract (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract) - Finished release [optimized + fuel] target(s) [8.68 KB] in ??? + Finished release [optimized + fuel] target(s) [7.936 KB] in ??? Running 11 tests, filtered 0 tests tested -- panicking_contract - test test_directly_panicking_method ... ok (???, 1648 gas) + test test_directly_panicking_method ... ok (???, 1595 gas) revert code: ffffffff00000000 ├─ panic message: Error C. ├─ panic value: C(true) └─ panicked in: panicking_contract@1.2.3, src/main.sw:22:9 decoded log values: C(true), log rb: 5503570629422409978 - test test_nested_panic_inlined ... ok (???, 3051 gas) + test test_nested_panic_inlined ... ok (???, 2913 gas) revert code: ffffffff00000005 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) └─ panicked in: panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_nested_panic_inlined_same_revert_code ... ok (???, 3051 gas) + test test_nested_panic_inlined_same_revert_code ... ok (???, 2913 gas) revert code: ffffffff00000005 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) └─ panicked in: panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_nested_panic_not_inlined ... ok (???, 3264 gas) + test test_nested_panic_not_inlined ... ok (???, 3110 gas) revert code: ffffffff00000006 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) └─ panicked in: panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_nested_panic_not_inlined_same_revert_code ... ok (???, 3264 gas) + test test_nested_panic_not_inlined_same_revert_code ... ok (???, 3110 gas) revert code: ffffffff00000006 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) └─ panicked in: panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_generic_panic_with_unit ... ok (???, 2136 gas) + test test_generic_panic_with_unit ... ok (???, 2035 gas) revert code: ffffffff00000004 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_unit_same_revert_code ... ok (???, 2136 gas) + test test_generic_panic_with_unit_same_revert_code ... ok (???, 2035 gas) revert code: ffffffff00000004 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_str ... ok (???, 2152 gas) + test test_generic_panic_with_str ... ok (???, 2057 gas) revert code: ffffffff00000002 ├─ panic message: generic panic with string └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218 - test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1798 gas) + test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1730 gas) revert code: ffffffff00000002 ├─ panic message: generic panic with different string └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218 - test test_generic_panic_with_error_type_enum ... ok (???, 1934 gas) + test test_generic_panic_with_error_type_enum ... ok (???, 1854 gas) revert code: ffffffff00000003 ├─ panic message: Error A. ├─ panic value: A └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: A, log rb: 5503570629422409978 - test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2112 gas) + test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2023 gas) revert code: ffffffff00000003 ├─ panic message: Error B. ├─ panic value: B(42) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib/stdout.snap index 78234e057c0..db5fd53c34d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib --release --test-threads 1 --logs --reverts exit status: 0 @@ -8,84 +7,84 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib) - Finished release [optimized + fuel] target(s) [6.304 KB] in ??? + Finished release [optimized + fuel] target(s) [5.68 KB] in ??? Running 18 tests, filtered 0 tests tested -- panicking_lib - test test_nested_panic_inlined ... ok (???, 837 gas) + test test_nested_panic_inlined ... ok (???, 810 gas) revert code: ffffffff00000000 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) └─ panicked in: panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 2721958641300806892 - test test_nested_panic_inlined_same_revert_code ... ok (???, 837 gas) + test test_nested_panic_inlined_same_revert_code ... ok (???, 810 gas) revert code: ffffffff00000000 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) └─ panicked in: panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 2721958641300806892 - test test_nested_panic_not_inlined ... ok (???, 810 gas) + test test_nested_panic_not_inlined ... ok (???, 789 gas) revert code: ffffffff00000001 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) └─ panicked in: panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 2721958641300806892 - test test_nested_panic_not_inlined_same_revert_code ... ok (???, 810 gas) + test test_nested_panic_not_inlined_same_revert_code ... ok (???, 789 gas) revert code: ffffffff00000001 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) └─ panicked in: panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 2721958641300806892 - test test_generic_panic_with_unit ... ok (???, 160 gas) + test test_generic_panic_with_unit ... ok (???, 154 gas) revert code: ffffffff00000002 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_unit_same_revert_code ... ok (???, 160 gas) + test test_generic_panic_with_unit_same_revert_code ... ok (???, 154 gas) revert code: ffffffff00000002 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_str ... ok (???, 294 gas) + test test_generic_panic_with_str ... ok (???, 285 gas) revert code: ffffffff00000003 ├─ panic message: generic panic with string └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218 - test test_generic_panic_with_different_str_same_revert_code ... ok (???, 294 gas) + test test_generic_panic_with_different_str_same_revert_code ... ok (???, 285 gas) revert code: ffffffff00000003 ├─ panic message: generic panic different string └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic different string" }, log rb: 10098701174489624218 - test test_generic_panic_with_error_type_enum_variant ... ok (???, 317 gas) + test test_generic_panic_with_error_type_enum_variant ... ok (???, 305 gas) revert code: ffffffff00000004 ├─ panic message: Error A. ├─ panic value: A └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: A, log rb: 2721958641300806892 - test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 317 gas) + test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 305 gas) revert code: ffffffff00000004 ├─ panic message: Error A. ├─ panic value: A └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: A, log rb: 2721958641300806892 - test test_panic_without_arg ... ok (???, 160 gas) + test test_panic_without_arg ... ok (???, 154 gas) revert code: ffffffff00000005 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:113:5 decoded log values: (), log rb: 3330666440490685604 - test test_panic_with_unit ... ok (???, 160 gas) + test test_panic_with_unit ... ok (???, 154 gas) revert code: ffffffff00000006 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:118:5 @@ -95,32 +94,32 @@ A, log rb: 2721958641300806892 revert code: ffffffff00000007 ├─ panic message: panic with string └─ panicked in: panicking_lib, src/lib.sw:123:5 - test test_panic_with_error_type_enum ... ok (???, 412 gas) + test test_panic_with_error_type_enum ... ok (???, 397 gas) revert code: ffffffff00000008 ├─ panic message: Error C. ├─ panic value: C(true) └─ panicked in: panicking_lib, src/lib.sw:128:5 decoded log values: C(true), log rb: 2721958641300806892 - test test_panic_with_generic_error_type_enum ... ok (???, 348 gas) + test test_panic_with_generic_error_type_enum ... ok (???, 337 gas) revert code: ffffffff00000009 ├─ panic value: A(42) └─ panicked in: panicking_lib, src/lib.sw:133:5 decoded log values: A(42), log rb: 12408470889216862137 - test test_panic_with_nested_generic_error_type ... ok (???, 635 gas) + test test_panic_with_nested_generic_error_type ... ok (???, 616 gas) revert code: ffffffff0000000a ├─ panic value: B(B(C(true))) └─ panicked in: panicking_lib, src/lib.sw:138:5 decoded log values: B(B(C(true))), log rb: 14988555917426256081 - test test_panic_with_generic_error_type_enum_with_abi_encode ... ok (???, 348 gas) + test test_panic_with_generic_error_type_enum_with_abi_encode ... ok (???, 337 gas) revert code: ffffffff0000000b ├─ panic value: A(42) └─ panicked in: panicking_lib, src/lib.sw:143:5 decoded log values: A(42), log rb: 17388243649088655852 - test test_panic_with_nested_generic_error_type_enum_with_abi_encode ... ok (???, 635 gas) + test test_panic_with_nested_generic_error_type_enum_with_abi_encode ... ok (???, 616 gas) revert code: ffffffff0000000c ├─ panic value: B(B(C(true))) └─ panicked in: panicking_lib, src/lib.sw:148:5 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_script/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_script/stdout.snap index 4e69ddb441b..eee575f29ec 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_script/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_script/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc test --path test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_script --release --test-threads 1 --logs --reverts exit status: 0 @@ -9,78 +8,78 @@ output: Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib) Compiling script panicking_script (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_script) - Finished release [optimized + fuel] target(s) [4.088 KB] in ??? + Finished release [optimized + fuel] target(s) [3.712 KB] in ??? Running 11 tests, filtered 0 tests tested -- panicking_script - test test_panic_in_main ... ok (???, 389 gas) + test test_panic_in_main ... ok (???, 374 gas) revert code: ffffffff00000000 ├─ panic message: Error C. ├─ panic value: C(true) └─ panicked in: panicking_script, src/main.sw:6:5 decoded log values: C(true), log rb: 5503570629422409978 - test test_nested_panic_inlined ... ok (???, 838 gas) + test test_nested_panic_inlined ... ok (???, 812 gas) revert code: ffffffff00000001 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) └─ panicked in: panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_nested_panic_inlined_same_revert_code ... ok (???, 838 gas) + test test_nested_panic_inlined_same_revert_code ... ok (???, 812 gas) revert code: ffffffff00000001 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) └─ panicked in: panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_nested_panic_not_inlined ... ok (???, 815 gas) + test test_nested_panic_not_inlined ... ok (???, 792 gas) revert code: ffffffff00000002 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) └─ panicked in: panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_nested_panic_not_inlined_same_revert_code ... ok (???, 815 gas) + test test_nested_panic_not_inlined_same_revert_code ... ok (???, 792 gas) revert code: ffffffff00000002 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) └─ panicked in: panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_generic_panic_with_unit ... ok (???, 160 gas) + test test_generic_panic_with_unit ... ok (???, 154 gas) revert code: ffffffff00000003 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_unit_same_revert_code ... ok (???, 160 gas) + test test_generic_panic_with_unit_same_revert_code ... ok (???, 154 gas) revert code: ffffffff00000003 ├─ panic value: () └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_str ... ok (???, 294 gas) + test test_generic_panic_with_str ... ok (???, 285 gas) revert code: ffffffff00000004 ├─ panic message: generic panic with string └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218 - test test_generic_panic_with_different_str_same_revert_code ... ok (???, 294 gas) + test test_generic_panic_with_different_str_same_revert_code ... ok (???, 285 gas) revert code: ffffffff00000004 ├─ panic message: generic panic with different string └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218 - test test_generic_panic_with_error_type_enum ... ok (???, 312 gas) + test test_generic_panic_with_error_type_enum ... ok (???, 300 gas) revert code: ffffffff00000005 ├─ panic message: Error A. ├─ panic value: A └─ panicked in: panicking_lib, src/lib.sw:74:5 decoded log values: A, log rb: 5503570629422409978 - test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 371 gas) + test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 359 gas) revert code: ffffffff00000005 ├─ panic message: Error B. ├─ panic value: B(42) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/u256/u256_abi/json_abi_oracle_new_encoding.json b/test/src/e2e_vm_tests/test_programs/should_pass/language/u256/u256_abi/json_abi_oracle_new_encoding.json index 88580a92d40..5300ce0f3bc 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/u256/u256_abi/json_abi_oracle_new_encoding.json +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/u256/u256_abi/json_abi_oracle_new_encoding.json @@ -10,7 +10,7 @@ "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", "indirect": false, "name": "SOME_U256", - "offset": 760 + "offset": 712 } ], "encodingVersion": "1", diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/panic_in_non_statement_positions/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/panic_in_non_statement_positions/stdout.snap index fc4e56c4fb5..361ddb4a4c4 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/panic_in_non_statement_positions/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/panic_in_non_statement_positions/stdout.snap @@ -1,6 +1,5 @@ --- source: test/src/snapshot/mod.rs -assertion_line: 162 --- > forc test --path test/src/e2e_vm_tests/test_programs/should_pass/panic_in_non_statement_positions --logs --test-threads 1 exit status: 0 @@ -287,57 +286,57 @@ warning ____ Compiled library "panic_in_non_statement_positions" with 23 warnings. - Finished debug [unoptimized + fuel] target(s) [2.344 KB] in ??? + Finished debug [unoptimized + fuel] target(s) [2.128 KB] in ??? Running 16 tests, filtered 0 tests tested -- panic_in_non_statement_positions - test in_init ... ok (???, 360 gas) + test in_init ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_array ... ok (???, 360 gas) + test in_array ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_length_1_array ... ok (???, 360 gas) + test in_length_1_array ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_length_2_array_first ... ok (???, 360 gas) + test in_length_2_array_first ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_length_2_array_second ... ok (???, 360 gas) + test in_length_2_array_second ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_tuple ... ok (???, 360 gas) + test in_tuple ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_struct ... ok (???, 360 gas) + test in_struct ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_parentheses ... ok (???, 360 gas) + test in_parentheses ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_if_condition ... ok (???, 360 gas) + test in_if_condition ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_while_condition ... ok (???, 360 gas) + test in_while_condition ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_enum ... ok (???, 360 gas) + test in_enum ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_enum_multivariant ... ok (???, 360 gas) + test in_enum_multivariant ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_fun_arg ... ok (???, 360 gas) + test in_fun_arg ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_lazy_and ... ok (???, 360 gas) + test in_lazy_and ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_lazy_or ... ok (???, 360 gas) + test in_lazy_or ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 - test in_match_scrutinee ... ok (???, 360 gas) + test in_match_scrutinee ... ok (???, 351 gas) decoded log values: E(42), log rb: 5087777005172090899 diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw index 1406d00d80e..fc75db79229 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw @@ -6,7 +6,7 @@ use std::hash::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x14ed3cd06c2947248f69d54bfa681fe40d26267be84df7e19e253622b7921bbe; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x334268ffc3350517784398be52cdb7daef62fc65c2dcc5f8990b96131380a479; // AUTO-CONTRACT-ID ../../test_contracts/array_of_structs_contract --release +const CONTRACT_ID = 0xf106a79029b4b175cbd3c403328947431c4cc39913d5c03bb88011a190cf7cd1; // AUTO-CONTRACT-ID ../../test_contracts/array_of_structs_contract --release fn get_address() -> Option { Some(CONTRACT_ID.into()) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw index 149d4a0a065..307328179f3 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw @@ -9,12 +9,12 @@ use test_fuel_coin_abi::*; #[cfg(experimental_new_encoding = false)] const FUEL_COIN_CONTRACT_ID = 0xec2277ebe007ade87e3d797c3b1e070dcd542d5ef8f038b471f262ef9cebc87c; #[cfg(experimental_new_encoding = true)] -const FUEL_COIN_CONTRACT_ID = 0x73afe3669fc4b788f989132b55550fdab7ae503f61df8d761e814953720d7035; // AUTO-CONTRACT-ID ../../test_contracts/test_fuel_coin_contract --release +const FUEL_COIN_CONTRACT_ID = 0x8476fc28f7ae3cad8b654176dc9f72417d4ddf0fbb9da24ade268e9ae8b82933; // AUTO-CONTRACT-ID ../../test_contracts/test_fuel_coin_contract --release #[cfg(experimental_new_encoding = false)] const BALANCE_CONTRACT_ID = 0xf6cd545152ac83225e8e7df2efb5c6fa6e37bc9b9e977b5ea8103d28668925df; #[cfg(experimental_new_encoding = true)] -const BALANCE_CONTRACT_ID = 0x937265d7f7db821c5a175bf3e7dd01b2822934b356c69b9b3bb87dcbd86eacab; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release +const BALANCE_CONTRACT_ID = 0x49460391f59d838a381add127bd3bc47a840c18e78d55df0d332159dfb01acfa; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release fn main() -> bool { let default_gas = 1_000_000_000_000; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw index 7c8c9ba4817..9894df5918f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw @@ -5,7 +5,7 @@ use balance_test_abi::BalanceTest; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xf6cd545152ac83225e8e7df2efb5c6fa6e37bc9b9e977b5ea8103d28668925df; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x937265d7f7db821c5a175bf3e7dd01b2822934b356c69b9b3bb87dcbd86eacab; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release +const CONTRACT_ID = 0x49460391f59d838a381add127bd3bc47a840c18e78d55df0d332159dfb01acfa; // AUTO-CONTRACT-ID ../../test_contracts/balance_test_contract --release fn main() -> bool { let balance_test_contract = abi(BalanceTest, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw index 691388a4a7c..93b6083a9a4 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw @@ -6,7 +6,7 @@ use abi_with_tuples::{MyContract, Location, Person}; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xfdc14550c8aee742cd556d0ab7f378b7be0d3b1e6e086c097352e94590d4ed02; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x0bc90060d4a15254088386bfc0922a0f67666ece10ba1a45a5f42349cded949a; // AUTO-CONTRACT-ID ../../test_contracts/abi_with_tuples_contract --release +const CONTRACT_ID = 0xa2a538dd3a09bda5ded434a7c4f7b91dd1c7ac8e1a74ef14693224bf210a7474; // AUTO-CONTRACT-ID ../../test_contracts/abi_with_tuples_contract --release fn main() -> bool { let the_abi = abi(MyContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw index a96d415c7c7..4ca06290859 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw @@ -4,7 +4,7 @@ use basic_storage_abi::{BasicStorage, Quad}; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x94db39f409a31b9f2ebcadeea44378e419208c20de90f5d8e1e33dc1523754cb; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x3b0939d9173db0f75ff6f9a11320929a7d78ae183c5702ae4587abe590711497; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release +const CONTRACT_ID = 0xcd95389a1c96d7527caf131a0758986c6733375387b222ead91edebc2f8dbbc8; // AUTO-CONTRACT-ID ../../test_contracts/basic_storage --release fn main() -> u64 { let addr = abi(BasicStorage, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw index 4c2da9732ce..476cb77a81d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw @@ -5,7 +5,7 @@ use contract_with_type_aliases_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x0cbeb6efe3104b460be769bdc4ea101ebf16ccc16f2d7b667ec3e1c7f5ce35b5; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x6cfbf04a102a4f250c63e7609fa64c25eb880d4c5f981302c863b824b245bf48; // AUTO-CONTRACT-ID ../../test_contracts/contract_with_type_aliases --release +const CONTRACT_ID = 0x1f4cb193e171334b5a19715805957e5f2076b1cb8ae2b2579eb8bbce5fce310f; // AUTO-CONTRACT-ID ../../test_contracts/contract_with_type_aliases --release fn main() { let caller = abi(MyContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw index 5edf1fc706c..254a6a7538e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw @@ -6,7 +6,7 @@ use dynamic_contract_call::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xd1b4047af7ef111c023ab71069e01dc2abfde487c0a0ce1268e4f447e6c6e4c2; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x4b93a566961d26a0d23702be66c33361355e338ed2ac78870c63685a39ea92a7; // AUTO-CONTRACT-ID ../../test_contracts/increment_contract --release +const CONTRACT_ID = 0xcea7265b9985e45584844a3e473f77396b9d2b19c5e82449b8d0403d6b1bc019; // AUTO-CONTRACT-ID ../../test_contracts/increment_contract --release fn main() -> bool { let the_abi = abi(Incrementor, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw index 8e36c459bf4..dde53847ab2 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw @@ -5,7 +5,7 @@ use storage_enum_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xc601d11767195485a6654d566c67774134668863d8c797a8c69e8778fb1f89e9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x996c1d876587e975f5fe8c170d721d193335bfd4b9abb343e8ba283f7338edef; // AUTO-CONTRACT-ID ../../test_contracts/storage_enum_contract --release +const CONTRACT_ID = 0x3223c0382a2ba0ba6a98d9f389776ba7595ef7396e007911fc7ee6c2d1a465d9; // AUTO-CONTRACT-ID ../../test_contracts/storage_enum_contract --release fn main() -> u64 { let caller = abi(StorageEnum, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw index 0806c8a3157..203afd03b22 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw @@ -5,7 +5,7 @@ use auth_testing_abi::AuthTesting; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xc2eec20491b53aab7232cbd27c31d15417b4e9daf0b89c74cc242ef1295f681f; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x699395b6197070e134a0c0b3eba01411a8fc197a29c75785eb21fe65b949ad3b; // AUTO-CONTRACT-ID ../../test_contracts/auth_testing_contract --release +const CONTRACT_ID = 0x3c940400fecfb98fb14ade0e76b1f115cdb92a829c7eb0349de88326fb910fa8; // AUTO-CONTRACT-ID ../../test_contracts/auth_testing_contract --release // should be false in the case of a script fn main() -> bool { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw index 7d0abd3077a..35c5b895910 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw @@ -6,7 +6,7 @@ use context_testing_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x6054c11cda000f5990373a4d61929396165be4dfdd61d5b7bd26da60ab0d8577; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x515e86ff9125107a493946e8607c422dc87d712443f17de0181ff6220f50c2fd; // AUTO-CONTRACT-ID ../../test_contracts/context_testing_contract --release +const CONTRACT_ID = 0x4b93165110ed4cd9b85b1f5127fa1e6330138baa82cb8fa1fe101678c6e57a78; // AUTO-CONTRACT-ID ../../test_contracts/context_testing_contract --release fn main() -> bool { let gas: u64 = u64::max(); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw index 84d41dfd3a6..20140f48667 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw @@ -5,7 +5,7 @@ use nested_struct_args_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xe63d33a1b3a6903808b379f6a41a72fa8a370e8b76626775e7d9d2f9c4c5da40; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x7c34b3ccbf7ef60a1a04015fb15e508e1ab3b9f1cda19d22b0ee94cb30815e81; // AUTO-CONTRACT-ID ../../test_contracts/nested_struct_args_contract --release +const CONTRACT_ID = 0x8dbe4018418007f05e643cbed3e95e1fce0a83f9dd651fee9ec73924f856c8bb; // AUTO-CONTRACT-ID ../../test_contracts/nested_struct_args_contract --release fn main() -> bool { let caller = abi(NestedStructArgs, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw index 416ca9d543d..05d0712a148 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw @@ -6,7 +6,7 @@ use std::hash::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x3bc28acd66d327b8c1b9624c1fabfc07e9ffa1b5d71c2832c3bfaaf8f4b805e9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xfdb2062a723341ffa71ad8fdf5a0abbadc484dd2beeee9a1cb2a9ccee8a9d9ba; // AUTO-CONTRACT-ID ../../test_contracts/storage_access_contract --release +const CONTRACT_ID = 0x0a882ead5e3f817cfa18d79828117b38a4cb2f3ca82eee2fa7530665bf0f8ace; // AUTO-CONTRACT-ID ../../test_contracts/storage_access_contract --release fn main() -> bool { let caller = abi(StorageAccess, CONTRACT_ID); diff --git a/test/src/ir_generation/tests/asm_block.sw b/test/src/ir_generation/tests/asm_block.sw index 1c9658963b4..0f85321459e 100644 --- a/test/src/ir_generation/tests/asm_block.sw +++ b/test/src/ir_generation/tests/asm_block.sw @@ -31,13 +31,10 @@ fn main() -> u64 { // regex: IMM=i\d+ // Call get_global_gas() and then return the result of the bhei instruction. -// check: sub $$$$reta $$pc $$is -// check: srli $$$$reta $$$$reta $IMM -// check: addi $$$$reta $$$$reta $IMM -// check: jmpf $$zero $IMM +// check: jal $$$$reta $$pc $IMM // check: bhei $(ret_val=$REG) // check: ret $ret_val // The get_global_gas() function: // check: move $$$$retv $$ggas -// check: jmp $$$$reta +// check: jal $$zero $$$$reta i0 diff --git a/test/src/ir_generation/tests/fn_call.sw b/test/src/ir_generation/tests/fn_call.sw index e6eb4343b63..6e5543925a3 100644 --- a/test/src/ir_generation/tests/fn_call.sw +++ b/test/src/ir_generation/tests/fn_call.sw @@ -43,7 +43,7 @@ fn main() -> u64 { // Matching fn a() here, which just returns its arg: // // check: move $$$$retv $REG -// check: jmp $$$$reta +// check: jal $$zero $$$$reta i0 // // Matching fn b() here, which has a local bool var, initialised to false/$zero: // @@ -53,4 +53,4 @@ fn main() -> u64 { // check: sb $$$$locbase $$zero i0 // ... // check: cfsi i24 -// check: jmp $$$$reta +// check: jal $$zero $$$$reta i0 diff --git a/test/src/ir_generation/tests/fn_call_noargs_nolocals.sw b/test/src/ir_generation/tests/fn_call_noargs_nolocals.sw index 49591342ffd..568d2ea09ec 100644 --- a/test/src/ir_generation/tests/fn_call_noargs_nolocals.sw +++ b/test/src/ir_generation/tests/fn_call_noargs_nolocals.sw @@ -24,23 +24,17 @@ fn main() { // Call a function: // -// check: sub $$$$reta $$pc $$is -// check: srli $$$$reta $$$$reta $IMM -// check: addi $$$$reta $$$$reta $IMM -// check: jmpf $$zero $IMM +// check: jal $$$$reta $$pc $IMM // Function calls other function, ignores result, returns unit/$zero. // // check: move $(reta_bk=$REG) $$$$reta -// check: sub $$$$reta $$pc $$is -// check: srli $$$$reta $$$$reta $IMM -// check: addi $$$$reta $$$$reta $IMM -// check: jmpf $$zero $IMM +// check: jal $$$$reta $$pc $IMM // check: move $$$$retv $$zero // check: move $$$$reta $reta_bk -// check: jmp $$$$reta +// check: jal $$zero $$$$reta i0 // Function returns unit. // // check: move $$$$retv $$zero -// check: jmp $$$$reta +// check: jal $$zero $$$$reta i0 diff --git a/test/src/ir_generation/tests/fn_call_nolocals.sw b/test/src/ir_generation/tests/fn_call_nolocals.sw index fbdb9c1f136..bcd8a959e2e 100644 --- a/test/src/ir_generation/tests/fn_call_nolocals.sw +++ b/test/src/ir_generation/tests/fn_call_nolocals.sw @@ -33,8 +33,5 @@ fn main() -> u64 { // check: move $$$$arg0 $REG // check: move $$$$arg1 $REG // check: move $$$$arg2 $REG -// check: sub $$$$reta $$pc $$is -// check: srli $$$$reta $$$$reta i2 -// check: addi $$$$reta $$$$reta i4 -// check: jmpf $$zero $IMM +// check: jal $$$$reta $$pc i2 // check: ret $$$$retv diff --git a/test/src/ir_generation/tests/jmp_mem.sw b/test/src/ir_generation/tests/jmp_mem.sw index 7861956060b..b3178f1d615 100644 --- a/test/src/ir_generation/tests/jmp_mem.sw +++ b/test/src/ir_generation/tests/jmp_mem.sw @@ -52,4 +52,4 @@ impl MyContract for Contract { // check: lw $(target=$REG) $$hp i0 // check: sub $(jmp_target_4=$REG) $target $$is // check: divi $(jmp_target=$REG) $jmp_target_4 i4 -// check: jmp $jmp_target +// check: jmp $jmp_target diff --git a/test/src/sdk-harness/test_projects/auth/mod.rs b/test/src/sdk-harness/test_projects/auth/mod.rs index 817ad8e9543..a9b3aea82ef 100644 --- a/test/src/sdk-harness/test_projects/auth/mod.rs +++ b/test/src/sdk-harness/test_projects/auth/mod.rs @@ -585,7 +585,7 @@ async fn can_get_predicate_address() { // Setup predicate. let hex_predicate_address: &str = - "0xa9e0330870e3ed1f537684021c02ad88d8116e91daff9651413169a77b26e509"; + "0xdb6749fef741db73ad960d0eb2c601601d8794aeaf3e356be78650b756d7c5ed"; let predicate_address = Address::from_str(hex_predicate_address).expect("failed to create Address from string"); let predicate_data = AuthPredicateEncoder::default() @@ -665,7 +665,7 @@ async fn when_incorrect_predicate_address_passed() { // Setup predicate with incorrect address. let hex_predicate_address: &str = - "0xeddbd8cc2be5fb1d4ae24a5f789e61308750ff698865f311c9818d7eb76d4777"; + "0xdb6749fef741db73ad960d0eb2c601601d8794aeaf3e356be78650b756d7c5ed"; let predicate_address = Address::from_str(hex_predicate_address).expect("failed to create Address from string"); let predicate_data = AuthPredicateEncoder::default() @@ -710,7 +710,7 @@ async fn when_incorrect_predicate_address_passed() { async fn can_get_predicate_address_in_message() { // Setup predicate address. let hex_predicate_address: &str = - "0xa9e0330870e3ed1f537684021c02ad88d8116e91daff9651413169a77b26e509"; + "0xdb6749fef741db73ad960d0eb2c601601d8794aeaf3e356be78650b756d7c5ed"; let predicate_address = Address::from_str(hex_predicate_address).expect("failed to create Address from string");