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

sct: add ABCI events for SCT roots #3454

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 8 additions & 5 deletions crates/core/component/sct/src/component/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tct::builder::{block, epoch};

// TODO: make epoch management the responsibility of this component

use crate::state_key;
use crate::{event, state_key};

/// This trait provides read access to common parts of the Penumbra
/// state store.
Expand Down Expand Up @@ -149,22 +149,25 @@ trait StateWriteExt: StateWrite {
fn set_sct_anchor(&mut self, height: u64, sct_anchor: tct::Root) {
tracing::debug!(?height, ?sct_anchor, "writing anchor");

self.record(event::sct_anchor(height, &sct_anchor));
self.put(state_key::anchor_by_height(height), sct_anchor);
self.put_proto(state_key::anchor_lookup(sct_anchor), height);
}

fn set_sct_block_anchor(&mut self, height: u64, sct_block_anchor: block::Root) {
tracing::debug!(?height, ?sct_block_anchor, "writing block anchor");

self.record(event::sct_block_anchor(height, &sct_block_anchor));
self.put(state_key::block_anchor_by_height(height), sct_block_anchor);
self.put_proto(state_key::block_anchor_lookup(sct_block_anchor), height);
}

fn set_sct_epoch_anchor(&mut self, index: u64, sct_block_anchor: epoch::Root) {
tracing::debug!(?index, ?sct_block_anchor, "writing epoch anchor");
fn set_sct_epoch_anchor(&mut self, index: u64, sct_epoch_anchor: epoch::Root) {
tracing::debug!(?index, ?sct_epoch_anchor, "writing epoch anchor");

self.put(state_key::epoch_anchor_by_index(index), sct_block_anchor);
self.put_proto(state_key::epoch_anchor_lookup(sct_block_anchor), index);
self.record(event::sct_epoch_anchor(index, &sct_epoch_anchor));
self.put(state_key::epoch_anchor_by_index(index), sct_epoch_anchor);
self.put_proto(state_key::epoch_anchor_lookup(sct_epoch_anchor), index);
}

async fn write_sct(
Expand Down
32 changes: 32 additions & 0 deletions crates/core/component/sct/src/event.rs
Original file line number Diff line number Diff line change
@@ -1 +1,33 @@
use penumbra_tct as tct;
use tct::builder::{block, epoch};
use tendermint::abci::{Event, EventAttributeIndexExt};

pub fn sct_anchor(height: u64, anchor: &tct::Root) -> Event {
Event::new(
"sct_anchor",
[
("height", height.to_string()).index(),
("anchor", anchor.to_string()).index(),
],
)
}

pub fn sct_block_anchor(height: u64, anchor: &block::Root) -> Event {
Event::new(
"sct_block_anchor",
[
("height", height.to_string()).index(),
("anchor", anchor.to_string()).index(),
],
)
}

pub fn sct_epoch_anchor(index: u64, anchor: &epoch::Root) -> Event {
Event::new(
"sct_epoch_anchor",
[
("index", index.to_string()).index(),
("anchor", anchor.to_string()).index(),
],
)
}
Loading