moving from custom types to text

This commit is contained in:
Godmode Galactus 2023-10-24 13:30:34 +02:00
parent 2dc6b27e68
commit 070c3264ba
No known key found for this signature in database
GPG Key ID: A04142C71ABB0DEA
3 changed files with 18 additions and 26 deletions

View File

@ -1,32 +1,16 @@
CREATE SCHEMA banking_stage_results;
CREATE TYPE error AS (
error text,
slot BIGINT,
count BIGINT
);
CREATE TYPE ACCOUNT_USED AS (
account CHAR(44),
r_w CHAR
);
CREATE TYPE ACCOUNT_USE_COUNT AS (
account CHAR(44),
cu BIGINT
);
CREATE TABLE banking_stage_results.transaction_infos (
signature CHAR(88) PRIMARY KEY,
message text,
errors ERROR[],
errors text [],
is_executed BOOL,
is_confirmed BOOL,
first_notification_slot BIGINT NOT NULL,
cu_requested BIGINT,
prioritization_fees BIGINT,
utc_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
accounts_used ACCOUNT_USED[],
accounts_used text [],
processed_slot BIGINT
);
@ -39,7 +23,7 @@ CREATE TABLE banking_stage_results.blocks (
processed_transactions BIGINT,
total_cu_used BIGINT,
total_cu_requested BIGINT,
heavily_writelocked_accounts ACCOUNT_USE_COUNT[]
heavily_writelocked_accounts text []
);
CREATE TABLE banking_stage_results.accounts (

View File

@ -73,7 +73,7 @@ impl BlockInfo {
.unwrap_or(0)
})
.sum::<u64>() as i64;
let mut writelocked_accounts = HashMap::new();
let mut writelocked_accounts: HashMap<Pubkey, (u64, u64)> = HashMap::new();
let mut total_cu_requested: u64 = 0;
for transaction in &block.transactions {
let Some(tx) = &transaction.transaction else {
@ -88,6 +88,10 @@ impl BlockInfo {
continue;
};
let Some(meta) = &transaction.meta else {
continue;
};
let message = VersionedMessage::V0(v0::Message {
header: MessageHeader {
num_required_signatures: header.num_required_signatures as u8,
@ -175,7 +179,9 @@ impl BlockInfo {
})
.or(legacy_cu_requested);
let cu_requested = cu_requested.unwrap_or(200000) as u64;
let cu_consumed = meta.compute_units_consumed.unwrap_or(0);
total_cu_requested = total_cu_requested + cu_requested;
let writable_accounts = message
.static_account_keys()
.iter()
@ -186,10 +192,12 @@ impl BlockInfo {
for writable_account in writable_accounts {
match writelocked_accounts.get_mut(&writable_account) {
Some(x) => {
*x += cu_requested;
x.0 += cu_requested;
x.1 += cu_consumed;
}
None => {
writelocked_accounts.insert(writable_account, cu_requested);
writelocked_accounts.insert(writable_account, (cu_requested, cu_consumed));
}
}
}
@ -197,12 +205,12 @@ impl BlockInfo {
let mut heavily_writelocked_accounts = writelocked_accounts
.iter()
.filter(|x| *x.1 > 1000000)
.filter(|x| x.1.1 > 1000000)
.collect_vec();
heavily_writelocked_accounts.sort_by(|lhs, rhs| (*rhs.1).cmp(lhs.1));
let heavily_writelocked_accounts = heavily_writelocked_accounts
.iter()
.map(|(pubkey, cu)| format!("({}, {})", **pubkey, **cu))
.map(|(pubkey, (cu_req, cu_con))| format!("(k:{}, cu_req:{}, cu_con:{})", **pubkey, *cu_req, *cu_con))
.collect_vec();
BlockInfo {
block_hash,

View File

@ -216,12 +216,12 @@ impl From<&TransactionInfo> for PostgresTransactionInfo {
let errors = value
.errors
.iter()
.map(|(key, size)| format!("({}, {}, {})", key.error, key.slot, size))
.map(|(key, size)| format!("key:{}, slot:{}, count:{}", key.error, key.slot, size))
.collect_vec();
let accounts_used = value
.account_used
.iter()
.map(|x| format!("({}, {})", x.0, x.1))
.map(|x| format!("{}({})", x.0, x.1))
.collect();
Self {
signature: value.signature.clone(),