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

more engine tests; build in release mode #88

Merged
merged 3 commits into from
Nov 26, 2024
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
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ COPY Cargo.toml build.rs ./
COPY src ./src

ENV RUST_BACKTRACE=full
RUN cargo build
RUN cargo build --release --bins

## Pre-generate some configurations we can use
# TOOD: consider doing something different here
RUN target/debug/setup_local_testnet
RUN target/release/setup_local_testnet

#################################################################################

Expand All @@ -54,7 +54,12 @@ EOF
WORKDIR /app
COPY --from=builder /usr/src/app/src/proto /app/proto
COPY --from=builder /usr/src/app/nodes /app/nodes
COPY --from=builder /usr/src/app/target/debug/snapchain /app/
COPY --from=builder \
/usr/src/app/target/release/snapchain \
/usr/src/app/target/release/follow_blocks \
/usr/src/app/target/release/setup_local_testnet \
/usr/src/app/target/release/submit_message \
/app/

ENV RUSTFLAGS="-Awarnings"
CMD ["./snapchain", "--id", "1"]
55 changes: 49 additions & 6 deletions src/storage/store/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ impl ShardEngine {
self.events_tx.send(event);
}
self.trie.reload(&self.db).unwrap();

self.emit_commit_metrics(&shard_chunk);

match self.shard_store.put_shard_chunk(shard_chunk) {
Err(err) => {
error!("Unable to write shard chunk to store {}", err)
}
Ok(()) => {}
}
}

fn emit_commit_metrics(&mut self, shard_chunk: &&ShardChunk) -> Result<(), EngineError> {
self.statsd_client
.count_with_shard(self.shard_id, "commit", 1);

Expand All @@ -430,14 +442,45 @@ impl ShardEngine {
.height
.unwrap()
.block_number;

self.statsd_client
.gauge_with_shard(self.shard_id, "block_height", *block_number);
match self.shard_store.put_shard_chunk(shard_chunk) {
Err(err) => {
error!("Unable to write shard chunk to store {}", err)
}
Ok(()) => {}
}

let trie_size = self.trie.items()?;

self.statsd_client
.gauge_with_shard(self.shard_id, "trie.num_items", trie_size as u64);

let (user_count, system_count) =
shard_chunk
.transactions
.iter()
.fold((0, 0), |(user_count, system_count), tx| {
(
user_count + tx.user_messages.len(),
system_count + tx.system_messages.len(),
)
});

self.statsd_client.count_with_shard(
self.shard_id,
"committed_transactions",
shard_chunk.transactions.len() as u64,
);

self.statsd_client.count_with_shard(
self.shard_id,
"committed_user_messages",
user_count as u64,
);

self.statsd_client.count_with_shard(
self.shard_id,
"committed_system_messages",
system_count as u64,
);

Ok(())
}

pub fn commit_shard_chunk(&mut self, shard_chunk: &ShardChunk) {
Expand Down