-
Notifications
You must be signed in to change notification settings - Fork 292
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
tests: 🏃 mock consensus can exercise staking component #4001
tests: 🏃 mock consensus can exercise staking component #4001
Conversation
f66d974
to
cb15f6d
Compare
cb15f6d
to
1a1e3cf
Compare
cherry-picked logging additions out into #4009. |
1a1e3cf
to
e25db4c
Compare
fixes a few comments in `App::end_block`. cherry-picked from #4001.
`Consensus::end_block` never returns an `Err(_)` value, so it does not need to return a `Result<T, E>`. cherry-picked out ouf #4001.
e25db4c
to
bb90f30
Compare
bb90f30
to
c601f21
Compare
6bf52ba
to
cd5950d
Compare
this is a group of improvements to the telemetry in the staking component, cherry-picked out of #4001. this improves the logs seen in tests, and additionally takes the time to make some other small gardening tweaks: consolidating imports, adding documentation comments, etc. this is another branch in the spirit of #4009. the changes here are itemized into distinct, small code transformations to facilitate review, and demonstrate that these are noop changes. you can start [here](f7f78b9). * f331964 - feat(staking): ❗ traces for invalid or missing parameters * d33598d - docs(staking): 🤝 add a doc comment * f6c60a8 - staking: 🙂 remove needless `Ok(_)` * fd4b8da - feat(staking): 💬 log when delegation changes are not found * fe597ff - feat(staking): 🔍 trace-level spans for `StateReadExt` methods * 0447600 - refactor(staking): 🚡 use `self::` prefix in reexports * 67893c9 - refactor(staking): 🙂 remove import from reexports * 043222e - refactor(staking): 🎁 consolidate public submodules * 6376796 - refactor(staking): 🎁 consolidate submodules * b5bd240 - refactor(staking): 👯 component flag reexports StateWriteExt * d57beaa - chore(staking): 🥡 consolidate component reexports * aa52f6d - chore(staking): 🧹 tidy epoch_handler imports * 765ed75 - refactor(compact-block): 🧹 tidy imports * 7cb93f7 - feat(staking): 🌐 log why epoch ended * 081d041 - refactor(staking): add context to `state.end_epoch` call * 5701295 - feat(app): 🦠 tracing telemetry for `App::end_block` * f7f78b9 - docs(staking): 📕 add doc comment for `end_epoch`
cd5950d
to
bd087ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let (new_validator_pb, _, new_validator_spend_key) = | ||
self::common::generate_penumbra_validator(&new_validator_vk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want to be using a common helper method to define the new validator we're adding. It should be possible to reason about the semantics of the test function just from reading its code, but if we reuse an internal helper method of the auto_app_state implementation, we're coupling the semantics of the test to the implementation of some other part of the test harness. This is actively undesirable.
definitely. i agree. it was a mistake to reuse that helper function here. i have cherry-picked ceb5d62 into this branch.
previously, we added a `Keyring` newtype. this was a low-effort, thin newtype wrapper around a `BTreeMap<VerificationKey, SigningKey>`. this commit removes it. NB: this is based on #4001.
previously, we added a `Keyring` newtype. this was a low-effort, thin newtype wrapper around a `BTreeMap<VerificationKey, SigningKey>`. this commit removes it. NB: this is based on #4001.
previously, we added a `Keyring` newtype. this was a low-effort, thin newtype wrapper around a `BTreeMap<VerificationKey, SigningKey>`. this commit removes it. NB: this is based on #4001.
opened #4039 to remove the |
// TODO: upstream a direct conversion from ed25519_consensus | ||
consensus_key: tendermint::PublicKey::from_raw_ed25519(&new_validator_consensus.to_bytes()) | ||
.expect("consensus key is valid"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filed informalsystems/tendermint-rs#1401 to address this TODO
🙂
### 🚠 overview in #4001 we added a test for the staking component (_see also #3995, and #3588_). this shortens the epoch length, so that this test runs in less time, and importantly, so that debugging test failures does not entail sifting through many log lines. ### ➕ changes * manually construct an `AppState` so that we use a shorter epoch. this test involves waiting for multiple epochs to pass, which takes many seconds with the default length of 719, see: <https://github.com/penumbra-zone/penumbra/blob/8be8e8266b312c2a9eb1b1522a937e8df12f3a4f/crates/core/component/sct/src/params.rs#L41> * `TestNode<C>::fast_forward` now accepts a u64, mirroring the type used in the sct parameters. ### 🏃 runtime on `main`... ``` Starting 1 test across 1 binary PASS [ 12.646s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 12.647s] 1 test run: 1 passed, 0 skipped ``` after these changes... ``` Starting 1 test across 1 binary PASS [ 0.420s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 0.420s] 1 test run: 1 passed, 0 skipped ``` ### 🥙 log volume on `main`... ``` ; RUST_LOG='info' cargo nextest run -p penumbra-app --test mock_consensus_staking --no-capture | wc -l Finished test [unoptimized + debuginfo] target(s) in 0.16s Starting 1 test across 1 binary START penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator PASS [ 12.185s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 12.185s] 1 test run: 1 passed, 0 skipped 46082 ``` ``` ; RUST_LOG='info' cargo nextest run -p penumbra-app --test mock_consensus_staking --no-capture | wc -l Finished test [unoptimized + debuginfo] target(s) in 0.15s Starting 1 test across 1 binary START penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator PASS [ 0.416s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 0.416s] 1 test run: 1 passed, 0 skipped 450 ```
### 🚠 overview in #4001 we added a test for the staking component (_see also #3995, and #3588_). this shortens the epoch length, so that this test runs in less time, and importantly, so that debugging test failures does not entail sifting through many log lines. ### ➕ changes * manually construct an `AppState` so that we use a shorter epoch. this test involves waiting for multiple epochs to pass, which takes many seconds with the default length of 719, see: <https://github.com/penumbra-zone/penumbra/blob/8be8e8266b312c2a9eb1b1522a937e8df12f3a4f/crates/core/component/sct/src/params.rs#L41> * `TestNode<C>::fast_forward` now accepts a u64, mirroring the type used in the sct parameters. ### 🏃 runtime on `main`... ``` Starting 1 test across 1 binary PASS [ 12.646s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 12.647s] 1 test run: 1 passed, 0 skipped ``` after these changes... ``` Starting 1 test across 1 binary PASS [ 0.420s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 0.420s] 1 test run: 1 passed, 0 skipped ``` ### 🥙 log volume on `main`... ``` ; RUST_LOG='info' cargo nextest run -p penumbra-app --test mock_consensus_staking --no-capture | wc -l Finished test [unoptimized + debuginfo] target(s) in 0.16s Starting 1 test across 1 binary START penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator PASS [ 12.185s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 12.185s] 1 test run: 1 passed, 0 skipped 46082 ``` ``` ; RUST_LOG='info' cargo nextest run -p penumbra-app --test mock_consensus_staking --no-capture | wc -l Finished test [unoptimized + debuginfo] target(s) in 0.15s Starting 1 test across 1 binary START penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator PASS [ 0.416s] penumbra-app::mock_consensus_staking mock_consensus_can_define_and_delegate_to_a_validator ------------ Summary [ 0.416s] 1 test run: 1 passed, 0 skipped 450 ```
fixes #3966. fixes #3908. fixes part of #3995.
this branch introduces the first steps towards mock consensus (#3588) testing of the staking component (#3845).
this defines a validator after genesis, and then shows that it does not enter the consensus set. #3966 is addressed in this branch so that the existing genesis validator correctly enters the consensus set, and so that we can successfully progress to the second epoch.
subsequent changes will exercise delegating to this validator in the
mock_consensus_can_define_and_delegate_to_a_validator
.✨ changes
alters
with_penumbra_auto_app_state
so that it adds an allocation of delegation tokens to the shielded pool component's genesis content.extends
generate_penumbra_validator
so that it generates a real spend key, and returns anAllocation
for the generated validator. (see mock-consensus: 🪙auto_app_state
assigns delegation tokens #3966)adds a new
mock_consensus_can_define_and_delegate_to_a_validator
test that defines a post-genesis validator. (see tests: 🐦 mock consensus supports post-genesis validators #3908)defines a new
ConsensusIndexRead::get_consensus_set()
method, which collects all of the identity keys returned byconsensus_set_stream
.lowers the events in
penumbra_mock_consensus::block::Builder::execute()
to trace-level events.penumbra_mock_consensus::builder::Builder
will now log a warning if values may be errantly rewritten by the builder methods.TestNode::fast_forward
sets itsi
span field to1..n
, rather than0..n-1
.🔗 related
Consensus::end_block
never errors #4011Amount
isFrom<u8>
andFrom<u16>
#4027auto_app_state
assigns delegation tokens #3966App
tests #3588