Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
TalDerei committed Nov 18, 2024
2 parents 9fffd7e + 63d1d33 commit f29bb47
Show file tree
Hide file tree
Showing 34 changed files with 1,881 additions and 1,217 deletions.
120 changes: 69 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

resolver = "2"

exclude = ["tools/proto-compiler", "tools/parameter-setup"]
exclude = ["tools/proto-compiler"]

# Also remember to add to deployments/scripts/rust-docs
members = [
Expand Down Expand Up @@ -55,6 +55,7 @@ members = [
"crates/view",
"crates/wallet",
"tools/summonerd",
"tools/parameter-setup",
]

# Config for 'cargo dist'
Expand Down Expand Up @@ -104,7 +105,7 @@ push = false
[workspace.package]
authors = ["Penumbra Labs <[email protected]"]
edition = "2021"
version = "0.80.7"
version = "0.80.8"
repository = "https://github.com/penumbra-zone/penumbra"
homepage = "https://penumbra.zone"
license = "MIT OR Apache-2.0"
Expand Down
1 change: 1 addition & 0 deletions crates/bin/pd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub enum RootCommand {
#[clap(long, display_order = 200)]
comet_home: Option<PathBuf>,
/// If set, force a migration to occur even if the chain is not halted.
/// Will not override a detected mismatch in state versions.
#[clap(long, display_order = 1000)]
force: bool,
/// If set, edit local state to permit the node to start, despite
Expand Down
2 changes: 2 additions & 0 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use pd::{
join::network_join,
},
};
use penumbra_app::app_version::assert_latest_app_version;
use penumbra_app::SUBSTORE_PREFIXES;
use rand::Rng;
use rand_core::OsRng;
Expand Down Expand Up @@ -102,6 +103,7 @@ async fn main() -> anyhow::Result<()> {
.context(
"Unable to initialize RocksDB storage - is there another `pd` process running?",
)?;
assert_latest_app_version(storage.clone()).await?;

tracing::info!(
?abci_bind,
Expand Down
11 changes: 11 additions & 0 deletions crates/bin/pd/src/migrate/mainnet1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ibc_types::core::channel::{Packet, PortId};
use ibc_types::transfer::acknowledgement::TokenTransferAcknowledgement;
use jmt::RootHash;
use penumbra_app::app::StateReadExt as _;
use penumbra_app::app_version::migrate_app_version;
use penumbra_governance::StateWriteExt;
use penumbra_ibc::{component::ChannelStateWriteExt as _, IbcRelay};
use penumbra_sct::component::clock::EpochManager;
Expand Down Expand Up @@ -111,6 +112,16 @@ pub async fn migrate(
let (migration_duration, post_upgrade_root_hash) = {
let start_time = std::time::SystemTime::now();

// Note, when this bit of code was added, the upgrade happened months ago,
// and the version safeguard mechanism was not in place. However,
// adding this will prevent someone running version 0.80.X with the
// safeguard patch from accidentally running the migraton again, since they
// will already have version 8 written into the state. But, if someone is syncing
// up from genesis, then version 0.79 will not have written anything into the safeguard,
// and this method will not complain. So, this addition provides a safeguard
// for existing nodes, while also not impeding syncing up a node from scratch.
migrate_app_version(&mut delta, 8).await?;

// Reinsert all of the erroneously removed packets
replace_lost_packets(&mut delta).await?;

Expand Down
49 changes: 26 additions & 23 deletions crates/bin/pindexer/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use cometindex::{async_trait, sqlx, AppView, ContextualizedEvent, PgTransaction};
use cometindex::{async_trait, index::EventBatch, sqlx, AppView, PgTransaction};
use penumbra_proto::{core::component::sct::v1 as pb, event::ProtoEvent};
use sqlx::{types::chrono::DateTime, PgPool};
use sqlx::types::chrono::DateTime;

#[derive(Debug)]
pub struct Block {}

#[async_trait]
impl AppView for Block {
fn name(&self) -> String {
"block".to_string()
}

async fn init_chain(
&self,
dbtx: &mut PgTransaction,
Expand All @@ -27,34 +31,33 @@ CREATE TABLE IF NOT EXISTS block_details (
Ok(())
}

fn is_relevant(&self, type_str: &str) -> bool {
type_str == "penumbra.core.component.sct.v1.EventBlockRoot"
}

async fn index_event(
async fn index_batch(
&self,
dbtx: &mut PgTransaction,
event: &ContextualizedEvent,
_src_db: &PgPool,
batch: EventBatch,
) -> Result<(), anyhow::Error> {
let pe = pb::EventBlockRoot::from_event(event.as_ref())?;
let timestamp = pe.timestamp.unwrap_or_default();
for event in batch.events() {
let pe = match pb::EventBlockRoot::from_event(event.as_ref()) {
Ok(pe) => pe,
Err(_) => continue,
};
let timestamp = pe.timestamp.unwrap_or_default();

sqlx::query(
"
sqlx::query(
"
INSERT INTO block_details (height, timestamp, root)
VALUES ($1, $2, $3)
",
)
.bind(i64::try_from(pe.height)?)
.bind(DateTime::from_timestamp(
timestamp.seconds,
u32::try_from(timestamp.nanos)?,
))
.bind(pe.root.unwrap().inner)
.execute(dbtx.as_mut())
.await?;

)
.bind(i64::try_from(pe.height)?)
.bind(DateTime::from_timestamp(
timestamp.seconds,
u32::try_from(timestamp.nanos)?,
))
.bind(pe.root.unwrap().inner)
.execute(dbtx.as_mut())
.await?;
}
Ok(())
}
}
Loading

0 comments on commit f29bb47

Please sign in to comment.