Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: New Executable model (and other misc markups) #1885

Merged
merged 13 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
45 changes: 24 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p sbor
run: cargo nextest run -p sbor --no-fail-fast
- name: Run tests (no_std)
run: cargo nextest run -p sbor --no-default-features --features alloc
run: cargo nextest run -p sbor --no-default-features --features alloc --no-fail-fast
- name: Run derive tests
run: cargo nextest run -p sbor-derive-common
run: cargo nextest run -p sbor-derive-common --no-fail-fast

sbor-integration-tests:
name: Run SBOR integration tests
Expand All @@ -69,9 +69,9 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p sbor-tests
run: cargo nextest run -p sbor-tests --no-fail-fast
- name: Run tests (no_std)
run: cargo nextest run -p sbor-tests --no-default-features --features alloc
run: cargo nextest run -p sbor-tests --no-default-features --features alloc --no-fail-fast
- name: Run bench
run: cargo bench -p sbor-tests

Expand All @@ -83,13 +83,13 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p scrypto
run: cargo nextest run -p scrypto --no-fail-fast
- name: Run tests (no_std)
run: cargo nextest run -p scrypto --no-default-features --features alloc
run: cargo nextest run -p scrypto --no-default-features --features alloc --no-fail-fast
- name: Run abi tests
run: cargo nextest run -p radix-blueprint-schema-init
run: cargo nextest run -p radix-blueprint-schema-init --no-fail-fast
- name: Run derive tests
run: cargo nextest run -p scrypto-derive
run: cargo nextest run -p scrypto-derive --no-fail-fast

scrypto-derive-tests:
name: Run Scrypto derive tests
Expand All @@ -99,9 +99,9 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p scrypto-derive-tests
run: cargo nextest run -p scrypto-derive-tests --no-fail-fast
- name: Run tests with no_std
run: cargo nextest run -p scrypto-derive-tests --no-default-features --features alloc
run: cargo nextest run -p scrypto-derive-tests --no-default-features --features alloc --no-fail-fast

scrypto-examples:
name: Run Scrypto examples
Expand All @@ -113,12 +113,12 @@ jobs:
- name: Build and test hello-world
run: |
cargo build --target wasm32-unknown-unknown --release
cargo nextest run --release
cargo nextest run --release --no-fail-fast
working-directory: examples/hello-world
- name: Build and test everything
run: |
cargo build --target wasm32-unknown-unknown --release
cargo nextest run --release
cargo nextest run --release --no-fail-fast
working-directory: examples/everything
- name: Build no-std
run: cargo build --target wasm32-unknown-unknown --release
Expand Down Expand Up @@ -163,7 +163,8 @@ jobs:
-p radix-sbor-derive \
-p radix-engine-interface \
-p radix-engine \
-p radix-engine-tests
-p radix-engine-tests \
--no-fail-fast
./check_stack_usage.sh

radix-engine-release:
Expand All @@ -186,7 +187,8 @@ jobs:
-p radix-sbor-derive \
-p radix-engine-interface \
-p radix-engine \
-p radix-engine-tests
-p radix-engine-tests \
--no-fail-fast

radix-engine-no-std:
name: Run Radix Engine tests (no_std)
Expand All @@ -204,7 +206,8 @@ jobs:
-p radix-sbor-derive \
-p radix-engine-interface \
-p radix-engine \
-p radix-engine-tests
-p radix-engine-tests \
--no-fail-fast

radix-engine-bench:
name: Run Radix Engine benchmarks
Expand Down Expand Up @@ -236,7 +239,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p radix-transactions
run: cargo nextest run -p radix-transactions --no-fail-fast

radix-transaction-scenarios:
name: Run transaction scenarios
Expand All @@ -246,7 +249,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p radix-transaction-scenarios
run: cargo nextest run -p radix-transaction-scenarios --no-fail-fast

radix-clis:
name: Run CLI tests
Expand All @@ -268,12 +271,12 @@ jobs:
cache-directories: ~/.cargo/registry/src/**/librocksdb-sys-*
workspaces: radix-clis
- name: Run Unit tests
run: cargo nextest run
run: cargo nextest run --no-fail-fast
working-directory: radix-clis
- name: Run tests
- name: Run resim shell tests
run: bash ./tests/resim.sh
working-directory: radix-clis
- name: Run tests
- name: Run manifest shell tests
run: bash ./tests/manifest.sh
working-directory: radix-clis

Expand Down
11 changes: 6 additions & 5 deletions radix-clis/src/replay/cmd_alloc_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use clap::Parser;
use flate2::read::GzDecoder;
use flume;
use radix_common::prelude::*;
use radix_engine::vm::wasm::*;
use radix_engine::vm::ScryptoVm;
use radix_engine::vm::VmModules;
use radix_engine_profiling::info_alloc::*;
use radix_substate_store_impls::rocks_db_with_merkle_tree::RocksDBWithMerkleTreeSubstateStore;
use radix_substate_store_interface::db_key_mapper::SpreadPrefixKeyMapper;
Expand Down Expand Up @@ -118,7 +117,7 @@ impl TxnAllocDump {
);
let trace = self.trace;
let txn_write_thread_handle = thread::spawn(move || {
let scrypto_vm = ScryptoVm::<DefaultWasmEngine>::default();
let vm_modules = VmModules::default();
let iter = rx.iter();
for tx_payload in iter {
let prepared = prepare_ledger_transaction(&tx_payload);
Expand All @@ -128,7 +127,7 @@ impl TxnAllocDump {

let receipt = execute_prepared_ledger_transaction(
&database,
&scrypto_vm,
&vm_modules,
&network,
&prepared,
trace,
Expand All @@ -152,7 +151,9 @@ impl TxnAllocDump {
output,
"user,{},{},{},{},{}",
TransactionHashBech32Encoder::new(&network)
.encode(&IntentHash(tx.signed_intent.intent.summary.hash))
.encode(&TransactionIntentHash(
tx.signed_intent.intent.summary.hash
))
.unwrap(),
execution_cost_units.unwrap(),
heap_allocations_sum,
Expand Down
7 changes: 3 additions & 4 deletions radix-clis/src/replay/cmd_execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use clap::Parser;
use flate2::read::GzDecoder;
use flume;
use radix_common::prelude::*;
use radix_engine::vm::wasm::*;
use radix_engine::vm::ScryptoVm;
use radix_engine::vm::VmModules;
use radix_substate_store_impls::rocks_db_with_merkle_tree::RocksDBWithMerkleTreeSubstateStore;
use radix_substate_store_interface::db_key_mapper::SpreadPrefixKeyMapper;
use radix_substate_store_interface::interface::*;
Expand Down Expand Up @@ -74,12 +73,12 @@ impl TxnExecute {
let mut database = RocksDBWithMerkleTreeSubstateStore::standard(self.database_dir.clone());
let trace = self.trace;
let txn_write_thread_handle = thread::spawn(move || {
let scrypto_vm = ScryptoVm::<DefaultWasmEngine>::default();
let vm_modules = VmModules::default();
let iter = rx.iter();
for tx_payload in iter {
let state_updates = execute_ledger_transaction(
&database,
&scrypto_vm,
&vm_modules,
&network,
&tx_payload,
trace,
Expand Down
7 changes: 3 additions & 4 deletions radix-clis/src/replay/cmd_execute_in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use clap::Parser;
use flate2::read::GzDecoder;
use flume;
use radix_common::prelude::*;
use radix_engine::vm::wasm::*;
use radix_engine::vm::ScryptoVm;
use radix_engine::vm::VmModules;
use radix_substate_store_impls::memory_db::InMemorySubstateDatabase;
use radix_substate_store_impls::state_tree_support::StateTreeUpdatingDatabase;
use radix_substate_store_interface::db_key_mapper::SpreadPrefixKeyMapper;
Expand Down Expand Up @@ -86,12 +85,12 @@ impl TxnExecuteInMemory {
let mut database = StateTreeUpdatingDatabase::new(substate_database);
let trace = self.trace;
let txn_write_thread_handle = thread::spawn(move || {
let scrypto_vm = ScryptoVm::<DefaultWasmEngine>::default();
let vm_modules = VmModules::default();
let iter = rx.iter();
for tx_payload in iter {
let state_updates = execute_ledger_transaction(
&database,
&scrypto_vm,
&vm_modules,
&network,
&tx_payload,
trace,
Expand Down
9 changes: 4 additions & 5 deletions radix-clis/src/replay/cmd_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use clap::Parser;
use flate2::read::GzDecoder;
use flume;
use radix_common::prelude::*;
use radix_engine::vm::wasm::*;
use radix_engine::vm::ScryptoVm;
use radix_engine::vm::*;
use radix_substate_store_impls::rocks_db_with_merkle_tree::RocksDBWithMerkleTreeSubstateStore;
use radix_substate_store_interface::db_key_mapper::SpreadPrefixKeyMapper;
use radix_substate_store_interface::interface::*;
Expand Down Expand Up @@ -94,14 +93,14 @@ impl TxnMeasure {

let trace = self.trace;
let txn_write_thread_handle = thread::spawn(move || {
let scrypto_vm = ScryptoVm::<DefaultWasmEngine>::default();
let vm_modules = VmModules::default();
let iter = rx.iter();
for tx_payload in iter {
let tx_start_time = std::time::Instant::now();
let prepared = prepare_ledger_transaction(&tx_payload);
let receipt = execute_prepared_ledger_transaction(
&database,
&scrypto_vm,
&vm_modules,
&network,
&prepared,
trace,
Expand All @@ -122,7 +121,7 @@ impl TxnMeasure {
output,
"{},{},{},{}",
TransactionHashBech32Encoder::new(&network)
.encode(&IntentHash(tx.signed_intent.intent.summary.hash))
.encode(&TransactionIntentHash(tx.signed_intent.intent.summary.hash))
.unwrap(),
tx_processing_time.as_micros(),
execution_cost_units.unwrap(),
Expand Down
11 changes: 5 additions & 6 deletions radix-clis/src/replay/cmd_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use clap::Parser;
use flume;
use flume::Sender;
use radix_common::prelude::*;
use radix_engine::vm::wasm::*;
use radix_engine::vm::ScryptoVm;
use radix_engine::vm::VmModules;
use radix_substate_store_impls::rocks_db_with_merkle_tree::RocksDBWithMerkleTreeSubstateStore;
use radix_substate_store_interface::db_key_mapper::SpreadPrefixKeyMapper;
use radix_substate_store_interface::interface::*;
Expand Down Expand Up @@ -64,12 +63,12 @@ impl TxnSync {
let mut database = RocksDBWithMerkleTreeSubstateStore::standard(self.database_dir.clone());
let trace = self.trace;
let txn_write_thread_handle = thread::spawn(move || {
let scrypto_vm = ScryptoVm::<DefaultWasmEngine>::default();
let vm_modules = VmModules::default();
let iter = rx.iter();
for (tx_payload, expected_state_root_hash) in iter {
let state_updates = execute_ledger_transaction(
&database,
&scrypto_vm,
&vm_modules,
&network,
&tx_payload,
trace,
Expand Down Expand Up @@ -226,8 +225,8 @@ pub enum TypedTransactionIdentifiers {
system_transaction_hash: SystemTransactionHash,
},
User {
intent_hash: IntentHash,
signed_intent_hash: SignedIntentHash,
intent_hash: TransactionIntentHash,
signed_intent_hash: SignedTransactionIntentHash,
notarized_transaction_hash: NotarizedTransactionHash,
},
RoundUpdateV1 {
Expand Down
24 changes: 7 additions & 17 deletions radix-clis/src/replay/ledger_transaction_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use radix_engine::system::bootstrap::*;
use radix_engine::transaction::{
execute_transaction, ExecutionConfig, TransactionFeeSummary, TransactionReceipt,
};
use radix_engine::vm::wasm::*;
use radix_engine::vm::{NoExtension, ScryptoVm, VmInit};
use radix_engine::vm::*;
use radix_engine_interface::prelude::system_execution;
use radix_substate_store_interface::interface::SubstateDatabase;
use radix_transactions::prelude::*;
Expand Down Expand Up @@ -40,13 +39,13 @@ impl LedgerTransactionReceipt {

pub fn execute_ledger_transaction<S: SubstateDatabase>(
database: &S,
scrypto_vm: &ScryptoVm<DefaultWasmEngine>,
vm_modules: &impl VmInitialize,
network: &NetworkDefinition,
tx_payload: &[u8],
trace: bool,
) -> StateUpdates {
let prepared = prepare_ledger_transaction(tx_payload);
execute_prepared_ledger_transaction(database, scrypto_vm, network, &prepared, trace)
execute_prepared_ledger_transaction(database, vm_modules, network, &prepared, trace)
.into_state_updates()
}

Expand All @@ -61,7 +60,7 @@ pub fn prepare_ledger_transaction(tx_payload: &[u8]) -> PreparedLedgerTransactio

pub fn execute_prepared_ledger_transaction<S: SubstateDatabase>(
database: &S,
scrypto_vm: &ScryptoVm<DefaultWasmEngine>,
vm_modules: &impl VmInitialize,
network: &NetworkDefinition,
prepared: &PreparedLedgerTransaction,
trace: bool,
Expand All @@ -76,10 +75,7 @@ pub fn execute_prepared_ledger_transaction<S: SubstateDatabase>(
PreparedGenesisTransaction::Transaction(tx) => {
let receipt = execute_transaction(
database,
VmInit {
scrypto_vm,
native_vm_extension: NoExtension,
},
vm_modules,
&ExecutionConfig::for_genesis_transaction(network.clone())
.with_kernel_trace(trace)
.with_cost_breakdown(trace),
Expand All @@ -92,10 +88,7 @@ pub fn execute_prepared_ledger_transaction<S: SubstateDatabase>(
PreparedLedgerTransactionInner::UserV1(tx) => {
let receipt = execute_transaction(
database,
VmInit {
scrypto_vm,
native_vm_extension: NoExtension,
},
vm_modules,
&ExecutionConfig::for_notarized_transaction(network.clone())
.with_kernel_trace(trace)
.with_cost_breakdown(trace),
Expand All @@ -109,10 +102,7 @@ pub fn execute_prepared_ledger_transaction<S: SubstateDatabase>(
PreparedLedgerTransactionInner::RoundUpdateV1(tx) => {
let receipt = execute_transaction(
database,
VmInit {
scrypto_vm,
native_vm_extension: NoExtension,
},
vm_modules,
&ExecutionConfig::for_system_transaction(network.clone())
.with_kernel_trace(trace)
.with_cost_breakdown(trace),
Expand Down
1 change: 1 addition & 0 deletions radix-clis/src/resim/cmd_publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use clap::Parser;
use colored::*;
use radix_common::prelude::*;
use radix_engine::blueprints::models::*;
use radix_engine::vm::wasm::ScryptoV1WasmValidator;
use radix_engine::vm::ScryptoVmVersion;
use radix_engine_interface::blueprints::package::{
BlueprintDefinition, BlueprintDependencies, BlueprintPayloadDef, FunctionSchema,
Expand Down
Loading
Loading