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

Fix block validations and add chain export test #741

Merged
merged 27 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
00a2f18
Move genesis utilities to shared utils crate
austinabell Oct 6, 2020
272f9f5
Setup test (blocked on bs provider logic)
austinabell Oct 6, 2020
f5f789a
remove unused deps
austinabell Oct 6, 2020
22e556b
merge main
austinabell Oct 11, 2020
774f04a
Merge branch 'main' of github.com:ChainSafe/forest into austin/export…
austinabell Oct 11, 2020
9b7b2dc
Connect blocksync provider with test
austinabell Oct 11, 2020
bc17c31
ignore test
austinabell Oct 11, 2020
9c98248
Update to drand beacon and fix bug
austinabell Oct 11, 2020
f28a746
Fix ticket validation
austinabell Oct 13, 2020
22b032f
Use pre smoke drand beacon
austinabell Oct 13, 2020
ddfa340
Remove todo and add doc comment
austinabell Oct 13, 2020
9e05547
Fix weight calculation
austinabell Oct 13, 2020
fe308a4
Clean up message validation logic
austinabell Oct 13, 2020
20e0c7b
Fix sequence check logic
austinabell Oct 13, 2020
1adf4ab
Fix miner validation
austinabell Oct 13, 2020
c9aa37d
Use shared export file for testing
austinabell Oct 13, 2020
535036e
Add semantic message validation and fix total filecoin constant
austinabell Oct 13, 2020
2c5090d
Uncomment skip
austinabell Oct 13, 2020
cb3b620
Merge branch 'main' into austin/exporttest
austinabell Oct 13, 2020
44f10ef
Change daemon default beacon
austinabell Oct 13, 2020
6b043a5
Fix success status code
austinabell Oct 13, 2020
633803f
Limit workers temporarily
austinabell Oct 13, 2020
7438c2b
Merge branch 'main' into austin/exporttest
austinabell Oct 14, 2020
7579596
Merge branch 'main' into austin/exporttest
austinabell Oct 14, 2020
2831ab4
Merge branch 'main' into austin/exporttest
austinabell Oct 15, 2020
85983ea
Merge branch 'main' into austin/exporttest
austinabell Oct 15, 2020
fac85a8
Fix doc comment
austinabell Oct 15, 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
49 changes: 23 additions & 26 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ members = [
"ipld",
"ipld/hamt",
"ipld/blockstore",
"ipld/graphsync",
# TODO re-enable graphsync when work continues
# "ipld/graphsync",
"utils/bigint",
"tests/serialization_tests",
"tests/conformance_tests",
"utils/bitfield",
"utils/test_utils",
"utils/commcid",
"utils/json_utils",
"utils/genesis",
"types",
"key_management",
]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ clean:
@cargo clean -p forest_json_utils
@cargo clean -p test_utils
@cargo clean -p message_pool
@cargo clean -p genesis
@echo "Done cleaning."

lint: license clean
Expand Down
2 changes: 1 addition & 1 deletion blockchain/beacon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ features = ["json"]
ahash = "0.4"
async-std = { version = "1.6.3", features = ["unstable"] }
clock = { path = "../../node/clock" }
bls-signatures = "0.6.0"
bls-signatures = "0.6.1"
serde = { version = "1.0", features = ["derive"] }
encoding = { path = "../../encoding", package = "forest_encoding" }
sha2 = { version = "0.9", default-features = false }
Expand Down
7 changes: 4 additions & 3 deletions blockchain/beacon/src/drand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use std::convert::TryFrom;
use std::error;

/// Default endpoint for the drand beacon node.
pub const DEFAULT_DRAND_URL: &str = "https://api.drand.sh";
// TODO this URL is only valid until smoke fork, should setup schedule for drand upgrade
pub const DEFAULT_DRAND_URL: &str = "https://pl-us.incentinet.drand.sh";

/// Enviromental Variable to ignore Drand. Lotus parallel is LOTUS_IGNORE_DRAND
pub const IGNORE_DRAND_VAR: &str = "IGNORE_DRAND";
Expand Down Expand Up @@ -74,6 +75,7 @@ pub struct DrandBeacon {
url: Cow<'static, str>,

pub_key: DrandPublic,
/// Interval between beacons, in seconds.
interval: u64,
drand_gen_time: u64,
fil_gen_time: u64,
Expand Down Expand Up @@ -163,8 +165,7 @@ impl Beacon for DrandBeacon {

fn max_beacon_round_for_epoch(&self, fil_epoch: ChainEpoch) -> u64 {
let latest_ts =
fil_epoch as u64 * self.fil_round_time + self.fil_gen_time - self.fil_round_time;
// TODO: self.interval has to be converted to seconds. Dont know what it is right now
((fil_epoch as u64 * self.fil_round_time) + self.fil_gen_time) - self.fil_round_time;
(latest_ts - self.drand_gen_time) / self.interval
}
}
1 change: 0 additions & 1 deletion blockchain/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async-std = "1.6.3"
types = { package = "fil_types", path = "../../types" }
lazy_static = "1.4"


[features]
json = []

Expand Down
21 changes: 16 additions & 5 deletions blockchain/chain/src/store/chain_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,22 @@ where
);
};

let out_add: BigInt = &log2_p << 8;
let mut out = ts.weight().to_owned() + out_add;
let e_weight: BigInt = ((log2_p * BigInt::from(ts.blocks().len())) * W_RATIO_NUM) << 8;
let value: BigInt = e_weight.div_floor(&(BigInt::from(BLOCKS_PER_EPOCH) * W_RATIO_DEN));
out += &value;
let mut total_j = 0;
for b in ts.blocks() {
total_j += b
.election_proof()
.as_ref()
.ok_or("Block contained no election proof when calculating weight")?
.win_count;
}

let mut out = ts.weight().to_owned();
out += &log2_p << 8;
let mut e_weight: BigInt = log2_p * W_RATIO_NUM;
e_weight <<= 8;
e_weight *= total_j;
e_weight = e_weight.div_floor(&(BigInt::from(BLOCKS_PER_EPOCH * W_RATIO_DEN)));
out += &e_weight;
Ok(out)
}

Expand Down
7 changes: 6 additions & 1 deletion blockchain/chain_sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ libp2p = { version = "0.24", default-features = false }
cid = { package = "forest_cid", path = "../../ipld/cid" }
ipld_blockstore = { path = "../../ipld/blockstore" }
chain = { path = "../chain" }
message = { package = "forest_message", path = "../../vm/message" }
message = { package = "forest_message", path = "../../vm/message", features = ["proofs"] }
state_tree = { path = "../../vm/state_tree/" }
state_manager = { path = "../state_manager/" }
num-bigint = { path = "../../utils/bigint", package = "forest_bigint" }
Expand All @@ -38,7 +38,12 @@ flo_stream = "0.4.0"
rand = "0.7.3"
smallvec = "1.1.0"
actor = { path = "../../vm/actor" }
interpreter = { path = "../../vm/interpreter/" }

[dev-dependencies]
test_utils = { version = "0.1.0", path = "../../utils/test_utils/", features = ["test_constructors"] }
base64 = "0.12.1"
genesis = { path = "../../utils/genesis", features = ["testing"] }
pretty_env_logger = "0.4.0"
forest_car = { path = "../../ipld/car" }
hex = "0.4"
Loading