Skip to content

Commit

Permalink
Bump scrypto dep to develop-839137f1 + Fix imports for good (#849)
Browse files Browse the repository at this point in the history
## Summary

This addresses https://radixdlt.atlassian.net/browse/NODE-596.

## Details

Apart from pulling the newest scrypto dep, this PR contains a slight
convenience-only refactor:

Each of our crates now contains a top-level `pub(crate) mod
scrypto_prelude { <lots of engine imports relevant to that crate> }`.
From this point on, all other files in these crates are supposed to only
import a single `use crate::scrypto_prelude::*;` (instead of many
independent engine imports).

## Testing

No Node feature / behavior change here - existing tests are sufficient.
  • Loading branch information
jakrawcz-rdx authored Feb 15, 2024
2 parents 4ec27b7 + f9ba2ce commit eb2c972
Show file tree
Hide file tree
Showing 134 changed files with 447 additions and 824 deletions.
240 changes: 101 additions & 139 deletions core-rust/Cargo.lock

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions core-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ resolver = "2"
# $ git push origin "release_name-BLAH"
# * Then use tag="release_name-BLAH" in the below dependencies.
#
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
transaction-scenarios = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
radix-engine-stores = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea" }
utils = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-e212f2ea", features = ["serde"] }
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
transaction-scenarios = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
substate-store-impls = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
substate-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
substate-store-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1" }
utils = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1", features = ["serde"] }
blueprint-schema-init = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "develop-839137f1", features = ["serde"] }

itertools = { version = "0.11.0" }
jni = { version = "0.19.0" }
Expand Down
7 changes: 4 additions & 3 deletions core-rust/core-api-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ transaction = { workspace = true }
radix-engine-common = { workspace = true }
radix-engine-interface = { workspace = true }
radix-engine = { workspace = true }
radix-engine-stores = { workspace = true }
radix-engine-store-interface = { workspace = true }
radix-engine-queries = { workspace = true }
substate-store-impls = { workspace = true }
substate-store-interface = { workspace = true }
substate-store-queries = { workspace = true }
blueprint-schema-init = { workspace = true }
utils = { workspace = true }

# Non-Radix Engine Dependencies:
Expand Down
15 changes: 1 addition & 14 deletions core-rust/core-api-server/src/core_api/conversions/addressing.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
use crate::core_api::models;
use crate::core_api::*;
use crate::engine_prelude::*;
use models::SubstateType;
use radix_engine::blueprints::account::{AccountField, AccountTypedSubstateKey};
use radix_engine::blueprints::pool::v1::substates::multi_resource_pool::{
MultiResourcePoolField, MultiResourcePoolTypedSubstateKey,
};
use radix_engine::blueprints::pool::v1::substates::one_resource_pool::{
OneResourcePoolField, OneResourcePoolTypedSubstateKey,
};
use radix_engine::blueprints::pool::v1::substates::two_resource_pool::{
TwoResourcePoolField, TwoResourcePoolTypedSubstateKey,
};
use radix_engine::types::*;

use radix_engine_queries::typed_substate_layout::*;
use radix_engine_store_interface::db_key_mapper::*;

pub fn to_api_global_address(
context: &MappingContext,
Expand Down
4 changes: 1 addition & 3 deletions core-rust/core-api-server/src/core_api/conversions/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use radix_engine::types::*;

use sbor::representations::*;
use crate::engine_prelude::*;
use state_manager::LedgerHeader;

use crate::core_api::handlers::to_api_epoch_round;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use radix_engine::types::{AddressBech32Decoder, AddressBech32Encoder};
use radix_engine_interface::network::NetworkDefinition;
use transaction::model::{TransactionHashBech32Decoder, TransactionHashBech32Encoder};
use crate::engine_prelude::*;

use crate::core_api::models;

Expand Down
7 changes: 1 addition & 6 deletions core-rust/core-api-server/src/core_api/conversions/errors.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use radix_engine::types::NonFungibleIdType;
use radix_engine_common::{address::AddressBech32EncodeError, types::PartitionNumber};
use radix_engine_interface::data::scrypto::model::ParseNonFungibleLocalIdError;
use sbor::{DecodeError, EncodeError};
use crate::engine_prelude::*;
use state_manager::StateVersion;
use tracing::warn;
use transaction::errors::TransactionValidationError;
use transaction::model::TransactionHashBech32EncodeError;

use crate::core_api::*;

Expand Down
3 changes: 1 addition & 2 deletions core-rust/core-api-server/src/core_api/conversions/hashes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use radix_engine_interface::blueprints::package::CodeHash;
use crate::engine_prelude::*;
use state_manager::{transaction::*, ReceiptTreeHash, StateHash, TransactionTreeHash};
use transaction::prelude::*;

use crate::core_api::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use radix_engine::types::PublicKey;
use radix_engine_interface::crypto::{Ed25519PublicKey, Secp256k1PublicKey};
use transaction::model::{SignatureV1, SignatureWithPublicKeyV1};
use transaction::prelude::{Ed25519Signature, Secp256k1Signature};
use crate::engine_prelude::*;

use crate::core_api::*;

Expand Down
15 changes: 3 additions & 12 deletions core-rust/core-api-server/src/core_api/conversions/lts.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
use models::*;
use radix_engine::{
system::system_modules::costing::RoyaltyRecipient,
transaction::BalanceChange,
types::{Decimal, GlobalAddress, IndexMap, ResourceAddress},
};

use crate::engine_prelude::*;
use state_manager::store::{traits::SubstateNodeAncestryStore, StateManagerDatabase};
use state_manager::{
CommittedTransactionIdentifiers, LedgerTransactionOutcome, LocalTransactionReceipt,
StateVersion, TransactionTreeHash,
};

use radix_engine::transaction::{FeeDestination, FeeSource, TransactionFeeSummary};
use transaction::prelude::*;

use crate::core_api::*;

#[tracing::instrument(skip_all)]
Expand Down Expand Up @@ -89,14 +80,14 @@ pub fn to_api_lts_committed_transaction_outcome(
pub fn to_api_lts_entity_non_fungible_balance_changes(
context: &MappingContext,
global_balance_summary: &IndexMap<GlobalAddress, IndexMap<ResourceAddress, BalanceChange>>,
) -> Result<Vec<LtsEntityNonFungibleBalanceChanges>, MappingError> {
) -> Result<Vec<models::LtsEntityNonFungibleBalanceChanges>, MappingError> {
let mut changes = Vec::new();
for (address, balance_changes) in global_balance_summary.iter() {
for (resource, balance_change) in balance_changes.iter() {
match balance_change {
BalanceChange::Fungible(_) => {}
BalanceChange::NonFungible { added, removed } => {
changes.push(LtsEntityNonFungibleBalanceChanges {
changes.push(models::LtsEntityNonFungibleBalanceChanges {
entity_address: to_api_global_address(context, address)?,
resource_address: to_api_resource_address(context, resource)?,
added: added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::any::type_name;

use radix_engine_common::math::*;
use radix_engine_interface::blueprints::package::BlueprintVersion;
use radix_engine_interface::prelude::*;
use sbor::WellKnownTypeId;
use crate::engine_prelude::*;
use state_manager::store::traits::scenario::ScenarioSequenceNumber;
use state_manager::StateVersion;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use radix_engine::types::*;

use crate::core_api::*;
use crate::engine_prelude::*;

pub struct SizeRange {
pub min: usize,
Expand Down
15 changes: 1 addition & 14 deletions core-rust/core-api-server/src/core_api/conversions/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,8 @@

use super::addressing::*;
use crate::core_api::*;
use radix_engine::blueprints::models::KeyValueKeyPayload;
use radix_engine::types::*;

use radix_engine::system::system_modules::costing::*;
use radix_engine::transaction::{
CostingParameters, EventSystemStructure, FeeDestination, FeeSource,
IndexPartitionEntryStructure, KeyValuePartitionEntryStructure, KeyValueStoreEntryStructure,
ObjectInstanceTypeReference, ObjectSubstateTypeReference, PackageTypeReference,
SortedIndexPartitionEntryStructure, StateUpdateSummary, SubstateSystemStructure,
SystemFieldKind, SystemFieldStructure, TransactionFeeSummary,
};
use radix_engine_queries::typed_substate_layout::*;
use radix_engine_store_interface::db_key_mapper::{MappedSubstateDatabase, SpreadPrefixKeyMapper};
use crate::engine_prelude::*;
use state_manager::store::StateManagerDatabase;
use transaction::prelude::TransactionCostingParameters;

use state_manager::{
ApplicationEvent, BySubstate, DetailedTransactionOutcome, LedgerStateChanges,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;

use radix_engine::types::*;
use radix_engine_interface::blueprints::access_controller::{RecoveryProposal, RuleSet};
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_access_controller_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::system::system_substates::KeyValueEntrySubstate;

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_owner_role_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::blueprints::account::{
AccountAuthorizedDepositorEntrySubstate, AccountAuthorizedDepositorKeyPayload,
AccountDepositRuleFieldSubstate, AccountResourcePreferenceEntrySubstate,
AccountResourcePreferenceKeyPayload, AccountResourceVaultEntrySubstate,
AccountResourceVaultKeyPayload, AccountSubstate, AccountTypedSubstateKey,
};

use radix_engine::types::*;
use radix_engine_interface::blueprints::account::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_account_state_substate(
_context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
use radix_engine::blueprints::models::SortedIndexKeyPayload;

use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine_interface::blueprints::consensus_manager::*;

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_registered_validators_by_stake_index_entry_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::system::system_substates::{FieldSubstate, KeyValueEntrySubstate};

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_generic_scrypto_component_state_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_metadata_value_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub use type_info_module::*;
//====================================

use super::MappingError;
use radix_engine::system::system_substates::{KeyValueEntrySubstate, LockStatus};
use crate::engine_prelude::*;

macro_rules! assert_key_type {
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::system::system_substates::KeyValueEntrySubstate;
use radix_engine::transaction::PackageTypeReference;

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_package_royalty_accumulator_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::blueprints::pool::v1::substates::multi_resource_pool::{
MultiResourcePoolState, MultiResourcePoolStateFieldSubstate,
};
use radix_engine::blueprints::pool::v1::substates::one_resource_pool::{
OneResourcePoolState, OneResourcePoolStateFieldSubstate,
};
use radix_engine::blueprints::pool::v1::substates::two_resource_pool::{
TwoResourcePoolState, TwoResourcePoolStateFieldSubstate,
};

use radix_engine::types::*;
use crate::engine_prelude::*;

pub fn to_api_one_resource_pool_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_fungible_vault_balance_substate(
_context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_component_royalty_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::blueprints::account::{
AccountTypedFieldSubstateValue, AccountTypedSubstateValue,
};
use radix_engine::blueprints::pool::v1::substates::multi_resource_pool::{
MultiResourcePoolTypedFieldSubstateValue, MultiResourcePoolTypedSubstateValue,
};
use radix_engine::blueprints::pool::v1::substates::one_resource_pool::{
OneResourcePoolTypedFieldSubstateValue, OneResourcePoolTypedSubstateValue,
};
use radix_engine::blueprints::pool::v1::substates::two_resource_pool::{
TwoResourcePoolTypedFieldSubstateValue, TwoResourcePoolTypedSubstateValue,
};

use radix_engine::types::*;

use radix_engine_queries::typed_substate_layout::*;

use super::super::MappingError;
use super::*;
use crate::engine_prelude::*;

pub fn to_api_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::super::*;
use super::*;
use crate::core_api::models;
use radix_engine::system::system_substates::{FieldSubstate, KeyValueEntrySubstate};

use radix_engine::types::*;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_transaction_tracker_substate(
context: &MappingContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use super::super::*;
use super::*;
use crate::core_api::models;

use radix_engine::types::*;
use radix_engine::vm::VmBoot;
use radix_engine_queries::typed_substate_layout::*;
use crate::engine_prelude::*;

pub fn to_api_vm_boot_substate(
_context: &MappingContext,
Expand Down
2 changes: 1 addition & 1 deletion core-rust/core-api-server/src/core_api/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use axum::{
use models::stream_proofs_error_details::StreamProofsErrorDetails;
use std::any::Any;

use crate::engine_prelude::*;
use hyper::StatusCode;
use radix_engine_interface::network::NetworkDefinition;
use tower_http::catch_panic::ResponseForPanic;

use super::{models, CoreApiState};
Expand Down
Loading

0 comments on commit eb2c972

Please sign in to comment.