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/check pox 2 params #3409

Merged
merged 66 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
18b8381
change the testnet height
Nov 11, 2022
1ec1c76
change hash
Nov 11, 2022
f23efbc
update timestamp
deantchi Nov 12, 2022
c5b239c
set new block heights for testing
deantchi Nov 16, 2022
7312eba
need to increase the 2.05 epoch
deantchi Nov 16, 2022
775812f
fix: stop segfault in reqwest by using rustls-tls
jcnelson Nov 18, 2022
a51a6f1
refactor: move epoch validation logic into StacksEpoch
jcnelson Nov 18, 2022
a10efec
refactor: move validate_epochs() into StacksEpoch
jcnelson Nov 18, 2022
89e523f
chore: move STACKS_EPOCH_MAX into stacks-common
jcnelson Nov 18, 2022
becc83c
feat: new method find_epoch_by_id() for a list of epochs
jcnelson Nov 18, 2022
4ffedc3
fix: require rustls-tls to avoid reqwest segfault
jcnelson Nov 18, 2022
4ddbdbc
refactor: remove update_pox_constants
jcnelson Nov 18, 2022
d063359
feat: new method to verify that epoch 2.1 settings are correct
jcnelson Nov 18, 2022
c348161
chore: remove unused import
jcnelson Nov 18, 2022
54260be
feat: validate epoch 2.1 settings early
jcnelson Nov 18, 2022
7a8abc6
feat: validate epoch 2.1 settings early
jcnelson Nov 18, 2022
9b0a5bf
fix: add an epoch 2.1 block limit
jcnelson Nov 20, 2022
99639a2
chore: debug epochs to validate
jcnelson Nov 20, 2022
f7f41a9
fix: use epoch 2.1 in block-limit test
jcnelson Nov 20, 2022
d69eb3e
fix: use epoch 2.1 by default in integration tests
jcnelson Nov 20, 2022
8de7075
fix: use epoch 2.1 in integration tests
jcnelson Nov 20, 2022
ded5602
fix: since the test begins in epoch 2.1, there are no lockup events
jcnelson Nov 20, 2022
cb43218
fix: neon_integration tests largely run in epoch 2.05, so make it so.…
jcnelson Nov 21, 2022
ecd6f2d
Merge branch 'draft/set-testnet-height' into feat/check-pox-2-params
jcnelson Nov 21, 2022
e2f6d6a
Merge branch 'next' into feat/check-pox-2-params
jcnelson Nov 21, 2022
2cca4fe
fix: bump network epoch version for mainnet and testnet
jcnelson Nov 21, 2022
920542f
fix: use burnchain constructor in config, and append wallet path for …
jcnelson Nov 21, 2022
377f463
fix: use burnchain constructor in config
jcnelson Nov 21, 2022
98c42e4
fix: make PoX sunset configurable, as well as the wallet name, and ad…
jcnelson Nov 21, 2022
5fbc6ac
fix: uew new burnchain constructor
jcnelson Nov 21, 2022
d6a45c9
fix: new runtime limit
jcnelson Nov 21, 2022
efbdb1c
Merge branch 'feat/check-pox-2-params' of https://github.com/stacks-n…
jcnelson Nov 21, 2022
1bb3a55
fix: increase highest supported epochs in earlier epochs (since we ha…
jcnelson Nov 21, 2022
2c966bd
chore: log unaffirmed anchor block hash and txid
jcnelson Nov 22, 2022
c03d2ec
fix: use 2.1 peer version
jcnelson Nov 22, 2022
9475b99
fix: revert new runtime
jcnelson Nov 22, 2022
8c2931d
Merge branch 'next' into feat/check-pox-2-params
jcnelson Nov 22, 2022
f5a43fb
fix: antientropy up to and including the current reward cycle
jcnelson Nov 23, 2022
49adb3e
fix: antientropy should include the current reward cycle
jcnelson Nov 23, 2022
d338bed
fix: restore original epochs used for testing pre-2.1
jcnelson Nov 23, 2022
f2f0e72
fix: use the original epochs that caused these tests to pass
jcnelson Nov 23, 2022
fa3cb94
fix: runtime
jcnelson Nov 23, 2022
b89e7de
fix: use epoch 2.1 data to satisfy the new config checker
jcnelson Nov 23, 2022
ca11f82
fix: debug! instead of info! for a commonly-emitted line
jcnelson Nov 28, 2022
8343390
fix: fix #34233 by checking for an already-locked error in the specia…
jcnelson Nov 29, 2022
ab7ca1e
feat: has_burnchain_block_at_height() for helping skip needless sorti…
jcnelson Dec 2, 2022
8ab4273
fix: the genesis block always had version 0
jcnelson Dec 2, 2022
9c7aa3c
chore: unused import
jcnelson Dec 2, 2022
3947d3c
chore: remove dispatch_boot_receipts() from block event dispatcher, a…
jcnelson Dec 2, 2022
8be2bee
chore: remove dispatch_boot_receipts, and add fault injection for hid…
jcnelson Dec 2, 2022
782d0dd
chore: remove boot_receipts as anything special that we need to store…
jcnelson Dec 2, 2022
a035f3c
chore: fault injection for missing blocks
jcnelson Dec 2, 2022
a72b6ee
fix: directly push boot receipts as soon as we have them
jcnelson Dec 2, 2022
ee94779
chore: method for pushing boot receipts
jcnelson Dec 2, 2022
ea32a36
refactor: separate chainstate instantiation and receipt propagation f…
jcnelson Dec 2, 2022
5188d46
feat: new test push_boot_receipts
jcnelson Dec 2, 2022
ecb418e
feat: run new test in CI
jcnelson Dec 2, 2022
7fd4e52
fix: remove unneeded trait impls to fix compile errors
jcnelson Dec 3, 2022
a86930a
fix: off-by-one errors now that the genesis block is a separate mined…
jcnelson Dec 3, 2022
9fb668c
refactor: consolidate hidden block fault injection
jcnelson Dec 4, 2022
361b3bd
chore: consolidate hidden block fault injection
jcnelson Dec 4, 2022
bc59858
fix: don't clobber another test's disk state
jcnelson Dec 5, 2022
cda834d
Merge branch 'next' into feat/check-pox-2-params
jcnelson Dec 6, 2022
cce95e7
fix: report both pox2 and costs3 tx receipts
jcnelson Dec 6, 2022
b16e121
Merge branch 'feat/check-pox-2-params' of https://github.com/stacks-n…
jcnelson Dec 6, 2022
b2d886a
Merge branch 'next' into feat/check-pox-2-params
jcnelson Dec 12, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
- tests::neon_integrations::test_problematic_blocks_are_not_relayed_or_stored
- tests::neon_integrations::test_problematic_microblocks_are_not_mined
- tests::neon_integrations::test_problematic_microblocks_are_not_relayed_or_stored
- tests::neon_integrations::push_boot_receipts
- tests::epoch_205::test_dynamic_db_method_costs
- tests::epoch_205::transition_empty_blocks
- tests::epoch_205::test_cost_limit_switch_version205
Expand Down
161 changes: 33 additions & 128 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 clarity/src/vm/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub enum RuntimeErrorType {
BadBlockHash(Vec<u8>),
UnwrapFailure,
DefunctPoxContract,
PoxAlreadyLocked,
}

#[derive(Debug, PartialEq)]
Expand Down
22 changes: 20 additions & 2 deletions src/burnchains/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,16 @@ impl BurnchainDB {
opt.ok_or(BurnchainError::MissingParentBlock)
}

pub fn has_burnchain_block_at_height(
conn: &DBConn,
height: u64,
) -> Result<bool, BurnchainError> {
let qry = "SELECT 1 FROM burnchain_db_block_headers WHERE block_height = ?1";
let args = &[&u64_to_sql(height)?];
let res: Option<i64> = query_row(conn, qry, args)?;
Ok(res.is_some())
}

pub fn get_burnchain_block(
conn: &DBConn,
block: &BurnchainHeaderHash,
Expand Down Expand Up @@ -1524,12 +1534,20 @@ impl BurnchainDB {
);
for rc in start_rc..last_reward_cycle {
if let Some((commit, metadata)) = BurnchainDB::get_anchor_block_commit(conn, rc)? {
let bhh = commit.block_header_hash.clone();
let txid = metadata.txid.clone();
let present = unconfirmed_oracle(commit, metadata);
if present {
debug!("Assume present anchor block at reward cycle {}", rc);
debug!(
"Assume present anchor block {} txid {} at reward cycle {}",
&bhh, &txid, rc
);
heaviest_am.push(AffirmationMapEntry::PoxAnchorBlockPresent);
} else {
debug!("Assume absent anchor block at reward cycle {}", rc);
debug!(
"Assume absent anchor block {} txid {} at reward cycle {}",
&bhh, &txid, rc
);
heaviest_am.push(AffirmationMapEntry::PoxAnchorBlockAbsent);
}
} else {
Expand Down
46 changes: 5 additions & 41 deletions src/chainstate/burn/db/sortdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use crate::chainstate::ChainstateDB;
use crate::core::AST_RULES_PRECHECK_SIZE;
use crate::core::FIRST_BURNCHAIN_CONSENSUS_HASH;
use crate::core::FIRST_STACKS_BLOCK_HASH;
use crate::core::{StacksEpoch, StacksEpochId, STACKS_EPOCH_MAX};
use crate::core::{StacksEpoch, StacksEpochExtension, StacksEpochId, STACKS_EPOCH_MAX};
use crate::net::neighbors::MAX_NEIGHBOR_BLOCK_DELAY;
use crate::net::{Error as NetError, Error};
use crate::util_lib::db::tx_begin_immediate;
Expand Down Expand Up @@ -2555,44 +2555,6 @@ impl SortitionDB {
Ok(db)
}

/// Validate all Stacks Epochs. Since this is data that always comes from a static variable,
/// any invalid StacksEpoch structuring should result in a runtime panic.
fn validate_epochs(epochs_ref: &[StacksEpoch]) -> Vec<StacksEpoch> {
// sanity check -- epochs must all be contiguous, each epoch must be unique,
// and the range of epochs should span the whole non-negative i64 space.
let mut epochs = epochs_ref.to_vec();
let mut seen_epochs = HashSet::new();
epochs.sort();

let mut epoch_end_height = 0;
for epoch in epochs.iter() {
assert!(
epoch.start_height <= epoch.end_height,
"{} > {} for {:?}",
epoch.start_height,
epoch.end_height,
&epoch.epoch_id
);

if epoch_end_height == 0 {
// first ever epoch must be defined for all of the prior chain history
assert_eq!(epoch.start_height, 0);
epoch_end_height = epoch.end_height;
} else {
assert_eq!(epoch_end_height, epoch.start_height);
epoch_end_height = epoch.end_height;
}
if seen_epochs.contains(&epoch.epoch_id) {
panic!("BUG: duplicate epoch");
}

seen_epochs.insert(epoch.epoch_id);
}

assert_eq!(epoch_end_height, STACKS_EPOCH_MAX);
epochs
}

fn instantiate(
&mut self,
first_block_height: u64,
Expand Down Expand Up @@ -2657,7 +2619,7 @@ impl SortitionDB {
db_tx: &Transaction,
epochs: &[StacksEpoch],
) -> Result<(), db_error> {
let epochs = SortitionDB::validate_epochs(epochs);
let epochs = StacksEpoch::validate_epochs(epochs);
for epoch in epochs.into_iter() {
let args: &[&dyn ToSql] = &[
&(epoch.epoch_id as u32),
Expand Down Expand Up @@ -2815,7 +2777,9 @@ impl SortitionDB {
pub fn is_db_version_supported_in_epoch(epoch: StacksEpochId, version: &str) -> bool {
match epoch {
StacksEpochId::Epoch10 => true,
StacksEpochId::Epoch20 => version == "1" || version == "2" || version == "3",
StacksEpochId::Epoch20 => {
version == "1" || version == "2" || version == "3" || version == "4"
}
StacksEpochId::Epoch2_05 => version == "2" || version == "3" || version == "4",
StacksEpochId::Epoch21 => version == "3" || version == "4",
}
Expand Down
Loading