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

Mempool Update #705

Merged
merged 32 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
486d331
update msgset
ec2 Sep 8, 2020
21fa7d8
add config and add check message
ec2 Sep 9, 2020
4046996
rename get_sequence to nonce
ec2 Sep 9, 2020
8a22c4d
Arc<StateManager<DB>>
ec2 Sep 10, 2020
36573ea
push with nonce
ec2 Sep 11, 2020
50e1b33
clear
ec2 Sep 14, 2020
67c6db0
Merge branch 'main' into ec2/mpool-update
ec2 Sep 14, 2020
cf49196
config
ec2 Sep 15, 2020
648882e
semantic validation
ec2 Sep 15, 2020
ed8b243
suggestions
ec2 Sep 15, 2020
490b754
Merge branch 'ec2/msg-semantics' into ec2/mpool-update
ec2 Sep 15, 2020
d0f7d90
suggestions
ec2 Sep 15, 2020
09586ea
Merge branch 'main' into ec2/mpool-update
ec2 Sep 16, 2020
061f49b
still working on tests
ec2 Sep 16, 2020
bdc4387
remove
ec2 Sep 16, 2020
4c1d08f
remove the provider
ec2 Sep 16, 2020
2f3ad58
Fix test provider and getting actor state
austinabell Sep 16, 2020
e8eb884
Merge branch 'ec2/mpool-update' of github.com:ChainSafe/forest into e…
austinabell Sep 16, 2020
634ca6d
Remove outdated logic
austinabell Sep 16, 2020
2509acd
lint clippy
ec2 Sep 17, 2020
0070950
accidentally commited file
ec2 Sep 17, 2020
7ca29b2
Merge branch 'main' into ec2/mpool-update
ec2 Sep 17, 2020
504f3c8
handle the subscriber better
ec2 Sep 24, 2020
31b9f7f
nonce to sequence
ec2 Sep 25, 2020
739e739
suggestsion
ec2 Sep 25, 2020
626d0bd
clippy
ec2 Sep 25, 2020
842925f
Merge branch 'main' into ec2/mpool-update
ec2 Sep 25, 2020
9047415
license
ec2 Sep 25, 2020
c9743f9
Merge branch 'main' into ec2/mpool-update
ec2 Sep 28, 2020
d9d682e
suggestions
ec2 Sep 28, 2020
f5487ca
fix test
ec2 Sep 28, 2020
c796b63
suggestions
ec2 Sep 28, 2020
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
99 changes: 96 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion blockchain/message_pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ libsecp256k1 = "0.3.4"
blake2b_simd = "0.5.10"
log = "0.4.8"
async-std = "1.6.0"
async-trait = "0.1"
statrs = "0.13.0"
ec2 marked this conversation as resolved.
Show resolved Hide resolved
state_manager = { path = "../state_manager" }
async-trait = "0.1"
interpreter = { path = "../../vm/interpreter/" }
types = { package = "fil_types", path = "../../types" }

[dev-dependencies]
interpreter = { path = "../../vm/interpreter/" }
Expand Down
78 changes: 78 additions & 0 deletions blockchain/message_pool/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
use address::Address;
use db::Store;
use encoding::{from_slice, to_vec};
use serde::{Deserialize, Serialize};
use std::error::Error as StdError;
use std::time::Duration;

const MPOOL_CONFIG_KEY: &[u8] = b"/mpool/config";
const SIZE_LIMIT_LOW: i64 = 20000;
const SIZE_LIMIT_HIGH: i64 = 30000;
const PRUNE_COOLDOWN: Duration = Duration::from_secs(60); // 1 minute
const REPLACE_BY_FEE_RATIO: f64 = 1.25;
const GAS_LIMIT_OVERESTIMATION: f64 = 1.25;

#[derive(Clone, Serialize, Deserialize)]
pub struct MpoolConfig {
priority_addrs: Vec<Address>,
size_limit_high: i64,
size_limit_low: i64,
replace_by_fee_ratio: f64,
prune_cooldown: Duration,
gas_limit_overestimation: f64,
}

impl Default for MpoolConfig {
fn default() -> Self {
Self {
priority_addrs: vec![],
size_limit_high: SIZE_LIMIT_HIGH,
size_limit_low: SIZE_LIMIT_LOW,
replace_by_fee_ratio: REPLACE_BY_FEE_RATIO,
prune_cooldown: PRUNE_COOLDOWN,
gas_limit_overestimation: GAS_LIMIT_OVERESTIMATION,
}
}
}

impl MpoolConfig {
pub fn new(
priority_addrs: Vec<Address>,
size_limit_high: i64,
size_limit_low: i64,
replace_by_fee_ratio: f64,
prune_cooldown: Duration,
gas_limit_overestimation: f64,
) -> Result<Self, String> {
// Validate if parameters are valid
if replace_by_fee_ratio < REPLACE_BY_FEE_RATIO {
return Err(format!(
"replace_by_fee_ratio:{} is less than required: {}",
replace_by_fee_ratio, REPLACE_BY_FEE_RATIO
));
}
if gas_limit_overestimation < 1.0 {
austinabell marked this conversation as resolved.
Show resolved Hide resolved
return Err(format!(
"gas_limit_overestimation of: {} is less than required: {}",
gas_limit_overestimation, 1
));
}
Ok(Self {
priority_addrs,
size_limit_high,
size_limit_low,
replace_by_fee_ratio,
prune_cooldown,
gas_limit_overestimation,
})
}
pub fn save_config<DB: Store>(&self, store: &DB) -> Result<(), Box<dyn StdError>> {
Ok(store.write(MPOOL_CONFIG_KEY, to_vec(&self)?)?)
}
pub fn load_config<DB: Store>(store: &DB) -> Result<Self, Box<dyn StdError>> {
match store.read(MPOOL_CONFIG_KEY)? {
Some(v) => Ok(from_slice(&v)?),
None => Ok(Default::default()),
}
}
}
4 changes: 4 additions & 0 deletions blockchain/message_pool/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub enum Error {
InvalidFromAddr,
#[error("Message with sequence already in mempool")]
DuplicateSequence,
#[error("State inconsistency with message. Try again")]
TryAgain,
#[error("Validation Error: {0}")]
SoftValidationFailure(String),
#[error("{0}")]
Other(String),
}
Expand Down
4 changes: 3 additions & 1 deletion blockchain/message_pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

mod errors;
mod msgpool;

// mod block_prob;
ec2 marked this conversation as resolved.
Show resolved Hide resolved
mod config;
pub use self::config::*;
pub use self::errors::*;
pub use self::msgpool::*;
Loading