Skip to content

Commit

Permalink
fix maximum transaction size to 256K
Browse files Browse the repository at this point in the history
  • Loading branch information
davidiw authored and aptos-bot committed May 8, 2022
1 parent 416bc14 commit 6dafa63
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
16 changes: 13 additions & 3 deletions aptos-move/aptos-vm/src/aptos_vm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use move_deps::{
value::{serialize_values, MoveValue},
},
move_vm_runtime::{logging::expect_no_verification_errors, session::Session},
move_vm_types::gas_schedule::{calculate_intrinsic_gas, GasStatus},
move_vm_types::gas_schedule::GasStatus,
};
use std::sync::Arc;

Expand Down Expand Up @@ -190,8 +190,18 @@ impl AptosVMImpl {
// The submitted transactions max gas units needs to be at least enough to cover the
// intrinsic cost of the transaction as calculated against the size of the
// underlying `RawTransaction`
let min_txn_fee =
gas_constants.to_external_units(calculate_intrinsic_gas(raw_bytes_len, gas_constants));
let min_txn_fee = {
let min_transaction_fee = gas_constants.min_transaction_gas_units;

if raw_bytes_len.get() > gas_constants.large_transaction_cutoff.get() {
let excess = raw_bytes_len.sub(gas_constants.large_transaction_cutoff);
min_transaction_fee.add(gas_constants.intrinsic_gas_per_byte.mul(excess))
} else {
min_transaction_fee.unitary_cast()
}
};
let min_txn_fee = gas_constants.to_external_units(min_txn_fee);

if txn_data.max_gas_amount().get() < min_txn_fee.get() {
warn!(
*log_context,
Expand Down
4 changes: 3 additions & 1 deletion aptos-move/e2e-testsuite/src/tests/verify_txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ use language_e2e_tests::{
use move_deps::{
move_binary_format::file_format::CompiledModule,
move_core_types::{
gas_schedule::{GasAlgebra, GasConstants, MAX_TRANSACTION_SIZE_IN_BYTES},
gas_schedule::{GasAlgebra, GasConstants},
identifier::Identifier,
language_storage::{StructTag, TypeTag},
vm_status::StatusCode::MODULE_ADDRESS_DOES_NOT_MATCH_SENDER,
},
move_ir_compiler::Compiler,
};

pub const MAX_TRANSACTION_SIZE_IN_BYTES: u64 = 262144;

#[test]
fn verify_signature() {
test_with_different_versions! {CURRENT_RELEASE_VERSIONS, |test_env| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module AptosFramework::VMConfig {
maximum_number_of_gas_units: 4000000,
min_price_per_gas_unit,
max_price_per_gas_unit: 10000,
max_transaction_size_in_bytes: 4096,
max_transaction_size_in_bytes: 262144,
gas_unit_scaling_factor: 1000,
default_account_size: 800,
};
Expand Down
4 changes: 3 additions & 1 deletion vm-validator/src/unit_tests/vm_validator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ use aptos_vm::AptosVM;
use aptosdb::AptosDB;
use move_core_types::{
account_address::AccountAddress,
gas_schedule::{GasAlgebra, GasConstants, MAX_TRANSACTION_SIZE_IN_BYTES},
gas_schedule::{GasAlgebra, GasConstants},
};
use rand::SeedableRng;
use storage_interface::DbReaderWriter;

const MAX_TRANSACTION_SIZE_IN_BYTES: u64 = 262144;

struct TestValidator {
vm_validator: VMValidator,
_db_path: aptos_temppath::TempPath,
Expand Down

0 comments on commit 6dafa63

Please sign in to comment.