From 894c401059579c4d10e3e94131a57952cad185f6 Mon Sep 17 00:00:00 2001
From: carneiro-cw <156914855+carneiro-cw@users.noreply.github.com>
Date: Tue, 19 Mar 2024 10:01:39 -0300
Subject: [PATCH] feat: read account from history (hybrid) (#395)
---
...5aa0339b8175c5339ef6a61fa7f04be445ef4.json | 41 ++++++++++++++++
src/eth/storage/hybrid/hybrid_history.rs | 2 +-
src/eth/storage/hybrid/mod.rs | 47 ++++++++++++++-----
static/schema/001-init.sql | 4 +-
4 files changed, 80 insertions(+), 14 deletions(-)
create mode 100644 .sqlx/query-64a4ea56c5c11b04315a5579ba25aa0339b8175c5339ef6a61fa7f04be445ef4.json
diff --git a/.sqlx/query-64a4ea56c5c11b04315a5579ba25aa0339b8175c5339ef6a61fa7f04be445ef4.json b/.sqlx/query-64a4ea56c5c11b04315a5579ba25aa0339b8175c5339ef6a61fa7f04be445ef4.json
new file mode 100644
index 000000000..084952c02
--- /dev/null
+++ b/.sqlx/query-64a4ea56c5c11b04315a5579ba25aa0339b8175c5339ef6a61fa7f04be445ef4.json
@@ -0,0 +1,41 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT address as \"address: _\",\n nonce as \"nonce: _\",\n balance as \"balance: _\",\n bytecode as \"bytecode: _\"\n FROM neo_accounts\n WHERE address = $1\n AND block_number = (SELECT MAX(block_number)\n FROM historical_slots\n WHERE address = $1\n AND block_number <= $2)",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "address: _",
+ "type_info": "Bytea"
+ },
+ {
+ "ordinal": 1,
+ "name": "nonce: _",
+ "type_info": "Numeric"
+ },
+ {
+ "ordinal": 2,
+ "name": "balance: _",
+ "type_info": "Numeric"
+ },
+ {
+ "ordinal": 3,
+ "name": "bytecode: _",
+ "type_info": "Bytea"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Bytea",
+ "Numeric"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ true
+ ]
+ },
+ "hash": "64a4ea56c5c11b04315a5579ba25aa0339b8175c5339ef6a61fa7f04be445ef4"
+}
diff --git a/src/eth/storage/hybrid/hybrid_history.rs b/src/eth/storage/hybrid/hybrid_history.rs
index 7c9fe9961..2028b679c 100644
--- a/src/eth/storage/hybrid/hybrid_history.rs
+++ b/src/eth/storage/hybrid/hybrid_history.rs
@@ -34,7 +34,7 @@ pub struct AccountInfo {
#[derive(Debug)]
pub struct HybridHistory {
pub hybrid_accounts_slots: HashMap
,
- pool: Arc>,
+ pub pool: Arc>,
}
#[derive(FromRow)]
diff --git a/src/eth/storage/hybrid/mod.rs b/src/eth/storage/hybrid/mod.rs
index 554cc6533..5b820bf03 100644
--- a/src/eth/storage/hybrid/mod.rs
+++ b/src/eth/storage/hybrid/mod.rs
@@ -6,6 +6,7 @@ use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::Duration;
+use anyhow::Context;
use async_trait::async_trait;
use indexmap::IndexMap;
use metrics::atomics::AtomicU64;
@@ -238,19 +239,43 @@ impl PermanentStorage for HybridPermanentStorage {
async fn maybe_read_account(&self, address: &Address, point_in_time: &StoragePointInTime) -> anyhow::Result