Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement FIP-0032 gas parameters and charges #534

Merged
merged 28 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b2757db
exec gas: apply only on non-structural instructions.
raulk May 5, 2022
7102ce7
pricelist: add new gas fees.
raulk May 6, 2022
4933e51
gas: fully switch to milligas as canonical unit.
raulk May 6, 2022
91bec8a
price list: update gas cost formulae.
raulk May 6, 2022
771dbcc
price list: vertical spacing.
raulk May 6, 2022
8ffcedf
kernel: apply extern gas.
raulk May 6, 2022
7c0f9a9
syscalls: charge for gas; small refactors.
raulk May 6, 2022
c98f046
remove Kernel#charge_milligas().
raulk May 6, 2022
eb7e7fc
fix tests.
raulk May 7, 2022
952f11a
fix param.
raulk May 7, 2022
6208be5
clippy.
raulk May 7, 2022
9183750
add comment.
raulk May 7, 2022
9999204
fix gas instrumentation.
raulk May 7, 2022
76f07a4
rename GasTracker#{charge_gas=>apply_charge} to disambiguate.
raulk May 8, 2022
d19ef2e
add Gas and Milligas unit types to disambiguate.
raulk May 8, 2022
a798545
convert public gas charges to milligas.
raulk May 8, 2022
be0fdb1
inclusion cost: adapt to milligas.
raulk May 8, 2022
4bb0a89
charge_gas: move conversion to milligas to syscall handler.
raulk May 8, 2022
17b1e0b
{to_milligas=>static_milligas}; make private.
raulk May 8, 2022
b7b41d0
clippy.
raulk May 8, 2022
573afca
price list: remove compute_gas_multiplier (unused).
raulk May 9, 2022
2a957c1
polish comment.
raulk May 9, 2022
c8b5241
use saturation arithmetics for mem costs.
raulk May 9, 2022
1dd5c51
Merge branch 'master' into raulk/fip-0032-parameters
raulk May 9, 2022
4d0d8bd
price list: use Milligas type for cost fields.
raulk May 9, 2022
5fe4437
rename Kernel#charge_{=>milli}gas.
raulk May 9, 2022
2bd6769
add extern cost in syscall pricing formulae.
raulk May 9, 2022
5791726
charge for syscall gas at the right place.
raulk May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fvm/src/call_manager/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::gas::GasTracker;
use crate::kernel::{ExecutionError, Kernel, Result, SyscallError};
use crate::machine::Machine;
use crate::syscalls::error::Abort;
use crate::syscalls::{charge_for_exec, update_gas_available};
use crate::syscalls::{apply_charges_on_syscall, update_gas_available};
use crate::trace::{ExecutionEvent, ExecutionTrace, SendParams};
use crate::{account_actor, syscall_error};

Expand Down Expand Up @@ -362,7 +362,7 @@ where

// Charge for any remaining uncharged execution gas, returning an error if we run
// out.
charge_for_exec(&mut store)?;
apply_charges_on_syscall(&mut store)?;

// If the invocation failed due to running out of exec_units, we have already detected it and returned OutOfGas above.
// Any other invocation failure is returned here as an Abort
Expand Down
5 changes: 4 additions & 1 deletion fvm/src/gas/charge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
/// as the amount of gas needed for computation and storage respectively.
pub struct GasCharge<'a> {
pub name: &'a str,
/// Compute costs in milligas.
pub compute_gas: i64,
/// Storage costs in milligas.
pub storage_gas: i64,
}

Expand All @@ -18,7 +20,8 @@ impl<'a> GasCharge<'a> {
}
}

/// Calculates total gas charge based on compute and storage multipliers.
/// Calculates total gas charge (in milligas) based on compute and storage
/// multipliers.
pub fn total(&self) -> i64 {
self.compute_gas + self.storage_gas
}
Expand Down
6 changes: 2 additions & 4 deletions fvm/src/gas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ impl GasTracker {
}
}

/// Applies the specified gas charge, where quantities are supplied in milligas.
pub fn charge_gas(&mut self, charge: GasCharge) -> Result<()> {
self.charge_milligas(
charge.name,
charge.total().saturating_mul(MILLIGAS_PRECISION),
)
self.charge_milligas(charge.name, charge.total())
}

/// Getter for gas available.
Expand Down
Loading