adds crds-value for broadcasting duplicate shreds through gossip (#14133)

In gossip, the header overhead we get from:
https://github.com/solana-labs/solana/blob/de9ac43eb/core/src/cluster_info.rs#L434-L435
https://github.com/solana-labs/solana/blob/de9ac43eb/core/src/crds_value.rs#L31-L36
https://github.com/solana-labs/solana/blob/de9ac43eb/core/src/crds_value.rs#L73
already exceeds SIZE_OF_NONCE in shreds. We also need aditional
meta-data (wallclock, source pubkey, ...). Which means that given the
SHRED_PAYLOAD_SIZE, we cannot fit all these in PACKET_DATA_SIZE:
https://github.com/solana-labs/solana/blob/de9ac43eb/ledger/src/shred.rs#L80

On top of that, we need 2 shred payloads as the proof of duplicate. So
each DuplicateShred crds value includes only a chunk of the payload,
along with the meta-data to reconstruct the full payload from the chunks
on the receiving end.
This commit is contained in:
behzad nouri
2020-12-18 14:32:43 +00:00
committed by GitHub
parent 3c9b853268
commit 6a3797e164
11 changed files with 445 additions and 26 deletions

View File

@@ -33,6 +33,8 @@ serde = "1.0.112"
serde_bytes = "0.11.4"
sha2 = "0.8.2"
solana-bpf-loader-program = { path = "../programs/bpf_loader", version = "1.6.0" }
solana-frozen-abi = { path = "../frozen-abi", version = "1.6.0" }
solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "1.6.0" }
solana-transaction-status = { path = "../transaction-status", version = "1.6.0" }
solana-logger = { path = "../logger", version = "1.6.0" }
solana-measure = { path = "../measure", version = "1.6.0" }
@@ -63,6 +65,9 @@ assert_matches = "1.3.0"
matches = "0.1.6"
solana-budget-program = { path = "../programs/budget", version = "1.6.0" }
[build-dependencies]
rustc_version = "0.2"
[lib]
crate-type = ["lib"]
name = "solana_ledger"

27
ledger/build.rs Normal file
View File

@@ -0,0 +1,27 @@
extern crate rustc_version;
use rustc_version::{version_meta, Channel};
fn main() {
// Copied and adapted from
// https://github.com/Kimundi/rustc-version-rs/blob/1d692a965f4e48a8cb72e82cda953107c0d22f47/README.md#example
// Licensed under Apache-2.0 + MIT
match version_meta().unwrap().channel {
Channel::Stable => {
println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION");
}
Channel::Beta => {
println!("cargo:rustc-cfg=RUSTC_WITHOUT_SPECIALIZATION");
}
Channel::Nightly => {
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
}
Channel::Dev => {
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
// See https://github.com/solana-labs/solana/issues/11055
// We may be running the custom `rust-bpf-builder` toolchain,
// which currently needs `#![feature(proc_macro_hygiene)]` to
// be applied.
println!("cargo:rustc-cfg=RUSTC_NEEDS_PROC_MACRO_HYGIENE");
}
}
}

View File

@@ -1,3 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#[macro_use]
extern crate solana_bpf_loader_program;
@@ -32,3 +33,6 @@ extern crate log;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate solana_frozen_abi_macro;

View File

@@ -119,7 +119,7 @@ pub enum ShredError {
pub type Result<T> = std::result::Result<T, ShredError>;
#[derive(Serialize, Clone, Deserialize, PartialEq, Debug)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, AbiExample, Deserialize, Serialize)]
pub struct ShredType(pub u8);
impl Default for ShredType {
fn default() -> Self {