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/stackerdb messages #3551

Merged
merged 34 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a97bb79
feat: burnchain view now tracks the current reward cycle's consensus …
jcnelson Feb 4, 2023
7ad241b
feat: load the reward cycle consensus hash from the sortition DB as t…
jcnelson Feb 4, 2023
2faae13
feat: have peers report in the `services` field that they support the…
jcnelson Feb 4, 2023
53c729c
chore: add codecs for all of the stackerdb messages, as well as tests
jcnelson Feb 4, 2023
f3332fd
feat: add bandwidth tracking for stackerdb message pushes (to be fill…
jcnelson Feb 4, 2023
230d7d7
feat: stackerdb message structs
jcnelson Feb 4, 2023
5193ef8
chore: codec for [u8; 20]
jcnelson Feb 4, 2023
04b78ff
chore: API sync
jcnelson Feb 4, 2023
f9ef8e8
chore: stub files for stacker db implementation
jcnelson Feb 4, 2023
ba405ee
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 4, 2023
31d4db0
chore: API sync
jcnelson Feb 5, 2023
c2d3ebd
chore: documentation on the design of the stacker DB system
jcnelson Feb 6, 2023
38cac58
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 9, 2023
cc65dfe
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 9, 2023
5bc14db
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 15, 2023
a699afd
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 15, 2023
d0290f3
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 16, 2023
3a64b10
chore: rustdoc burnchain
jcnelson Feb 16, 2023
01f1e90
chore: rustdoc chat
jcnelson Feb 16, 2023
ab3b929
chore: use helpers to serialize/deserialize qualified contract identi…
jcnelson Feb 16, 2023
a91d37b
fix: use an extension trait for qualified contract identifiers, and a…
jcnelson Feb 16, 2023
548ed95
chore: comment where handshake handling happens
jcnelson Feb 16, 2023
890ffc6
Merge branch 'feat/stackerdb-messages' of https://github.com/stacks-n…
jcnelson Feb 16, 2023
18ee6c8
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Feb 17, 2023
7ad9ec1
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Mar 2, 2023
3a37647
Merge branch 'develop' into feat/stackerdb-messages
igorsyl Mar 7, 2023
01c25ac
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Jul 10, 2023
360906a
Update src/net/stackerdb/mod.rs
jcnelson Jul 20, 2023
21cf846
Update src/net/stackerdb/mod.rs
jcnelson Jul 20, 2023
9a34a0e
Update src/net/stackerdb/mod.rs
jcnelson Jul 20, 2023
b6bc8af
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Jul 20, 2023
f7b376d
chore: add more test coverage to chat.rs
jcnelson Jul 24, 2023
adf0180
chore: add changelog entry
jcnelson Jul 29, 2023
5c84ee1
Merge branch 'develop' into feat/stackerdb-messages
jcnelson Jul 29, 2023
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
17 changes: 12 additions & 5 deletions src/burnchains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,18 @@ impl PoxConstants {
/// Structure for encoding our view of the network
#[derive(Debug, PartialEq, Clone)]
pub struct BurnchainView {
pub burn_block_height: u64, // last-seen block height (at chain tip)
pub burn_block_hash: BurnchainHeaderHash, // last-seen burn block hash
pub burn_stable_block_height: u64, // latest stable block height (e.g. chain tip minus 7)
pub burn_stable_block_hash: BurnchainHeaderHash, // latest stable burn block hash
pub last_burn_block_hashes: HashMap<u64, BurnchainHeaderHash>, // map all block heights from burn_block_height back to the oldest one we'll take for considering the peer a neighbor
/// last-seen block height (at chain tip)
pub burn_block_height: u64,
/// last-seen burn block hash
pub burn_block_hash: BurnchainHeaderHash,
/// latest stable block height (e.g. chain tip minus 7)
pub burn_stable_block_height: u64,
/// latest stable burn block hash
pub burn_stable_block_hash: BurnchainHeaderHash,
/// map all block heights from burn_block_height back to the oldest one we'll take for considering the peer a neighbor
pub last_burn_block_hashes: HashMap<u64, BurnchainHeaderHash>,
/// consensus hash of the current reward cycle's start block
pub rc_consensus_hash: ConsensusHash,
}

/// The burnchain block's encoded state transition:
Expand Down
21 changes: 18 additions & 3 deletions src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3823,7 +3823,7 @@ impl SortitionDB {
/// Get a burn blockchain snapshot, given a burnchain configuration struct.
/// Used mainly by the network code to determine what the chain tip currently looks like.
pub fn get_burnchain_view(
conn: &DBConn,
conn: &SortitionDBConn,
burnchain: &Burnchain,
chain_tip: &BlockSnapshot,
) -> Result<BurnchainView, db_error> {
Expand Down Expand Up @@ -3895,19 +3895,34 @@ impl SortitionDB {
.unwrap_or(&burnchain.first_block_hash)
.clone();

let rc = burnchain
.block_height_to_reward_cycle(chain_tip.block_height)
.expect("FATAL: block height does not have a reward cycle");

let rc_height = burnchain.reward_cycle_to_block_height(rc);
let rc_consensus_hash = SortitionDB::get_ancestor_snapshot(
conn,
cmp::min(chain_tip.block_height, rc_height),
&chain_tip.sortition_id,
)?
.map(|sn| sn.consensus_hash)
.ok_or(db_error::NotFoundError)?;

test_debug!(
"Chain view: {},{}-{},{}",
"Chain view: {},{}-{},{},{}",
chain_tip.block_height,
chain_tip.burn_header_hash,
stable_block_height,
&burn_stable_block_hash
&burn_stable_block_hash,
&rc_consensus_hash,
);
Ok(BurnchainView {
burn_block_height: chain_tip.block_height,
burn_block_hash: chain_tip.burn_header_hash,
burn_stable_block_height: stable_block_height,
burn_stable_block_hash: burn_stable_block_hash,
last_burn_block_hashes: last_burn_block_hashes,
rc_consensus_hash,
})
}
}
Expand Down
Loading