Skip to content

Commit

Permalink
fix: Fix TxStage string representation (#255)
Browse files Browse the repository at this point in the history
# What ❔

After transferring to vise metrics, `mempool_` transaction stage labels
became incorrect (e.g., `mempool_Added` instead of `mempool_added`).
This PR changes them back.

## Why ❔

These labels are used on some internal Grafana dashboards.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] ~Tests for the changes have been added / updated.~ *not
applicable*
- [ ] ~Documentation comments have been added / updated.~ *not
applicable*
- [x] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
slowli authored Oct 19, 2023
1 parent 34f3110 commit 246b5a0
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions core/lib/dal/src/transactions_dal.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use bigdecimal::BigDecimal;
use std::collections::HashMap;
use std::fmt::{self, Debug};
use std::iter::FromIterator;
use std::time::Duration;

use itertools::Itertools;
use sqlx::error;
use sqlx::types::chrono::NaiveDateTime;
use sqlx::{error, types::chrono::NaiveDateTime};

use std::{collections::HashMap, fmt, time::Duration};

use zksync_types::tx::tx_execution_info::TxExecutionStatus;
use zksync_types::vm_trace::Call;
use zksync_types::{
block::MiniblockReexecuteData, fee::TransactionExecutionMetrics, get_nonce_key, l1::L1Tx,
l2::L2Tx, protocol_version::ProtocolUpgradeTx, tx::TransactionExecutionResult,
vm_trace::VmExecutionTrace, Address, ExecuteTransactionCommon, L1BatchNumber, L1BlockNumber,
MiniblockNumber, Nonce, PriorityOpId, Transaction, H256, PROTOCOL_UPGRADE_TX_TYPE, U256,
block::MiniblockReexecuteData,
fee::TransactionExecutionMetrics,
get_nonce_key,
l1::L1Tx,
l2::L2Tx,
protocol_version::ProtocolUpgradeTx,
tx::{tx_execution_info::TxExecutionStatus, TransactionExecutionResult},
vm_trace::{Call, VmExecutionTrace},
Address, ExecuteTransactionCommon, L1BatchNumber, L1BlockNumber, MiniblockNumber, Nonce,
PriorityOpId, Transaction, H256, PROTOCOL_UPGRADE_TX_TYPE, U256,
};
use zksync_utils::{h256_to_u32, u256_to_big_decimal};

Expand All @@ -35,8 +35,14 @@ pub enum L2TxSubmissionResult {
}

impl fmt::Display for L2TxSubmissionResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::Added => "added",
Self::Replaced => "replaced",
Self::AlreadyExecuted => "already_executed",
Self::Duplicate => "duplicate",
Self::Proxied => "proxied",
})
}
}

Expand Down Expand Up @@ -378,11 +384,8 @@ impl TransactionsDal<'_, '_> {
transactions: &[TransactionExecutionResult],
) {
{
let hashes: Vec<Vec<u8>> = transactions
.iter()
.map(|tx| tx.hash.as_bytes().to_vec())
.collect();
let l1_batch_tx_indexes = Vec::from_iter(0..transactions.len() as i32);
let hashes: Vec<_> = transactions.iter().map(|tx| tx.hash.as_bytes()).collect();
let l1_batch_tx_indexes: Vec<_> = (0..transactions.len() as i32).collect();
sqlx::query!(
"
UPDATE transactions
Expand All @@ -398,7 +401,7 @@ impl TransactionsDal<'_, '_> {
WHERE transactions.hash=data_table.hash
",
&l1_batch_tx_indexes,
&hashes,
&hashes as &[&[u8]],
block_number.0 as i64
)
.execute(self.storage.conn())
Expand Down

0 comments on commit 246b5a0

Please sign in to comment.