Skip to content

Commit

Permalink
Remove U256_MAX const, use U256::MAX
Browse files Browse the repository at this point in the history
  • Loading branch information
rockbmb committed Jan 9, 2025
1 parent b228eb2 commit 3e4bbe8
Show file tree
Hide file tree
Showing 25 changed files with 140 additions and 151 deletions.
10 changes: 5 additions & 5 deletions substrate/frame/revive/fixtures/contracts/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -38,10 +38,10 @@ pub extern "C" fn call() {
api::call(
uapi::CallFlags::empty(),
callee_addr,
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
callee_input,
None,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

extern crate common;

use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

const BUF_SIZE: usize = 8;
static DATA: [u8; BUF_SIZE] = [1, 2, 3, 4, 5, 6, 7, 8];
Expand All @@ -44,7 +44,7 @@ fn assert_call<const N: usize>(callee_address: &[u8; 20], expected_output: [u8;
callee_address,
u64::MAX,
u64::MAX,
&U256_MAX,
&[u8::MAX; 32],
&[0u8; 32],
&[],
Some(output_buf_capped),
Expand All @@ -69,7 +69,7 @@ fn assert_instantiate<const N: usize>(expected_output: [u8; BUF_SIZE]) {
&code_hash,
u64::MAX,
u64::MAX,
&U256_MAX,
&[u8::MAX; 32],
&[0; 32],
&[0; 32],
None,
Expand Down
10 changes: 5 additions & 5 deletions substrate/frame/revive/fixtures/contracts/call_return_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -42,10 +42,10 @@ pub extern "C" fn call() {
let err_code = match api::call(
uapi::CallFlags::empty(),
callee_addr,
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
value, // Value transferred to the contract.
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
value, // Value transferred to the contract.
input,
None,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -42,10 +42,10 @@ pub extern "C" fn call() {
api::call(
uapi::CallFlags::empty(),
callee_addr,
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
callee_input,
None,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![no_main]

use common::{input, u256_bytes};
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -40,10 +40,10 @@ pub extern "C" fn call() {
api::call(
uapi::CallFlags::from_bits(flags).unwrap(),
callee_addr,
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
&u256_bytes(value), // Value transferred to the contract.
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&u256_bytes(value), // Value transferred to the contract.
forwarded_input,
None,
)
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/fixtures/contracts/call_with_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -43,7 +43,7 @@ pub extern "C" fn call() {
callee_addr,
ref_time,
proof_size,
&U256_MAX, // No deposit limit.
&[u8::MAX; 32], // No deposit limit.
&[0u8; 32], // value transferred to the contract.
forwarded_input,
None,
Expand Down
50 changes: 25 additions & 25 deletions substrate/frame/revive/fixtures/contracts/caller_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![no_main]

use common::{input, u256_bytes};
use uapi::{HostFn, HostFnImpl as api, ReturnErrorCode, U256_MAX};
use uapi::{HostFn, HostFnImpl as api, ReturnErrorCode};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -42,9 +42,9 @@ pub extern "C" fn call() {
// Fail to deploy the contract since it returns a non-zero exit status.
let res = api::instantiate(
code_hash,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&value,
&reverted_input,
None,
Expand All @@ -56,9 +56,9 @@ pub extern "C" fn call() {
// Fail to deploy the contract due to insufficient ref_time weight.
let res = api::instantiate(
code_hash,
1u64, // too little ref_time weight
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
1u64, // too little ref_time weight
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&value,
&input,
None,
Expand All @@ -70,9 +70,9 @@ pub extern "C" fn call() {
// Fail to deploy the contract due to insufficient proof_size weight.
let res = api::instantiate(
code_hash,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
1u64, // Too little proof_size weight
&U256_MAX, // No deposit limit.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
1u64, // Too little proof_size weight
&[u8::MAX; 32], // No deposit limit.
&value,
&input,
None,
Expand All @@ -86,9 +86,9 @@ pub extern "C" fn call() {

api::instantiate(
code_hash,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&value,
&input,
Some(&mut callee),
Expand All @@ -101,9 +101,9 @@ pub extern "C" fn call() {
let res = api::call(
uapi::CallFlags::empty(),
&callee,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&value,
&reverted_input,
None,
Expand All @@ -114,9 +114,9 @@ pub extern "C" fn call() {
let res = api::call(
uapi::CallFlags::empty(),
&callee,
1u64, // Too little ref_time weight.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
1u64, // Too little ref_time weight.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&value,
&input,
None,
Expand All @@ -127,9 +127,9 @@ pub extern "C" fn call() {
let res = api::call(
uapi::CallFlags::empty(),
&callee,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
1u64, // too little proof_size weight
&U256_MAX, // No deposit limit.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
1u64, // too little proof_size weight
&[u8::MAX; 32], // No deposit limit.
&value,
&input,
None,
Expand All @@ -141,9 +141,9 @@ pub extern "C" fn call() {
api::call(
uapi::CallFlags::empty(),
&callee,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&value,
&input,
Some(&mut &mut output[..]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand Down Expand Up @@ -54,10 +54,10 @@ pub extern "C" fn call() {
api::call(
uapi::CallFlags::ALLOW_REENTRY,
&addr,
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&U256_MAX, // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
u64::MAX, // How much ref_time to devote for the execution. u64::MAX = use all.
u64::MAX, // How much proof_size to devote for the execution. u64::MAX = use all.
&[u8::MAX; 32], // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
input,
None,
)
Expand Down
14 changes: 12 additions & 2 deletions substrate/frame/revive/fixtures/contracts/create1_with_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -34,6 +34,16 @@ pub extern "C" fn call() {
api::value_transferred(&mut value);

// Deploy the contract with no salt (equivalent to create1).
let ret = api::instantiate(code_hash, u64::MAX, u64::MAX, &U256_MAX, &value, &[], None, None, None);
let ret = api::instantiate(
code_hash,
u64::MAX,
u64::MAX,
&[u8::MAX; 32],
&value,
&[],
None,
None,
None
);
assert!(ret.is_ok());
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, StorageFlags, U256_MAX};
use uapi::{HostFn, HostFnImpl as api, StorageFlags};

static BUFFER: [u8; 448] = [0u8; 448];

Expand Down Expand Up @@ -49,10 +49,10 @@ pub extern "C" fn call() {
api::call(
uapi::CallFlags::empty(),
callee,
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = all.
&U256_MAX, // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
u64::MAX, // How much ref_time weight to devote for the execution. u64::MAX = all.
u64::MAX, // How much proof_size weight to devote for the execution. u64::MAX = all.
&[u8::MAX; 32], // No deposit limit.
&[0u8; 32], // Value transferred to the contract.
input,
None,
)
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/revive/fixtures/contracts/delegate_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, StorageFlags, U256_MAX};
use uapi::{HostFn, HostFnImpl as api, StorageFlags};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand Down Expand Up @@ -51,7 +51,7 @@ pub extern "C" fn call() {
address,
ref_time,
proof_size,
&U256_MAX,
&[u8::MAX; 32],
&input,
None
).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![no_main]

use common::input;
use uapi::{HostFn, HostFnImpl as api, U256_MAX};
use uapi::{HostFn, HostFnImpl as api};

#[no_mangle]
#[polkavm_derive::polkavm_export]
Expand All @@ -37,7 +37,7 @@ pub extern "C" fn call() {
address,
u64::MAX,
u64::MAX,
&U256_MAX,
&[u8::MAX; 32],
&input,
None
).unwrap();
Expand Down
Loading

0 comments on commit 3e4bbe8

Please sign in to comment.