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 msg pool #449

Merged
merged 47 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4ce62e7
switched state_manager db to a chainstore
flodesi May 26, 2020
3235b0c
started messagepool, added code structure and started mempool provide…
flodesi May 26, 2020
3f12a6d
Merge branch 'master' into jaden/implement-msg-pool
flodesi May 26, 2020
9303053
updated mpool cargo.toml
flodesi May 26, 2020
1b1d3ed
fixed dependency and some clippy
flodesi May 26, 2020
5d6f622
added license
flodesi May 26, 2020
bba60ea
added add to msgpool
flodesi May 28, 2020
30ea670
finished add and reverted state_manager back to normal
flodesi May 28, 2020
13c321d
Merge branch 'master' into jaden/implement-msg-pool
flodesi May 28, 2020
2822083
commenting and fmt
flodesi May 28, 2020
c01e669
added some unimplemented functions
flodesi May 31, 2020
d738418
fmt, clippy and documentation
flodesi Jun 1, 2020
278d80d
fix merge conflict
flodesi Jun 3, 2020
9ff011d
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 3, 2020
652c19e
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 5, 2020
48f24d4
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 8, 2020
2020516
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 10, 2020
85e1aae
added prelim msgpool test
flodesi Jun 16, 2020
48055cc
fixed merge conflict
flodesi Jun 16, 2020
7d693a8
first test
flodesi Jun 16, 2020
202f86b
finished tests
flodesi Jun 18, 2020
dffff0b
fmt and clippy
flodesi Jun 19, 2020
1e34c96
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 19, 2020
1ca5b38
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 19, 2020
7275d9b
added changes
flodesi Jun 23, 2020
c2d139c
added changes
flodesi Jun 24, 2020
807ddec
Merge branch 'master' into jaden/implement-msg-pool
flodesi Jun 24, 2020
8c15afb
added async subscribe new heads
flodesi Jun 27, 2020
923678c
Merge branch 'jaden/implement-msg-pool' of https://github.com/ChainSa…
flodesi Jun 27, 2020
0f41e5b
fmt
flodesi Jun 27, 2020
d1e2e54
Merge branch 'main' into jaden/implement-msg-pool
flodesi Jun 28, 2020
f244be5
added better error handling
flodesi Jun 29, 2020
c9ebd9f
Merge branch 'main' into jaden/implement-msg-pool
flodesi Jun 29, 2020
4d64d97
removed mutex around messagepool, and cleaned up code
flodesi Jun 30, 2020
ca23f23
rm unneeded mutex and cleaned up msgs for ts
flodesi Jul 1, 2020
9801e44
replaced mutex with rwlock in mpool
flodesi Jul 1, 2020
69c39bd
Merge branch 'main' into jaden/implement-msg-pool
flodesi Jul 1, 2020
5c67b81
add comment
flodesi Jul 2, 2020
fb4b2e5
applied changes
flodesi Jul 6, 2020
57b6eb9
fixes and code cleanup
flodesi Jul 6, 2020
1c9b32b
add box to local_msgs
flodesi Jul 6, 2020
ce90bdd
remove box
flodesi Jul 7, 2020
6d2bc48
added push to add_local when no error
flodesi Jul 7, 2020
bb13174
Merge branch 'jaden/implement-msg-pool' of https://github.com/chainsa…
flodesi Jul 7, 2020
3f1548c
Merge branch 'main' into jaden/implement-msg-pool
flodesi Jul 7, 2020
a045654
revert add_helper to use refs
flodesi Jul 7, 2020
be9a58d
changed local_msgs to hashset and refactor
flodesi Jul 7, 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
29 changes: 29 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"blockchain/state_manager",
"blockchain/chain_sync",
"blockchain/beacon",
"blockchain/message_pool",
flodesi marked this conversation as resolved.
Show resolved Hide resolved
"vm",
"vm/actor",
"vm/address",
Expand Down
18 changes: 18 additions & 0 deletions blockchain/chain/src/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ where
// the given tipset has already been verified, so this cannot fail
Ok(FullTipset::new(blocks).unwrap())
}

/// Determines if provided tipset is heavier than existing known heaviest tipset
async fn update_heaviest(&mut self, ts: &Tipset) -> Result<(), Error> {
match &self.heaviest {
Expand All @@ -199,6 +200,23 @@ where
}
Ok(())
}

/// Return the messages in the chainstore for a given tipset
pub fn messages_for_tipset(&self, h: &Tipset) -> Result<Vec<UnsignedMessage>, Error> {
flodesi marked this conversation as resolved.
Show resolved Hide resolved
let mut umsg: Vec<UnsignedMessage> = Vec::new();
let mut msgs: Vec<SignedMessage> = Vec::new();
for bh in h.blocks().iter() {
let (mut bh_umsg_tmp, mut bh_msg_tmp) = block_messages(self.blockstore(), bh)?;
let bh_umsg = &mut bh_umsg_tmp;
let bh_msg = &mut bh_msg_tmp;
umsg.append(bh_umsg);
msgs.append(bh_msg);
}
for msg in msgs {
umsg.push(msg.into_message());
}
Ok(umsg)
}
}

/// Returns a Tuple of bls messages of type UnsignedMessage and secp messages
Expand Down
32 changes: 32 additions & 0 deletions blockchain/message_pool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "message_pool"
version = "0.1.0"
authors = ["ChainSafe Systems <info@chainsafe.io>"]
edition = "2018"

[dependencies]
address = { package = "forest_address", path = "../../vm/address" }
vm = { package = "forest_vm", path = "../../vm" }
blocks = { package = "forest_blocks", path = "../blocks" }
message = { package = "forest_message", path = "../../vm/message" }
thiserror = "1.0"
cid = { package = "forest_cid", path = "../../ipld/cid", version = "0.1" }
encoding = { package = "forest_encoding", path = "../../encoding", version = "0.1" }
blockstore = { package = "ipld_blockstore", path = "../../ipld/blockstore/" }
num-bigint = { path = "../../utils/bigint", package = "forest_bigint" }
lru = "0.5.1"
crypto = { package = "forest_crypto", path = "../../crypto", version = "0.2" }
chain = { path = "../chain"}
state_tree = { path = "../../vm/state_tree/" }
serde = { version = "1.0", features = ["derive"] }
db = { path = "../../node/db" }
flo_stream = "0.4.0"
async-std = "1.6.0"
futures = "0.3.5"
libsecp256k1 = "0.3.4"
blake2b_simd = "0.5.10"
log = "0.4.8"

[dev-dependencies]
interpreter = { path = "../../vm/interpreter/" }
key_management = { path = "../../key_management"}
48 changes: 48 additions & 0 deletions blockchain/message_pool/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use chain::Error as ChainError;
use encoding::Error as EncodeError;
use thiserror::Error;

// /// MessagePool error
#[derive(Debug, PartialEq, Error)]
pub enum Error {
/// Error indicating message that's too large
#[error("Message is too big")]
MessageTooBig,
#[error("Cannot send more Filecoin than will ever exist")]
MessageValueTooHigh,
#[error("Message sequence too low")]
SequenceTooLow,
#[error("Not enough funds to execute transaction")]
NotEnoughFunds,
#[error("Invalid to address for message")]
InvalidToAddr,
#[error("Invalid from address")]
InvalidFromAddr,
#[error("Message with sequence already in mempool")]
DuplicateSequence,
#[error("Signature validation failed")]
SigVerification,
#[error("Unknown signature type")]
UnknownSigType,
#[error("BLS signature too short")]
BLSSigTooShort,
#[error("{0}")]
Other(String),
#[error("Mutex is either poisoned or data inside could not be accessed at this current time")]
MutexPoisonError,
}

impl From<ChainError> for Error {
fn from(ce: ChainError) -> Self {
Error::Other(ce.to_string())
}
}

impl From<EncodeError> for Error {
fn from(ee: EncodeError) -> Self {
Error::Other(ee.to_string())
}
}
8 changes: 8 additions & 0 deletions blockchain/message_pool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod errors;
mod msgpool;

pub use self::errors::*;
pub use self::msgpool::*;
Loading