Skip to content

Commit

Permalink
query optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
harryliisme3 committed Apr 28, 2023
1 parent e14fc9a commit 82fd715
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/components/contracts/baseapp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ protobuf = "2.16"
ruc = "1.0"
serde = {version = "1.0.124", features = ["derive"]}
serde_json = "1.0.40"
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
sha3 = "0.8"

config = { path = "../../config"}
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/modules/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ primitive-types = { version = "0.11.1", default-features = false, features = ["r
ruc = "1.0"
serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0.64"
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }

# primitives, don't depend on any modules
fp-core = { path = "../../primitives/core" }
Expand All @@ -29,4 +29,4 @@ config = { path = "../../../config"}
rand_chacha = "0.2"
parking_lot = "0.12"
zei = { git = "https://github.com/FindoraNetwork/zei", branch = "stable-main" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
4 changes: 2 additions & 2 deletions src/components/contracts/modules/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ enterprise-web3 = { path = "../../primitives/enterprise-web3" }
baseapp = { path = "../../baseapp" }
fp-mocks = { path = "../../primitives/mocks" }
module-account = { path = "../account" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/modules/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fp-traits = { path = "../../primitives/traits" }
fp-types = { path = "../../primitives/types" }
fp-utils = { path = "../../primitives/utils" }
config = { path = "../../../config"}
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
ledger = { path = "../../../../ledger" }
enterprise-web3 = { path = "../../primitives/enterprise-web3" }

Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/primitives/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ parking_lot = "0.12"
primitive-types = { version = "0.11.1", default-features = false, features = ["rlp", "byteorder", "serde"] }
ruc = "1.0"
serde = { version = "1.0.124", features = ["derive"] }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true }
storage = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize", optional = true }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize", optional = true }
serde_with = { version = "1.9.4"}

# primitives
Expand Down
26 changes: 18 additions & 8 deletions src/components/contracts/primitives/core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ pub struct Context {
pub eth_cache: EthereumCache,
}

impl Drop for Context {
fn drop(&mut self) {
self.state.write().clear_query_cache();
}
}

impl Context {
pub fn new(
state_merkle: Arc<RwLock<ChainState<FinDB>>>,
Expand All @@ -57,14 +63,18 @@ impl Context {
let state = self.state.read().state_at(height);
let db = State::new(self.db.read().chain_state(), false);
match state {
Ok(state) => Some(Context {
state: Arc::new(RwLock::new(state)),
db: Arc::new(RwLock::new(db)),
run_mode: RunTxMode::None,
header: Default::default(),
header_hash: Default::default(),
eth_cache: Default::default(),
}),
Ok(state) => {
let ctx = Context {
state: Arc::new(RwLock::new(state)),
db: Arc::new(RwLock::new(db)),
run_mode: RunTxMode::None,
header: Default::default(),
header_hash: Default::default(),
eth_cache: Default::default(),
};
ctx.state.write().create_query_cache();
Some(ctx)
}
_ => None,
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/primitives/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ ruc = "1.0"
serde = { version = "1.0.124", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.9.5"
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }

# primitives
fp-core = { path = "../core" }
config = { path = "../../../config"}

[dev-dependencies]
temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" }
temp_db = { git = "https://github.com/FindoraNetwork/storage.git", branch = "query_optimize" }
2 changes: 2 additions & 0 deletions src/components/contracts/rpc/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ impl EthApi for EthApiImpl {
.map_err(|err| {
internal_err(format!("evm runner call error: {err:?}"))
})?;

debug!(target: "eth_rpc", "evm runner call result: {info:?}");

error_on_execution_failure(&info.exit_reason, &info.value)?;
Expand All @@ -405,6 +406,7 @@ impl EthApi for EthApiImpl {
.map_err(|err| {
internal_err(format!("evm runner create error: {err:?}"))
})?;

debug!(target: "eth_rpc", "evm runner create result: {info:?}");

error_on_execution_failure(&info.exit_reason, &[])?;
Expand Down

0 comments on commit 82fd715

Please sign in to comment.