Skip to content

Commit

Permalink
more engine tests; build in release mode (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
suurkivi authored Nov 26, 2024
1 parent 728cd80 commit 40ca68f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 9 deletions.
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

0 comments on commit 40ca68f

Please sign in to comment.