Skip to content

Commit

Permalink
1. update dependencies (#139)
Browse files Browse the repository at this point in the history
2. up rust version
3. query.function_call ReadRPC returns error while NEAR RPC succeeds
  • Loading branch information
kobayurii authored Nov 28, 2023
1 parent b854698 commit c83849c
Show file tree
Hide file tree
Showing 18 changed files with 1,079 additions and 1,311 deletions.
2,204 changes: 980 additions & 1,224 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[workspace]

resolver = "2"

members = [
"database",
"perf-testing",
Expand All @@ -8,3 +10,16 @@ members = [
"state-indexer",
"tx-indexer",
]

[patch.crates-io]
near-chain-configs = { git = 'https://github.com/near/nearcore.git', branch = '1.36.0' }
near-crypto = { git = 'https://github.com/near/nearcore.git', branch = '1.36.0' }
near-jsonrpc-primitives = { git = 'https://github.com/near/nearcore.git', branch = '1.36.0' }
near-indexer-primitives = { git = 'https://github.com/near/nearcore.git', branch = '1.36.0' }
near-primitives = { git = 'https://github.com/near/nearcore.git', branch = '1.36.0' }
near-vm-runner = { git = 'https://github.com/near/nearcore.git', branch = '1.36.0' }

# TODO: We use forks to resolve nearcore dependency conflicts.
# After updating the dependencies, we should use the published versions of the crates.
near-jsonrpc-client = { git = 'https://github.com/kobayurii/near-jsonrpc-client-rs.git', branch = '0.7.0' }
near-lake-framework = { git = 'https://github.com/kobayurii/near-lake-framework-rs.git', branch = '0.7.4' }
6 changes: 3 additions & 3 deletions database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ uuid = { version = "1.3.0", optional = true }

readnode-primitives = { path = "../readnode-primitives" }

near-primitives = "0.17.0"
near-crypto = "0.17.0"
near-indexer-primitives = "0.17.0"
near-primitives = "1.36.0"
near-crypto = "1.36.0"
near-indexer-primitives = "1.36.0"

[features]
default = ["scylla_db"]
Expand Down
9 changes: 5 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
version: '3.4'

x-common-variables: &common-variables
SCYLLA_URL: scylla:9042
SCYLLA_USER: ${SCYLLA_USER}
SCYLLA_PASSWORD: ${SCYLLA_PASSWORD}
DATABASE_URL: scylla:9042
DATABASE_USER: ${SCYLLA_USER}
DATABASE_PASSWORD: ${SCYLLA_PASSWORD}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
OTEL_EXPORTER_JAEGER_AGENT_HOST: jaeger
OTEL_EXPORTER_JAEGER_AGENT_PORT: 6831
OTEL_EXPORTER_JAEGER_ENDPOINT: http://jaeger:14268/api/traces

NEAR_RPC_URL: https://archival-rpc.mainnet.near.org
NEAR_RPC_URL: https://rpc.mainnet.near.org
ARCHIVAL_NEAR_RPC_URL: https://archival-rpc.mainnet.near.org
AWS_BUCKET_NAME: near-lake-data-mainnet

services:
Expand Down
6 changes: 3 additions & 3 deletions perf-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ serde_json = "1.0"
tokio = { version = "1.28.2", features = ["full", "tracing"] }
tracing = "0.1.34"

near-jsonrpc-client = "0.6.0"
near-jsonrpc-primitives = "0.17.0"
near-primitives = "0.17.0"
near-jsonrpc-client = "0.7.0"
near-jsonrpc-primitives = "1.36.0"
near-primitives = "1.36.0"
4 changes: 1 addition & 3 deletions readnode-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ num-traits = "0.2.15"
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.85"

near-indexer-primitives = "0.17.0"
near-primitives = "0.17.0"
near-primitives-core = "0.17.0"
near-indexer-primitives = "1.36.0"
21 changes: 10 additions & 11 deletions readnode-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ pub type StateValue = Vec<u8>;
pub struct BlockHeightShardId(pub u64, pub u64);
pub struct QueryData<T: BorshDeserialize> {
pub data: T,
pub block_height: near_primitives_core::types::BlockHeight,
pub block_height: near_indexer_primitives::types::BlockHeight,
pub block_hash: CryptoHash,
}
pub struct ReceiptRecord {
pub receipt_id: CryptoHash,
pub parent_transaction_hash: CryptoHash,
pub block_height: near_primitives::types::BlockHeight,
pub shard_id: near_primitives::types::ShardId,
pub block_height: near_indexer_primitives::types::BlockHeight,
pub shard_id: near_indexer_primitives::types::ShardId,
}

pub struct BlockRecord {
Expand Down Expand Up @@ -185,8 +185,8 @@ where
impl<T>
TryFrom<(
Vec<u8>,
near_primitives_core::types::BlockHeight,
near_indexer_primitives::CryptoHash,
near_indexer_primitives::types::BlockHeight,
CryptoHash,
)> for QueryData<T>
where
T: BorshDeserialize,
Expand All @@ -196,8 +196,8 @@ where
fn try_from(
value: (
Vec<u8>,
near_primitives_core::types::BlockHeight,
near_indexer_primitives::CryptoHash,
near_indexer_primitives::types::BlockHeight,
CryptoHash,
),
) -> Result<Self, Self::Error> {
let data = T::try_from_slice(&value.0)?;
Expand All @@ -217,10 +217,9 @@ where
type Error = anyhow::Error;

fn try_from(value: (String, String, T, T)) -> Result<Self, Self::Error> {
let receipt_id =
near_primitives::hash::CryptoHash::try_from(value.0.as_bytes()).map_err(|err| {
anyhow::anyhow!("Failed to parse `receipt_id` to CryptoHash: {}", err)
})?;
let receipt_id = CryptoHash::try_from(value.0.as_bytes()).map_err(|err| {
anyhow::anyhow!("Failed to parse `receipt_id` to CryptoHash: {}", err)
})?;
let parent_transaction_hash = CryptoHash::from_str(&value.1).map_err(|err| {
anyhow::anyhow!(
"Failed to parse `parent_transaction_hash` to CryptoHash: {}",
Expand Down
20 changes: 8 additions & 12 deletions rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,14 @@ tracing-stackdriver = "0.7.2" # GCP logs
database = { path = "../database" }
readnode-primitives = { path = "../readnode-primitives" }

near-chain-configs = "0.17.0"
near-crypto = "0.17.0"
near-jsonrpc-client = "0.6.0"
near-jsonrpc-primitives = "0.17.0"
near-indexer-primitives = "0.17.0"
near-lake-framework = "0.7.3"
near-primitives = "0.17.0"
near-primitives-core = "0.17.0"
near-vm-runner = "0.17.0"
near-vm-logic = "0.17.0"
near-vm-errors = "0.17.0"

near-chain-configs = "1.36.0"
near-crypto = "1.36.0"
near-jsonrpc-client = "0.7.0"
near-jsonrpc-primitives = "1.36.0"
near-indexer-primitives = "1.36.0"
near-lake-framework = "0.7.4"
near-primitives = "1.36.0"
near-vm-runner = "1.36.0"

[features]
default = ["send_tx_methods", "scylla_db"]
Expand Down
2 changes: 1 addition & 1 deletion rpc-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.69 AS builder
FROM rust:1.73 AS builder
ARG features="default"
WORKDIR /tmp/

Expand Down
16 changes: 8 additions & 8 deletions rpc-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct Opts {
/// Max gas burnt for contract function call
/// Default value is 300_000_000_000_000
#[clap(long, env, default_value_t = 300_000_000_000_000)]
pub max_gas_burnt: near_primitives_core::types::Gas,
pub max_gas_burnt: near_primitives::types::Gas,

/// Max available memory for `block_cache` and `contract_code_cache` in gigabytes
/// By default we use all available memory
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Opts {

pub async fn to_lake_config(
&self,
start_block_height: near_primitives_core::types::BlockHeight,
start_block_height: near_primitives::types::BlockHeight,
) -> anyhow::Result<near_lake_framework::LakeConfig> {
let config_builder = near_lake_framework::LakeConfigBuilder::default();
Ok(config_builder
Expand All @@ -159,7 +159,7 @@ pub struct ServerContext {
pub contract_code_cache: std::sync::Arc<
std::sync::RwLock<crate::cache::LruMemoryCache<near_primitives::hash::CryptoHash, Vec<u8>>>,
>,
pub max_gas_burnt: near_primitives_core::types::Gas,
pub max_gas_burnt: near_primitives::types::Gas,
}

impl ServerContext {
Expand All @@ -180,7 +180,7 @@ impl ServerContext {
crate::cache::LruMemoryCache<near_primitives::hash::CryptoHash, Vec<u8>>,
>,
>,
max_gas_burnt: near_primitives_core::types::Gas,
max_gas_burnt: near_primitives::types::Gas,
) -> Self {
Self {
s3_client,
Expand All @@ -201,17 +201,17 @@ pub struct CompiledCodeCache {
std::sync::RwLock<
crate::cache::LruMemoryCache<
near_primitives::hash::CryptoHash,
near_primitives::types::CompiledContract,
near_vm_runner::logic::CompiledContract,
>,
>,
>,
}

impl near_primitives::types::CompiledContractCache for CompiledCodeCache {
impl near_vm_runner::logic::CompiledContractCache for CompiledCodeCache {
fn put(
&self,
key: &near_primitives::hash::CryptoHash,
value: near_primitives::types::CompiledContract,
value: near_vm_runner::logic::CompiledContract,
) -> std::io::Result<()> {
self.local_cache.write().unwrap().put(*key, value);
Ok(())
Expand All @@ -220,7 +220,7 @@ impl near_primitives::types::CompiledContractCache for CompiledCodeCache {
fn get(
&self,
key: &near_primitives::hash::CryptoHash,
) -> std::io::Result<Option<near_primitives::types::CompiledContract>> {
) -> std::io::Result<Option<near_vm_runner::logic::CompiledContract>> {
Ok(self.local_cache.write().unwrap().get(key).cloned())
}

Expand Down
28 changes: 14 additions & 14 deletions rpc-server/src/modules/queries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod utils;

const MAX_LIMIT: u8 = 100;

pub type Result<T> = ::std::result::Result<T, near_vm_logic::VMLogicError>;
pub type Result<T> = ::std::result::Result<T, near_vm_runner::logic::VMLogicError>;

pub struct CodeStorage {
db_manager: std::sync::Arc<Box<dyn ReaderDbManager + Sync + Send + 'static>>,
Expand All @@ -21,7 +21,7 @@ pub struct StorageValuePtr {
value: Vec<u8>,
}

impl near_vm_logic::ValuePtr for StorageValuePtr {
impl near_vm_runner::logic::ValuePtr for StorageValuePtr {
fn len(&self) -> u32 {
self.value.len() as u32
}
Expand All @@ -47,11 +47,11 @@ impl CodeStorage {
}
}

impl near_vm_logic::External for CodeStorage {
impl near_vm_runner::logic::External for CodeStorage {
#[cfg_attr(feature = "tracing-instrumentation", tracing::instrument(skip(self)))]
fn storage_set(&mut self, _key: &[u8], _value: &[u8]) -> Result<()> {
Err(near_vm_logic::VMLogicError::HostError(
near_vm_logic::HostError::ProhibitedInView {
Err(near_vm_runner::logic::VMLogicError::HostError(
near_vm_runner::logic::HostError::ProhibitedInView {
method_name: String::from("storage_set"),
},
))
Expand All @@ -64,8 +64,8 @@ impl near_vm_logic::External for CodeStorage {
fn storage_get(
&self,
key: &[u8],
_mode: near_vm_logic::StorageGetMode,
) -> Result<Option<Box<dyn near_vm_logic::ValuePtr>>> {
_mode: near_vm_runner::logic::StorageGetMode,
) -> Result<Option<Box<dyn near_vm_runner::logic::ValuePtr>>> {
let get_db_data =
self.db_manager
.get_state_key_value(&self.account_id, self.block_height, key.to_vec());
Expand All @@ -81,17 +81,17 @@ impl near_vm_logic::External for CodeStorage {

#[cfg_attr(feature = "tracing-instrumentation", tracing::instrument(skip(self)))]
fn storage_remove(&mut self, _key: &[u8]) -> Result<()> {
Err(near_vm_logic::VMLogicError::HostError(
near_vm_logic::HostError::ProhibitedInView {
Err(near_vm_runner::logic::VMLogicError::HostError(
near_vm_runner::logic::HostError::ProhibitedInView {
method_name: String::from("storage_remove"),
},
))
}

#[cfg_attr(feature = "tracing-instrumentation", tracing::instrument(skip(self)))]
fn storage_remove_subtree(&mut self, _prefix: &[u8]) -> Result<()> {
Err(near_vm_logic::VMLogicError::HostError(
near_vm_logic::HostError::ProhibitedInView {
Err(near_vm_runner::logic::VMLogicError::HostError(
near_vm_runner::logic::HostError::ProhibitedInView {
method_name: String::from("storage_remove_subtree"),
},
))
Expand All @@ -104,7 +104,7 @@ impl near_vm_logic::External for CodeStorage {
fn storage_has_key(
&mut self,
key: &[u8],
_mode: near_vm_logic::StorageGetMode,
_mode: near_vm_runner::logic::StorageGetMode,
) -> Result<bool> {
let get_db_state_keys =
self.db_manager
Expand Down Expand Up @@ -145,8 +145,8 @@ impl near_vm_logic::External for CodeStorage {
fn validator_total_stake(&self) -> Result<near_primitives::types::Balance> {
// TODO: Should be works after implementing validators. See comment above.
// Ok(self.validators.values().sum())
Err(near_vm_logic::VMLogicError::HostError(
near_vm_logic::HostError::ProhibitedInView {
Err(near_vm_runner::logic::VMLogicError::HostError(
near_vm_runner::logic::HostError::ProhibitedInView {
method_name: String::from("validator_total_stake"),
},
))
Expand Down
Loading

0 comments on commit c83849c

Please sign in to comment.