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

Use fee rate estimation in block assembly #2859

Merged
merged 29 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c1042cc
feat: add estimate evaluation and nonce tracking to mempool iteration
kantai Sep 23, 2021
d5d94cf
chore: integrate into neon_node. requires Box<dyn ..>
kantai Sep 23, 2021
81a5afe
apply schema changes if necessary
kantai Sep 24, 2021
0472031
various fixes to the iteration
kantai Sep 24, 2021
077c97c
Merge branch 'feat/cost-estimator' into feat/miner-rate-eval
kantai Sep 27, 2021
2cb74b9
Merge remote-tracking branch 'origin/feat/cost-estimator' into feat/m…
kantai Sep 27, 2021
69f630c
fix mempool test
kantai Sep 27, 2021
efbcb47
Merge remote-tracking branch 'origin/feat/cost-estimator' into feat/m…
kantai Sep 28, 2021
896b9cc
fix mempool test
kantai Sep 28, 2021
bc1ef55
fix neon_integrations tests
kantai Sep 29, 2021
ade8353
refactor the configuration logic
kantai Sep 29, 2021
5366806
calculate estimate on mempool admission
kantai Oct 7, 2021
14dcd49
fix mempool integration test
kantai Oct 7, 2021
497851f
use Send bound on trait for http server tests
kantai Oct 7, 2021
b9531b7
enum renaming, add mempool db schema version
kantai Oct 7, 2021
b960b27
enable WAL mode in estimator DBs, add TestPeer testing for block asse…
kantai Oct 8, 2021
92dd070
update test, try using matrix for parallel testing
kantai Oct 8, 2021
c59290f
test: use job matrix execution for bitcoin integration tests
kantai Oct 8, 2021
a407985
chore: attempt to fix mining fairness test in GH action
kantai Oct 9, 2021
6b14999
fix metric returning zero while dimensions near zero, add test case
kantai Oct 9, 2021
58b0358
chore: update "mined anchored" log line to k-v + added total tx fee
kantai Oct 11, 2021
903fdda
address PR feedback
kantai Oct 15, 2021
cc3ba50
oops, tx_consider_no_estimate should return that the estimate must be…
kantai Oct 15, 2021
36deacb
test: fix ports in new test case, backport atlas test updates from ot…
kantai Oct 16, 2021
3a55306
remember `start_with_no_estimate` value if only updated nonces
kantai Oct 16, 2021
304247c
Merge branch 'develop' into feat/miner-rate-eval
kantai Oct 17, 2021
aa290e2
Merge branch 'develop' into feat/miner-rate-eval
kantai Oct 18, 2021
ee201e8
chore: update comment in gh action
kantai Oct 18, 2021
6005207
chore: add changelog entry, change config variable name
kantai Oct 19, 2021
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
37 changes: 4 additions & 33 deletions .github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
FROM rust:bullseye

WORKDIR /src/

COPY . .

WORKDIR /src/testnet/stacks-node
RUN cargo test --no-run

RUN cd / && wget https://bitcoin.org/bin/bitcoin-core-0.20.0/bitcoin-0.20.0-x86_64-linux-gnu.tar.gz
RUN cd / && tar -xvzf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz

RUN ln -s /bitcoin-0.20.0/bin/bitcoind /bin/
FROM stacks-node:integrations

ARG test_name
ENV BITCOIND_TEST 1
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::microblock_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::size_check_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::cost_voting_integration
RUN cargo test -- --test-threads 1 --ignored tests::integrations::integration_test_get_info
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::bitcoind_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::liquid_ustx_integration
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::stx_transfer_btc_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::bitcoind_forking_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::should_fix_2771
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::pox_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::bitcoin_regtest::bitcoind_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::should_succeed_handling_malformed_and_valid_txs
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::size_overflow_unconfirmed_microblocks_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::size_overflow_unconfirmed_stream_microblocks_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::size_overflow_unconfirmed_invalid_stream_microblocks_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::runtime_overflow_unconfirmed_microblocks_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::antientropy_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::filter_low_fee_tx_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::filter_long_runtime_tx_integration_test
RUN cargo test -- --test-threads 1 --ignored tests::neon_integrations::mining_transactions_is_fair

RUN cargo test -- --test-threads 1 --ignored "$test_name"

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM rust:bullseye

WORKDIR /src/

COPY . .

WORKDIR /src/testnet/stacks-node
RUN cargo test --no-run

RUN cd / && wget https://bitcoin.org/bin/bitcoin-core-0.20.0/bitcoin-0.20.0-x86_64-linux-gnu.tar.gz
RUN cd / && tar -xvzf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz

RUN ln -s /bitcoin-0.20.0/bin/bitcoind /bin/

ENV BITCOIND_TEST 1
50 changes: 49 additions & 1 deletion .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,63 @@ on:
pull_request:

jobs:
build-integration-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build bitcoin integration testing image
env:
DOCKER_BUILDKIT: 1
run: docker build -f ./.github/actions/bitcoin-int-tests/Dockerfile.generic.bitcoin-tests -t stacks-node:integrations .
- name: Export docker image as tarball
run: docker save -o integration-image.tar stacks-node:integrations
- name: Upload built docker image
uses: actions/upload-artifact@v2
with:
name: integration-image.tar
path: integration-image.tar
# Run sampled genesis tests
sampled-genesis:
runs-on: ubuntu-latest
needs:
- build-integration-image
strategy:
matrix:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
matrix:
fail-fast: false
matrix:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 903fdda

test-name:
- tests::neon_integrations::microblock_integration_test
- tests::neon_integrations::size_check_integration_test
- tests::neon_integrations::cost_voting_integration
- tests::integrations::integration_test_get_info
- tests::neon_integrations::bitcoind_integration_test
- tests::neon_integrations::liquid_ustx_integration
- tests::neon_integrations::stx_transfer_btc_integration_test
- tests::neon_integrations::bitcoind_forking_test
- tests::neon_integrations::should_fix_2771
- tests::neon_integrations::pox_integration_test
- tests::bitcoin_regtest::bitcoind_integration_test
- tests::should_succeed_handling_malformed_and_valid_txs
- tests::neon_integrations::size_overflow_unconfirmed_microblocks_integration_test
- tests::neon_integrations::size_overflow_unconfirmed_stream_microblocks_integration_test
- tests::neon_integrations::size_overflow_unconfirmed_invalid_stream_microblocks_integration_test
- tests::neon_integrations::runtime_overflow_unconfirmed_microblocks_integration_test
- tests::neon_integrations::antientropy_integration_test
- tests::neon_integrations::filter_low_fee_tx_integration_test
- tests::neon_integrations::filter_long_runtime_tx_integration_test
- tests::neon_integrations::mining_transactions_is_fair
steps:
- uses: actions/checkout@v2
- name: Download math result for job 1
uses: actions/download-artifact@v2
with:
name: integration-image.tar
- name: Load docker image
run: docker load -i integration-image.tar && rm integration-image.tar
- name: All integration tests with sampled genesis
timeout-minutes: 30
env:
DOCKER_BUILDKIT: 1
run: docker build -f ./.github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests .
TEST_NAME: ${{ matrix.test-name }}
run: docker build --build-arg test_name=${{ matrix.test-name }} -f ./.github/actions/bitcoin-int-tests/Dockerfile.bitcoin-tests .
atlas-test:
# disable this job/test for now, as the atlas endpoints are currently disabled.
if: ${{ true }}
Expand Down
18 changes: 9 additions & 9 deletions src/chainstate/coordinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ pub struct ChainsCoordinator<
T: BlockEventDispatcher,
N: CoordinatorNotices,
R: RewardSetProvider,
CE: CostEstimator,
FE: FeeEstimator,
CE: CostEstimator + ?Sized,
FE: FeeEstimator + ?Sized,
> {
canonical_sortition_tip: Option<SortitionId>,
canonical_chain_tip: Option<StacksBlockId>,
Expand All @@ -160,8 +160,8 @@ pub struct ChainsCoordinator<
burnchain: Burnchain,
attachments_tx: SyncSender<HashSet<AttachmentInstance>>,
dispatcher: Option<&'a T>,
cost_estimator: Option<CE>,
fee_estimator: Option<FE>,
cost_estimator: Option<&'a mut CE>,
fee_estimator: Option<&'a mut FE>,
reward_set_provider: R,
notifier: N,
atlas_config: AtlasConfig,
Expand Down Expand Up @@ -256,7 +256,7 @@ impl RewardSetProvider for OnChainRewardSetProvider {
}
}

impl<'a, T: BlockEventDispatcher, CE: CostEstimator, FE: FeeEstimator>
impl<'a, T: BlockEventDispatcher, CE: CostEstimator + ?Sized, FE: FeeEstimator + ?Sized>
ChainsCoordinator<'a, T, ArcCounterCoordinatorNotices, OnChainRewardSetProvider, CE, FE>
{
pub fn run(
Expand All @@ -266,8 +266,8 @@ impl<'a, T: BlockEventDispatcher, CE: CostEstimator, FE: FeeEstimator>
dispatcher: &'a mut T,
comms: CoordinatorReceivers,
atlas_config: AtlasConfig,
cost_estimator: Option<CE>,
fee_estimator: Option<FE>,
cost_estimator: Option<&mut CE>,
fee_estimator: Option<&mut FE>,
) where
T: BlockEventDispatcher,
{
Expand Down Expand Up @@ -517,8 +517,8 @@ impl<
T: BlockEventDispatcher,
N: CoordinatorNotices,
U: RewardSetProvider,
CE: CostEstimator,
FE: FeeEstimator,
CE: CostEstimator + ?Sized,
FE: FeeEstimator + ?Sized,
> ChainsCoordinator<'a, T, N, U, CE, FE>
{
pub fn handle_new_stacks_block(&mut self) -> Result<(), Error> {
Expand Down
5 changes: 4 additions & 1 deletion src/chainstate/stacks/db/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5545,6 +5545,8 @@ pub mod test {
use util::hash::*;
use util::retry::*;

use crate::cost_estimates::metrics::UnitMetric;
use crate::cost_estimates::UnitEstimator;
use crate::types::chainstate::{BlockHeaderHash, StacksWorkScore};

use super::*;
Expand Down Expand Up @@ -9166,7 +9168,8 @@ pub mod test {
}
};

let mut mempool = MemPoolDB::open(false, 0x80000000, &chainstate_path).unwrap();
let mut mempool =
MemPoolDB::open_test(false, 0x80000000, &chainstate_path).unwrap();
let coinbase_tx = make_coinbase(miner, tenure_id);

let anchored_block = StacksBlockBuilder::build_anchored_block(
Expand Down
18 changes: 9 additions & 9 deletions src/chainstate/stacks/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ impl FromRow<DBConfig> for DBConfig {

impl FromRow<StacksHeaderInfo> for StacksHeaderInfo {
fn from_row<'a>(row: &'a Row) -> Result<StacksHeaderInfo, db_error> {
let block_height = u64::from_column(row, "block_height")?;
let block_height: u64 = u64::from_column(row, "block_height")?;
let index_root = TrieHash::from_column(row, "index_root")?;
let consensus_hash = ConsensusHash::from_column(row, "consensus_hash")?;
let burn_header_hash = BurnchainHeaderHash::from_column(row, "burn_header_hash")?;
let burn_header_height = u64::from_column(row, "burn_header_height")? as u32;
let burn_header_height: u64 = u64::from_column(row, "burn_header_height")?;
let burn_header_timestamp = u64::from_column(row, "burn_header_timestamp")?;
let stacks_header = StacksBlockHeader::from_row(row)?;
let anchored_block_size_str: String = row.get_unwrap("block_size");
Expand All @@ -256,13 +256,13 @@ impl FromRow<StacksHeaderInfo> for StacksHeaderInfo {
Ok(StacksHeaderInfo {
anchored_header: stacks_header,
microblock_tail: None,
block_height: block_height,
index_root: index_root,
consensus_hash: consensus_hash,
burn_header_hash: burn_header_hash,
burn_header_height: burn_header_height,
burn_header_timestamp: burn_header_timestamp,
anchored_block_size: anchored_block_size,
block_height,
index_root,
consensus_hash,
burn_header_hash,
burn_header_height: burn_header_height as u32,
burn_header_timestamp,
anchored_block_size,
})
}
}
Expand Down
Loading