Skip to content

Commit

Permalink
fix(gtest): bump memory limit to 2GB (#4391)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx authored Dec 10, 2024
1 parent 1f2bddd commit a967e29
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
3 changes: 0 additions & 3 deletions core-processor/src/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ use gear_core::{

pub use gear_wasm_instrument::syscalls::SyscallName;

/// Number of max pages number to use it in tests.
pub const TESTS_MAX_PAGES_NUMBER: u16 = 512;

/// Contextual block information.
#[derive(Clone, Copy, Debug, Default)]
pub struct BlockInfo {
Expand Down
9 changes: 6 additions & 3 deletions gtest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,13 @@ pub mod constants {

/// Gas allowance for executing user dispatch and set of generated
/// by programs dispatches from execution of the user dispatch.
pub const GAS_ALLOWANCE: Gas = 750_000_000_000;
pub const GAS_ALLOWANCE: Gas = 1_000_000_000_000;

/// Max allowed user gas to apply for external message.
pub const MAX_USER_GAS_LIMIT: Gas = 750_000_000_000;

/// Gas multiplier used to calculate equivalence of gas in token value.
pub const GAS_MULTIPLIER: GasMultiplier<Value, Gas> = GasMultiplier::ValuePerGas(6);
pub const GAS_MULTIPLIER: GasMultiplier<Value, Gas> = GasMultiplier::ValuePerGas(VALUE_PER_GAS);

/* Currency-related constants */

Expand Down Expand Up @@ -583,5 +586,5 @@ pub mod constants {
}

/// Default initial balance for users.
pub const DEFAULT_USERS_INITIAL_BALANCE: Value = EXISTENTIAL_DEPOSIT * 100_000;
pub const DEFAULT_USERS_INITIAL_BALANCE: Value = 100_000 * UNITS;
}
25 changes: 12 additions & 13 deletions gtest/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

mod block_exec;
mod expend;
mod hold_bound;
mod journal;
mod memory;
mod reservations;
mod send_dispatch;
mod task;
mod wait_wake;

use crate::{
constants::Value,
error::usage_panic,
Expand All @@ -45,9 +35,8 @@ use crate::{
GAS_MULTIPLIER, INITIAL_RANDOM_SEED, MAX_RESERVATIONS, RESERVE_FOR, VALUE_PER_GAS,
};
use core_processor::{
common::*,
configs::{BlockConfig, TESTS_MAX_PAGES_NUMBER},
ContextChargedForInstrumentation, ContextChargedForProgram, Ext,
common::*, configs::BlockConfig, ContextChargedForInstrumentation, ContextChargedForProgram,
Ext,
};
use gear_common::{
auxiliary::{
Expand Down Expand Up @@ -81,6 +70,16 @@ use std::{
mem,
};

mod block_exec;
mod expend;
mod hold_bound;
mod journal;
mod memory;
mod reservations;
mod send_dispatch;
mod task;
mod wait_wake;

const OUTGOING_LIMIT: u32 = 1024;
const OUTGOING_BYTES_LIMIT: u32 = 64 * 1024 * 1024;

Expand Down
4 changes: 2 additions & 2 deletions gtest/src/manager/block_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use core_processor::SuccessfulDispatchResultKind;
use gear_core::{gas::GasCounter, str::LimitedStr};
use gear_core::{code::MAX_WASM_PAGES_AMOUNT, gas::GasCounter, str::LimitedStr};
use task::get_maximum_task_gas;

use super::*;
Expand Down Expand Up @@ -540,7 +540,7 @@ impl ExtManager {
existential_deposit: EXISTENTIAL_DEPOSIT,
mailbox_threshold: schedule.rent_weights.mailbox_threshold.ref_time,
max_reservations: MAX_RESERVATIONS,
max_pages: TESTS_MAX_PAGES_NUMBER.into(),
max_pages: MAX_WASM_PAGES_AMOUNT.into(),
outgoing_limit: OUTGOING_LIMIT,
outgoing_bytes_limit: OUTGOING_BYTES_LIMIT,
}
Expand Down
4 changes: 2 additions & 2 deletions gtest/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
manager::ExtManager,
state::actors::{Actors, GenuineProgram, Program as InnerProgram, TestActor},
system::System,
Result, Value, GAS_ALLOWANCE,
Result, Value, MAX_USER_GAS_LIMIT,
};
use codec::{Codec, Decode, Encode};
use gear_core::{
Expand Down Expand Up @@ -539,7 +539,7 @@ impl<'a> Program<'a> {
ID: Into<ProgramIdWrapper>,
T: Into<Vec<u8>>,
{
self.send_bytes_with_gas_and_value(from, payload, GAS_ALLOWANCE, value)
self.send_bytes_with_gas_and_value(from, payload, MAX_USER_GAS_LIMIT, value)
}

/// Send the message to the program with bytes payload, gas limit and value.
Expand Down
4 changes: 2 additions & 2 deletions gtest/src/state/mailbox/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
error::usage_panic,
manager::ExtManager,
state::{accounts::Accounts, actors::Actors},
Log, Value, GAS_ALLOWANCE,
Log, Value, MAX_USER_GAS_LIMIT,
};
use codec::Encode;
use gear_common::{
Expand Down Expand Up @@ -96,7 +96,7 @@ impl<'a> ActorMailbox<'a> {
{
0
} else {
GAS_ALLOWANCE
MAX_USER_GAS_LIMIT
};

// Build a reply message
Expand Down

0 comments on commit a967e29

Please sign in to comment.