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

Track the most recently active validators and sample the superblock committee from them #2448

Open
wants to merge 32 commits into
base: 2.0-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bca4401
feat(data_structures): add basic staking tracker with tests
aesedepece Jun 13, 2023
adb1f05
feat(data_structures): adapt stakes tracker to latest specs
aesedepece Oct 16, 2023
22c6672
feat: add StakeTransaction (split commit)
Tommytrg Oct 9, 2023
fca76af
feat(data_structures): add transaction factories for `StakeTransaction`
aesedepece Oct 30, 2023
824166a
feat(data_structures): add support for `UnstakeTransaction`
Tommytrg Oct 20, 2023
10472e5
feat(data_structures): allow backwards-compatibility of key data stru…
aesedepece Nov 20, 2023
6009e9b
fix(tests): fix some tests that rely on block hashes
aesedepece Nov 21, 2023
25e1f10
fix(node): make session message decoding backwards-compatible
aesedepece Nov 21, 2023
188f462
feat(node): make 2.0 codebase able to sync to V1_6
aesedepece Nov 21, 2023
d307d68
chore(data_structures): commit missing module
aesedepece Nov 21, 2023
ced0133
feat(jsonrpc): implement method for staking
Tommytrg Nov 21, 2023
f5d85a1
feat(node): staking CLI client
Tommytrg Nov 23, 2023
33ab7fb
feat(node): perform further integration of staking methods
aesedepece Jan 4, 2024
a814e0c
fix(validations): fix mismatch in superblock validations
aesedepece Nov 27, 2023
49f6cda
tests: add missing superblock_period arg in validate_commit_transaction
Tommytrg Jan 10, 2024
9cf332b
refactor: fix clippy errors
Tommytrg Jan 10, 2024
f5a5b0b
feat(data_structures): implement protocol versions controller
aesedepece Jan 19, 2024
0618bd3
feat(data_structures): enable protocol versions injection through config
aesedepece Jan 25, 2024
35bc88a
feat(data_structures): enable multiple withdrawers for a single valid…
aesedepece Jan 26, 2024
30bf140
feat(node): make mining aware of protocol versions
aesedepece Feb 2, 2024
6da1773
feat(node): ask for confirmation when creating staking transactions
aesedepece Feb 2, 2024
f894632
feat(validations): make block signature validations aware of protocol…
aesedepece Feb 2, 2024
88f04ae
fix(validations): solve synchronization and bootstrapping issues
aesedepece Feb 5, 2024
7c749f8
fix(wallet): fix keypair decoding from storage
aesedepece Feb 9, 2024
c131f74
feat(data_structures): incorporate stakes tracker into ChainState
aesedepece Feb 15, 2024
4cc3a8c
feat(node): process stake transactions when consolidating blocks
aesedepece Feb 22, 2024
cf3885f
feat(node): complete stake transaction implementation
aesedepece Feb 26, 2024
e6c963e
feat(node): add stake transaction block weight checks
aesedepece Feb 26, 2024
2e84cff
feat(jsonrpc): implement query stakes method
Tommytrg Feb 29, 2024
ef7bf95
feat(CLI): implement method for querying stakes
Tommytrg Mar 6, 2024
4c5b368
feat(stakes): track the last epoch when a validator was active
drcpu-github Apr 14, 2024
f8bf45d
feat(superblock) sample superblock voters from a list of active valid…
drcpu-github Apr 15, 2024
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
112 changes: 98 additions & 14 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 @@ -35,6 +35,7 @@ lazy_static = "1.4.0"
log = "0.4.8"
num-format = "0.4.0"
prettytable-rs = { version = "0.10.0", default-features = false }
qrcode = "0.12"
sentry = { version = "0.29.3", features = ["log"], optional = true }
serde_json = "1.0.47"
structopt = "0.3.9"
Expand Down
71 changes: 66 additions & 5 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@
//! // Default config for mainnet
//! // Config::from_partial(&PartialConfig::default_mainnet());
//! ```
use std::convert::TryFrom;
use std::{
collections::HashSet, fmt, marker::PhantomData, net::SocketAddr, path::PathBuf, time::Duration,
array::IntoIter, collections::HashSet, convert::TryFrom, fmt, marker::PhantomData,
net::SocketAddr, path::PathBuf, time::Duration,
};

use partial_struct::PartialStruct;
use serde::{de, Deserialize, Deserializer, Serialize};

use partial_struct::PartialStruct;
use witnet_crypto::hash::HashFunction;
use witnet_data_structures::chain::{ConsensusConstants, Environment, PartialConsensusConstants};
use witnet_data_structures::witnessing::WitnessingConfig;
use witnet_data_structures::{
chain::{ConsensusConstants, Environment, Epoch, PartialConsensusConstants},
proto::versioning::ProtocolVersion,
witnessing::WitnessingConfig,
};
use witnet_protected::ProtectedString;

use crate::{
Expand Down Expand Up @@ -125,6 +129,11 @@ pub struct Config {
#[partial_struct(ty = "PartialWitnessing")]
#[partial_struct(serde(default))]
pub witnessing: Witnessing,

/// Configuration related with protocol versions
#[partial_struct(ty = "Protocol")]
#[partial_struct(serde(default))]
pub protocol: Protocol,
}

/// Log-specific configuration.
Expand Down Expand Up @@ -420,6 +429,25 @@ pub struct Tapi {
pub oppose_wip0027: bool,
}

/// Configuration related to protocol versions.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
pub struct Protocol {
pub v1_7: Option<Epoch>,
pub v1_8: Option<Epoch>,
pub v2_0: Option<Epoch>,
}

impl Protocol {
pub fn iter(&self) -> IntoIter<(ProtocolVersion, Option<Epoch>), 3> {
[
(ProtocolVersion::V1_7, self.v1_7),
(ProtocolVersion::V1_8, self.v1_8),
(ProtocolVersion::V2_0, self.v2_0),
]
.into_iter()
}
}

fn to_partial_consensus_constants(c: &ConsensusConstants) -> PartialConsensusConstants {
PartialConsensusConstants {
checkpoint_zero_timestamp: Some(c.checkpoint_zero_timestamp),
Expand Down Expand Up @@ -450,6 +478,13 @@ fn to_partial_consensus_constants(c: &ConsensusConstants) -> PartialConsensusCon
}
}

pub trait Partializable {
type Partial;

fn from_partial(config: &Self::Partial, defaults: &dyn Defaults) -> Self;
fn to_partial(&self) -> Self::Partial;
}

impl Config {
pub fn from_partial(config: &PartialConfig) -> Self {
let defaults: &dyn Defaults = match config.environment {
Expand Down Expand Up @@ -478,6 +513,7 @@ impl Config {
mempool: Mempool::from_partial(&config.mempool, defaults),
tapi: config.tapi.clone(),
witnessing: Witnessing::from_partial(&config.witnessing, defaults),
protocol: Protocol::from_partial(&config.protocol, defaults),
}
}

Expand All @@ -496,6 +532,7 @@ impl Config {
mempool: self.mempool.to_partial(),
tapi: self.tapi.clone(),
witnessing: self.witnessing.to_partial(),
protocol: self.protocol.to_partial(),
}
}
}
Expand Down Expand Up @@ -1171,6 +1208,30 @@ impl Witnessing {
}
}

impl Partializable for Protocol {
type Partial = Self;

fn from_partial(config: &Self::Partial, defaults: &dyn Defaults) -> Self {
let defaults = defaults.protocol_versions();

Protocol {
v1_7: config
.v1_7
.or(defaults.get(&ProtocolVersion::V1_7).copied()),
v1_8: config
.v1_8
.or(defaults.get(&ProtocolVersion::V1_8).copied()),
v2_0: config
.v2_0
.or(defaults.get(&ProtocolVersion::V2_0).copied()),
}
}

fn to_partial(&self) -> Self::Partial {
self.clone()
}
}

// Serialization helpers

fn as_log_filter_string<S>(
Expand Down
Loading
Loading