Skip to content

Commit

Permalink
feat(staking): 💬 log when delegation changes are not found
Browse files Browse the repository at this point in the history
NB: this is different from logging the error that is propagated back
upwards. at this precise point, it where we will still be in the context
of the various spans that brought us to this point:

this allows to see information like:

```
  2024-03-13T16:47:37.801600Z  INFO penumbra_app::app: ending epoch, is_end_epoch: true, is_chain_upgrade: false, current_height: 718
    at crates/core/app/src/app/mod.rs:485
    in penumbra_app::app::end_block with height: 1
    in penumbra_mock_consensus::abci::end_block
    in penumbra_mock_consensus::block::execute with height: 718, time: 1710348457
    in penumbra_mock_consensus::fast_forward with blocks: 1000, height: 0, fast_forward.blocks: 1000
    in mock_consensus_staking::fast forwarding test node to next epoch

  2024-03-13T16:47:37.802068Z ERROR penumbra_stake::component::stake: could not find delegation changes for block
    at crates/core/component/stake/src/component/stake.rs:262
    in penumbra_stake::component::stake::get_delegation_changes with height: block::Height(2)
    in penumbra_stake::component::epoch_handler::end_epoch with index: 0
    in penumbra_stake::component::stake::staking
    in penumbra_app::app::end_block with height: 1
    in penumbra_mock_consensus::abci::end_block
    in penumbra_mock_consensus::block::execute with height: 718, time: 1710348457
    in penumbra_mock_consensus::fast_forward with blocks: 1000, height: 0, fast_forward.blocks: 1000
    in mock_consensus_staking::fast forwarding test node to next epoch
```
  • Loading branch information
cratelyn committed Mar 13, 2024
1 parent fe597ff commit fd4b8da
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/core/component/stake/src/component/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ use sha2::{Digest, Sha256};
use std::pin::Pin;
use std::str::FromStr;
use std::{collections::BTreeMap, sync::Arc};
use tap::Tap;
use tap::{Tap, TapFallible, TapOptional};
use tendermint::v0_37::abci;
use tendermint::validator::Update;
use tendermint::{block, PublicKey};
use tracing::{instrument, trace};
use tracing::{error, instrument, trace};

use crate::component::epoch_handler::EpochHandler;
use crate::component::validator_handler::{ValidatorDataRead, ValidatorManager};
Expand Down Expand Up @@ -257,7 +257,9 @@ pub trait StateReadExt: StateRead {
.get(&state_key::chain::delegation_changes::by_height(
height.value(),
))
.await?
.await
.tap_err(|err| error!(?err, "delegation changes for block exist but are invalid"))?
.tap_none(|| error!("could not find delegation changes for block"))
.ok_or_else(|| anyhow!("missing delegation changes for block {}", height))?)
}
}
Expand Down

0 comments on commit fd4b8da

Please sign in to comment.