Skip to content

Commit

Permalink
query state optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
harryliisme3 committed Jun 20, 2023
1 parent a6a69da commit db3e7ce
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 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.5" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
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.5" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }

# 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.5" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
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.5" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }

[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.5" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
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.5", optional = true }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5", optional = true }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6", optional = true }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6", optional = true }
serde_with = { version = "1.9.4"}

# primitives
Expand Down
6 changes: 6 additions & 0 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 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.5" }
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }

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

[dev-dependencies]
temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5" }
temp_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.6" }
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 @@ -359,6 +359,8 @@ impl EthApi for EthApiImpl {
.create_context_at(block.header.number.as_u64())
.ok_or_else(|| internal_err("failed to create context"))?;

ctx.state.write().create_query_cache();

ctx.header
.mut_time()
.set_seconds(block.header.timestamp as i64);
Expand Down

0 comments on commit db3e7ce

Please sign in to comment.