Skip to content

Commit c62b5c1

Browse files
committed
tolerate randomness gas deposit calc error
1 parent cf9ebc5 commit c62b5c1

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

aptos-move/aptos-vm/src/aptos_vm.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ impl AptosVM {
16371637
&gas_meter.vm_gas_params().txn,
16381638
&txn_data,
16391639
txn.payload(),
1640-
)?;
1640+
);
16411641
txn_data.set_required_deposit(required_deposit);
16421642
self.validate_signed_transaction(session, resolver, txn, &txn_data, log_context)
16431643
}));
@@ -2319,11 +2319,11 @@ impl AptosVM {
23192319
txn_gas_params: &TransactionGasParameters,
23202320
txn_metadata: &TransactionMetadata,
23212321
payload: &TransactionPayload,
2322-
) -> VMResult<Option<u64>> {
2322+
) -> Option<u64> {
23232323
match payload {
23242324
TransactionPayload::EntryFunction(entry_func) => {
23252325
if self.randomness_enabled
2326-
&& has_randomness_attribute(resolver, session, entry_func)?
2326+
&& has_randomness_attribute(resolver, session, entry_func).unwrap_or(false)
23272327
{
23282328
let max_execution_gas: Gas = txn_gas_params
23292329
.max_execution_gas
@@ -2336,14 +2336,14 @@ impl AptosVM {
23362336
let cand_1 =
23372337
txn_metadata.gas_unit_price * txn_gas_params.maximum_number_of_gas_units;
23382338
let required_fee_deposit = min(cand_0, cand_1);
2339-
Ok(Some(u64::from(required_fee_deposit)))
2339+
Some(u64::from(required_fee_deposit))
23402340
} else {
2341-
Ok(None)
2341+
None
23422342
}
23432343
},
23442344
TransactionPayload::Script(_)
23452345
| TransactionPayload::ModuleBundle(_)
2346-
| TransactionPayload::Multisig(_) => Ok(None),
2346+
| TransactionPayload::Multisig(_) => None,
23472347
}
23482348
}
23492349
}
@@ -2481,7 +2481,7 @@ impl VMValidator for AptosVM {
24812481

24822482
let resolver = self.as_move_resolver(&state_view);
24832483
let mut session = self.new_session(&resolver, SessionId::prologue_meta(&txn_data));
2484-
let maybe_required_deposit = if let Ok(gas_params) = &self.gas_params {
2484+
let required_deposit = if let Ok(gas_params) = &self.gas_params {
24852485
self.get_required_deposit(
24862486
&mut session,
24872487
&resolver,
@@ -2493,13 +2493,6 @@ impl VMValidator for AptosVM {
24932493
return VMValidatorResult::error(StatusCode::GAS_PARAMS_MISSING);
24942494
};
24952495

2496-
let required_deposit = match maybe_required_deposit {
2497-
Ok(v) => v,
2498-
Err(_e) => {
2499-
return VMValidatorResult::error(StatusCode::DEPOSIT_CALCULATION_FAILED);
2500-
},
2501-
};
2502-
25032496
txn_data.set_required_deposit(required_deposit);
25042497

25052498
// Increment the counter for transactions verified.

third_party/move/move-core/types/src/vm_status.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,11 @@ pub enum StatusCode {
585585
GAS_PAYER_ACCOUNT_MISSING = 36,
586586
INSUFFICIENT_BALANCE_FOR_REQUIRED_DEPOSIT = 37,
587587
GAS_PARAMS_MISSING = 38,
588-
DEPOSIT_CALCULATION_FAILED = 39,
589588
// Reserved error code for future use
589+
RESERVED_VALIDATION_ERROR_4 = 39,
590590
RESERVED_VALIDATION_ERROR_5 = 40,
591591
RESERVED_VALIDATION_ERROR_6 = 41,
592592
RESERVED_VALIDATION_ERROR_7 = 42,
593-
RESERVED_VALIDATION_ERROR_8 = 43,
594593

595594
// When a code module/script is published it is verified. These are the
596595
// possible errors that can arise from the verification process.

0 commit comments

Comments
 (0)