Skip to content

Commit

Permalink
remove near-vm-logic’s dependency on near-primitives (near#9225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekleog-NEAR authored Jun 21, 2023
1 parent e95890e commit 2413ec0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions runtime/near-vm-logic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ near-crypto.workspace = true
near-account-id.workspace = true
near-fmt.workspace = true
near-o11y.workspace = true
near-primitives.workspace = true
near-primitives-core.workspace = true
near-vm-errors.workspace = true

Expand All @@ -37,11 +36,11 @@ expect-test.workspace = true
[features]
default = []
protocol_feature_fix_contract_loading_cost = [
"near-primitives/protocol_feature_fix_contract_loading_cost",
"near-primitives-core/protocol_feature_fix_contract_loading_cost",
]

io_trace = ["tracing"]

# Use this feature to enable counting of fees and costs applied.
costs_counting = []
sandbox = ["tracing","near-primitives/sandbox"]
sandbox = ["tracing"]
13 changes: 8 additions & 5 deletions runtime/near-vm-logic/src/gas_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,15 @@ mod tests {
#[test]
fn test_profile_compute_cost_is_accurate() {
let mut counter = make_test_counter(MAX_GAS, MAX_GAS, false);
counter.pay_base(near_primitives::config::ExtCosts::storage_write_base).unwrap();
counter.pay_per(near_primitives::config::ExtCosts::storage_write_value_byte, 10).unwrap();
counter.pay_base(near_primitives_core::config::ExtCosts::storage_write_base).unwrap();
counter
.pay_per(near_primitives_core::config::ExtCosts::storage_write_value_byte, 10)
.unwrap();
counter
.pay_action_accumulated(
100,
100,
near_primitives::config::ActionCosts::new_data_receipt_byte,
near_primitives_core::config::ActionCosts::new_data_receipt_byte,
)
.unwrap();

Expand All @@ -376,7 +378,8 @@ mod tests {
fn test(burn: Gas, prepaid: Gas, want: Result<(), HostError>) {
let mut counter = make_test_counter(burn, prepaid, false);
assert_eq!(
counter.pay_per(near_primitives::config::ExtCosts::storage_write_value_byte, 100),
counter
.pay_per(near_primitives_core::config::ExtCosts::storage_write_value_byte, 100),
want.map_err(Into::into)
);
let mut profile = counter.profile_data();
Expand All @@ -398,7 +401,7 @@ mod tests {
counter.pay_action_accumulated(
10_000_000_000,
10_000_000_000,
near_primitives::config::ActionCosts::new_data_receipt_byte
near_primitives_core::config::ActionCosts::new_data_receipt_byte
),
want.map_err(Into::into)
);
Expand Down
8 changes: 4 additions & 4 deletions runtime/near-vm-logic/src/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use crate::types::{PromiseIndex, PromiseResult, ReceiptIndex, ReturnData};
use crate::utils::split_method_names;
use crate::{ReceiptMetadata, StorageGetMode, ValuePtr};
use near_crypto::Secp256K1Signature;
use near_primitives::checked_feature;
use near_primitives::config::ViewConfig;
use near_primitives::profile::ProfileDataV3;
use near_primitives::runtime::fees::RuntimeFeesConfig;
use near_primitives_core::checked_feature;
use near_primitives_core::config::ExtCosts::*;
use near_primitives_core::config::ViewConfig;
use near_primitives_core::config::{ActionCosts, ExtCosts, VMConfig};
use near_primitives_core::profile::ProfileDataV3;
use near_primitives_core::runtime::fees::RuntimeFeesConfig;
use near_primitives_core::runtime::fees::{transfer_exec_fee, transfer_send_fee};
use near_primitives_core::types::{
AccountId, Balance, Compute, EpochHeight, Gas, GasDistribution, GasWeight, ProtocolVersion,
Expand Down
13 changes: 6 additions & 7 deletions runtime/near-vm-logic/src/receipt_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ use crate::logic;
use crate::types::ReceiptIndex;
use crate::External;
use near_crypto::PublicKey;
use near_primitives::receipt::DataReceiver;
use near_primitives::transaction::{
Action, AddKeyAction, CreateAccountAction, DeleteAccountAction, DeleteKeyAction,
DeployContractAction, FunctionCallAction, StakeAction, TransferAction,
};
use near_primitives::types::{Balance, Nonce};
use near_primitives_core::account::{AccessKey, AccessKeyPermission, FunctionCallPermission};
use near_primitives_core::hash::CryptoHash;
use near_primitives_core::types::{AccountId, Gas};
use near_primitives_core::types::{Balance, Nonce};
use near_primitives_core::types::{GasDistribution, GasWeight};
use near_vm_errors::HostError;
use near_vm_errors::action::{
Action, AddKeyAction, CreateAccountAction, DeleteAccountAction, DeleteKeyAction,
DeployContractAction, FunctionCallAction, StakeAction, TransferAction,
};
use near_vm_errors::{DataReceiver, HostError};

type ActionReceipts = Vec<(AccountId, ReceiptMetadata)>;

Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-logic/src/tests/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::tests::vm_logic_builder::VMLogicBuilder;
use near_primitives::config::{VMLimitConfig, ViewConfig};
use near_primitives_core::config::{VMLimitConfig, ViewConfig};

macro_rules! decl_test_bytes {
($testname:ident, $method:ident, $ctx:ident, $want:expr) => {
Expand Down
6 changes: 3 additions & 3 deletions runtime/near-vm-logic/src/tests/gas_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::types::Gas;
use crate::{MemSlice, VMConfig};
use borsh::BorshSerialize;
use expect_test::expect;
use near_primitives::config::{ActionCosts, ExtCosts};
use near_primitives::runtime::fees::Fee;
use near_primitives::transaction::{Action, FunctionCallAction};
use near_primitives_core::config::{ActionCosts, ExtCosts};
use near_primitives_core::runtime::fees::Fee;
use near_vm_errors::action::{Action, FunctionCallAction};
use near_vm_errors::{HostError, VMLogicError};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-logic/src/tests/promises.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::VMLogic;
use borsh::BorshSerialize;
use near_account_id::AccountId;
use near_crypto::PublicKey;
use near_primitives::transaction::Action;
use near_vm_errors::action::Action;
use serde_json;

#[derive(serde::Serialize)]
Expand Down

0 comments on commit 2413ec0

Please sign in to comment.