This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn use_ccp_to_memory_clear() { | |
let mut test_context = TestBuilder::new(2322u64); | |
let gas_limit = 10_000_000; | |
let program = vec![ | |
op::ret(RegId::ZERO), // super short contract | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub(crate) fn copy_from_slice_zero_fill<A: ToAddr, B: ToAddr>( | |
memory: &mut Memory, | |
owner: H160, | |
src: &[u8], | |
dst_addr: A, | |
src_offset: usize, | |
len: usize, | |
) -> Result<(), Error> { | |
let range = memory.write(owner, dst_addr, len)?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub(crate) fn code_copy(...) { | |
// Charges gas based on the contract's length | |
dependent_gas_charge_without_base( | |
self.cgas, | |
self.ggas, | |
profiler, | |
self.gas_cost, | |
contract_len as u64, // <-- Charged based on this | |
)?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[tokio::test] | |
async fn pow_bug() { | |
//Setup | |
let (instance, _id) = get_contract_instance().await; | |
println!("------------u8 pow function overflow----------------"); | |
let asset_id = instance.methods().demonstrate_bug_u8(Identity::Address(instance.account().address().into()), 20) | |
.append_variable_outputs(1) | |
.call() | |
.await |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract; | |
//Setup | |
use std::{ | |
asset::mint_to, | |
constants::DEFAULT_SUB_ID | |
}; | |
abi PowBug { | |
fn demonstrate_bug_u8(recipient: Identity, a: u8) -> AssetId; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl Power for u32 { | |
fn pow(self, exponent: u32) -> Self { | |
asm(r1: self, r2: exponent, r3) { | |
exp r3 r1 r2; | |
r3: Self | |
} | |
} | |
} | |
impl Power for u16 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Returns a list of all registers *read* by instruction `self`. | |
pub(crate) fn use_registers(&self) -> BTreeSet<&VirtualRegister> { | |
use VirtualOp::*; | |
(match self { | |
/* Arithmetic/Logic (ALU) Instructions */ | |
... | |
WQAM(_, r2, r3, r4) => vec![r2, r3, r4], | |
... | |
}) | |
.into_iter() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ownable.sw | |
library; | |
pub struct OwnershipTransferred { | |
previous_owner: b256, | |
new_owner: b256, | |
} | |
pub trait StorageHelpers { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.sw | |
contract; | |
mod ownable; | |
use ownable::*; | |
storage { | |
owner: b256 = b256::zero(), | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn validate_root(...) { | |
... | |
// ABI entries are all functions declared in impl_traits on the contract type | |
// itself, except for ABI supertraits, which do not expose their methods to | |
// the user | |
... | |
} |
NewerOlder