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

feat: certs part 2 #14

Merged
merged 33 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.6
timeout-minutes: 5
continue-on-error: true
- run: cargo llvm-cov --all-features --lcov --output-path lcov.info
env:
RUSTC_WRAPPER:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ edition = "2021"

[workspace.dependencies]
ahash = "0.8.11"
anyhow = "1.0"
fvm_ipld_encoding = "0.4.0"
keccak-hash = "0.11.0"
thiserror = "1.0.41"
5 changes: 5 additions & 0 deletions certs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ edition = "2021"

[dependencies]
ahash = { workspace = true }
anyhow = { workspace = true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a dev-dependency, I think.

filecoin-f3-gpbft = { path = "../gpbft" }
keccak-hash = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
filecoin-f3-gpbft = { path = "../gpbft", features = ["test-utils"] }
69 changes: 69 additions & 0 deletions certs/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use filecoin_f3_gpbft::{ActorId, CborError, GPBFTError};
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum CertsError {
#[error("empty chain")]
EmptyChain,

#[error("empty power delta")]
EmptyPowerDelta,

#[error("invalid justification: {0}")]
InvalidJustification(String),

#[error("got a decision for bottom for instance {0}")]
BottomDecision(u64),

#[error("invalid power table delta: {0}")]
InvalidPowerTableDelta(String),

#[error("serialization error: {0}")]
SerializationError(String),

#[error("expected instance {expected}, found instance {found}")]
InstanceMismatch { expected: u64, found: u64 },

#[error("invalid round: expected 0, got {0}")]
InvalidRound(u64),

#[error("diff {0} not sorted by participant ID")]
UnsortedDiff(usize),

#[error("diff {0} contains an empty delta for participant {1}")]
EmptyDelta(usize, ActorId),

#[error("diff {0} includes a new entry with a non-positive power delta for participant {1}")]
NonPositivePowerDeltaForNewEntry(usize, ActorId),

#[error("diff {0} delta for participant {1} includes an unchanged key")]
UnchangedKey(usize, ActorId),

#[error("diff {0} removes all power for participant {1} while specifying a new key")]
RemovesAllPowerWithNewKey(usize, ActorId),

#[error("diff {0} resulted in negative power for participant {1}")]
NegativePower(usize, ActorId),

#[error("invalid finality certificate at instance {0}: {1}")]
InvalidFinalityCertificate(u64, GPBFTError),

#[error("empty finality certificate for instance {0}")]
EmptyFinalityCertificate(u64),

#[error("base tipset does not match finalized chain at instance {0}")]
BaseTipsetMismatch(u64),

#[error("incorrect power diff from finality certificate for instance {instance}: expected {expected:?}, got {got:?}")]
IncorrectPowerDiff {
instance: u64,
expected: String,
got: String,
},

#[error("cbor encoding error")]
EncodingError(#[from] CborError),
}
Loading
Loading