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

Update price list for calico VM gas #918

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
5 changes: 3 additions & 2 deletions vm/interpreter/src/gas_block_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::price_list_by_epoch;
use cid::Code::Blake2b256;
use db::MemoryDB;
use vm::{ActorError, ExitCode};
Expand All @@ -109,7 +110,7 @@ mod tests {
ipld_get_base: 4,
ipld_put_base: 2,
ipld_put_per_byte: 1,
..Default::default()
..price_list_by_epoch(0)
},
gas: Rc::new(RefCell::new(GasTracker::new(5000, 0))),
store: &db,
Expand All @@ -128,7 +129,7 @@ mod tests {
let gbs = GasBlockStore {
price_list: PriceList {
ipld_put_base: 12,
..Default::default()
..price_list_by_epoch(0)
},
gas: Rc::new(RefCell::new(GasTracker::new(10, 0))),
store: &db,
Expand Down
77 changes: 68 additions & 9 deletions vm/interpreter/src/gas_tracker/price_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use clock::ChainEpoch;
use crypto::SignatureType;
use fil_types::{
PieceInfo, RegisteredPoStProof, RegisteredSealProof, SealVerifyInfo, WindowPoStVerifyInfo,
UPGRADE_CALICO_HEIGHT,
};
use num_traits::Zero;
use vm::{MethodNum, TokenAmount, METHOD_SEND};
Expand Down Expand Up @@ -66,6 +67,64 @@ lazy_static! {
.iter()
.copied()
.collect(),
verify_post_discount: true,
};

static ref CALICO_PRICES: PriceList = PriceList {
on_chain_message_compute_base: 38863,
on_chain_message_storage_base: 36,
on_chain_message_storage_per_byte: 1,

on_chain_return_value_per_byte: 1,

send_base: 29233,
send_transfer_funds: 27500,
send_transfer_only_premium: 159672,
send_invoke_method: -5377,

ipld_get_base: 114617,
ipld_put_base: 353640,
ipld_put_per_byte: 1,

create_actor_compute: 1108454,
create_actor_storage: 36 + 40,
delete_actor: -(36 + 40),

bls_sig_cost: 16598605,
secp256k1_sig_cost: 1637292,

hashing_base: 31355,
compute_unsealed_sector_cid_base: 98647,
verify_seal_base: 2000, // TODO revisit potential removal of this
verify_consensus_fault: 495422,

verify_post_lookup: [
(
RegisteredPoStProof::StackedDRGWindow512MiBV1,
ScalingCost {
flat: 117680921,
scale: 43780,
},
),
(
RegisteredPoStProof::StackedDRGWindow32GiBV1,
ScalingCost {
flat: 117680921,
scale: 43780,
},
),
(
RegisteredPoStProof::StackedDRGWindow64GiBV1,
ScalingCost {
flat: 117680921,
scale: 43780,
},
),
]
.iter()
.copied()
.collect(),
verify_post_discount: false,
};
}

Expand Down Expand Up @@ -146,6 +205,7 @@ pub struct PriceList {
pub compute_unsealed_sector_cid_base: i64,
pub verify_seal_base: i64,
pub verify_post_lookup: AHashMap<RegisteredPoStProof, ScalingCost>,
pub verify_post_discount: bool,
pub verify_consensus_fault: i64,
}

Expand Down Expand Up @@ -259,7 +319,9 @@ impl PriceList {
});

let mut gas_used = cost.flat + info.challenged_sectors.len() as i64 * cost.scale;
gas_used /= 2;
if self.verify_post_discount {
gas_used /= 2;
}

GasCharge::new("OnVerifyPost", gas_used, 0)
}
Expand All @@ -270,14 +332,11 @@ impl PriceList {
}
}

impl Default for PriceList {
fn default() -> Self {
/// Returns gas price list by Epoch for gas consumption
pub fn price_list_by_epoch(epoch: ChainEpoch) -> PriceList {
if epoch < UPGRADE_CALICO_HEIGHT {
BASE_PRICES.clone()
} else {
CALICO_PRICES.clone()
}
}

/// Returns gas price list by Epoch for gas consumption
pub fn price_list_by_epoch(_epoch: ChainEpoch) -> PriceList {
// In future will match on epoch and select matching price lists when config options allowed
BASE_PRICES.clone()
}