-
Notifications
You must be signed in to change notification settings - Fork 15
feat: proof of gossip #217
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
Open
camembera
wants to merge
25
commits into
main
Choose a base branch
from
feat/proof-of-gossip
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e832452
feat: add BerachainArgs with optional PoG flags
camembera 5521591
feat: add Proof of Gossip service
camembera 0b4f577
chore: add dependencies for Proof of Gossip
camembera d032bb2
feat: integrate Proof of Gossip service
camembera de1bf45
feat: PoG reputation scoring with configurable penalty
camembera a595748
style: cargo fmt
camembera cdaac8c
fix: use internal provider for PoG
camembera 3286ee9
fix: set sqlite journal mode via pragma_update
camembera 81f30a6
fix: gate PoG on sync and reconcile nonce
camembera 06e889f
fix: fail loud on nonce/base-fee lookup, add startup delay
camembera 91a8804
fix PoG canary fee cap and remove startup delay
camembera 44a6b1a
chore: revert fmt-only changes in non-PoG files
camembera f315976
feat: add pog telemetry metrics
camembera 968071f
fix: run pog with graceful shutdown
camembera cfcb7d0
fix: resolve clippy warnings in proof_of_gossip
camembera b3787aa
cargo fmt
camembera 612a7c6
refactor: address CodeRabbit review (PoG args, metrics, tests)
camembera 7b03a36
cargo fmt
camembera 733d99e
refactor: add PogError result type for PoG
camembera 0d15b69
fix: resolve clippy and advisory failures
camembera b1e335f
style: apply CI rustfmt output
camembera 5f53b4f
feat: use PoG private key file
camembera 00c9f34
fix: harden PoG nonce and penalty logic
camembera 6ca0435
style: fix args import ordering
camembera cb0d0fe
fix: preserve confirmed active canary state
camembera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| use clap::Args; | ||
| use std::path::PathBuf; | ||
|
|
||
| const DEFAULT_POG_TIMEOUT_SECS: u64 = 120; | ||
| const DEFAULT_POG_REPUTATION_PENALTY: i32 = -25600; | ||
|
|
||
| #[derive(Debug, Clone, Default, Args)] | ||
| #[command(next_help_heading = "Proof of Gossip")] | ||
| pub struct BerachainArgs { | ||
| #[arg(long = "pog.private-key-file")] | ||
| pub pog_private_key_file: Option<PathBuf>, | ||
|
|
||
| #[arg(long = "pog.timeout", default_value_t = DEFAULT_POG_TIMEOUT_SECS)] | ||
| pub pog_timeout: u64, | ||
|
|
||
| #[arg( | ||
| long = "pog.reputation-penalty", | ||
| default_value_t = DEFAULT_POG_REPUTATION_PENALTY, | ||
| allow_hyphen_values = true | ||
| )] | ||
| pub pog_reputation_penalty: i32, | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use clap::{Parser, error::ErrorKind}; | ||
| use std::path::PathBuf; | ||
|
|
||
| #[derive(Parser)] | ||
| struct TestCli { | ||
| #[command(flatten)] | ||
| args: BerachainArgs, | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_defaults() { | ||
| let cli = TestCli::parse_from(["test"]); | ||
| assert_eq!(cli.args.pog_private_key_file, None); | ||
| assert_eq!(cli.args.pog_timeout, DEFAULT_POG_TIMEOUT_SECS); | ||
| assert_eq!(cli.args.pog_reputation_penalty, DEFAULT_POG_REPUTATION_PENALTY); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_with_private_key_file() { | ||
| let key_file = "/tmp/pog.key"; | ||
| let cli = TestCli::parse_from(["test", "--pog.private-key-file", key_file]); | ||
| assert_eq!( | ||
| cli.args.pog_private_key_file.as_deref(), | ||
| Some(PathBuf::from(key_file).as_path()) | ||
| ); | ||
| assert_eq!(cli.args.pog_timeout, DEFAULT_POG_TIMEOUT_SECS); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_with_all_flags() { | ||
| let key_file = "/tmp/pog.key"; | ||
| let cli = TestCli::parse_from([ | ||
| "test", | ||
| "--pog.private-key-file", | ||
| key_file, | ||
| "--pog.timeout", | ||
| "300", | ||
| "--pog.reputation-penalty", | ||
| "-50000", | ||
| ]); | ||
| assert_eq!( | ||
| cli.args.pog_private_key_file.as_deref(), | ||
| Some(PathBuf::from(key_file).as_path()) | ||
| ); | ||
| assert_eq!(cli.args.pog_timeout, 300); | ||
| assert_eq!(cli.args.pog_reputation_penalty, -50000); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_with_explicit_reputation_penalty() { | ||
| let cli = TestCli::parse_from(["test", "--pog.reputation-penalty", "-10000"]); | ||
| assert_eq!(cli.args.pog_reputation_penalty, -10000); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_feature_off_when_flag_absent() { | ||
| let cli = TestCli::parse_from(["test", "--pog.timeout", "60"]); | ||
| assert_eq!(cli.args.pog_private_key_file, None); | ||
| assert_eq!(cli.args.pog_timeout, 60); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_rejects_old_private_key_flag() { | ||
| let key = format!("0x{:064x}", 1u64); | ||
| let parsed = TestCli::try_parse_from(["test", "--pog.private-key", &key]); | ||
| assert!(parsed.is_err()); | ||
| let err = parsed.err().expect("old flag should be rejected"); | ||
| assert_eq!(err.kind(), ErrorKind::UnknownArgument); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.