diff --git a/binary_port/src/payload_type.rs b/binary_port/src/payload_type.rs index 73f0fc18fd..5e535e6ffa 100644 --- a/binary_port/src/payload_type.rs +++ b/binary_port/src/payload_type.rs @@ -277,11 +277,11 @@ const NEXT_UPGRADE_TAG: u8 = 25; const CONSENSUS_STATUS_TAG: u8 = 26; const CHAINSPEC_RAW_BYTES_TAG: u8 = 27; const HIGHEST_BLOCK_SEQUENCE_CHECK_RESULT_TAG: u8 = 28; -const SPECULATIVE_EXECUTION_RESULT_TAG: u8 = 29; -const GLOBAL_STATE_QUERY_RESULT_TAG: u8 = 30; -const STORED_VALUES_TAG: u8 = 31; -const GET_TRIE_FULL_RESULT_TAG: u8 = 32; -const NODE_STATUS_TAG: u8 = 33; +const GLOBAL_STATE_QUERY_RESULT_TAG: u8 = 29; +const STORED_VALUES_TAG: u8 = 30; +const GET_TRIE_FULL_RESULT_TAG: u8 = 31; +const NODE_STATUS_TAG: u8 = 32; +const SPECULATIVE_EXECUTION_RESULT_TAG: u8 = 33; const WASM_V1_RESULT_TAG: u8 = 34; impl ToBytes for PayloadType { diff --git a/node/src/components/binary_port/tests.rs b/node/src/components/binary_port/tests.rs index 933e26925e..b2ca2ebf54 100644 --- a/node/src/components/binary_port/tests.rs +++ b/node/src/components/binary_port/tests.rs @@ -316,7 +316,8 @@ impl From for Event { } impl From for Event { - fn from(_request: StorageRequest) -> Self { + fn from(request: StorageRequest) -> Self { + println!("{}", request); unreachable!() } } diff --git a/node/src/components/block_synchronizer.rs b/node/src/components/block_synchronizer.rs index 8d1c6b3a68..cbf7a1d76b 100644 --- a/node/src/components/block_synchronizer.rs +++ b/node/src/components/block_synchronizer.rs @@ -1141,7 +1141,7 @@ impl BlockSynchronizer { } }; return effect_builder - .put_execution_results_to_storage( + .put_execution_artifacts_to_storage( block_hash, block_height, era_id, diff --git a/node/src/components/contract_runtime/utils.rs b/node/src/components/contract_runtime/utils.rs index 5d1856c4dd..f8591a0bde 100644 --- a/node/src/components/contract_runtime/utils.rs +++ b/node/src/components/contract_runtime/utils.rs @@ -13,12 +13,14 @@ use crate::{ fatal, types::{ExecutableBlock, MetaBlock, MetaBlockState}, }; + use casper_execution_engine::engine_state::ExecutionEngineV1; use casper_storage::{ data_access_layer::DataAccessLayer, global_state::state::lmdb::LmdbGlobalState, }; use casper_types::{Chainspec, EraId, Key}; use once_cell::sync::Lazy; +use std::fmt::Debug; use std::{ cmp, collections::{BTreeMap, HashMap}, @@ -43,13 +45,18 @@ static INTENSIVE_TASKS_SEMAPHORE: Lazy = pub(super) async fn run_intensive_task(task: T) -> V where T: 'static + Send + FnOnce() -> V, - V: 'static + Send, + V: 'static + Send + Debug, { // This will never panic since the semaphore is never closed. let _permit = INTENSIVE_TASKS_SEMAPHORE.acquire().await.unwrap(); - tokio::task::spawn_blocking(task) - .await - .expect("task panicked") + let result = tokio::task::spawn_blocking(task).await; + match result { + Ok(ret) => ret, + Err(err) => { + error!("{:?}", err); + panic!("intensive contract runtime task errored: {:?}", err); + } + } } #[allow(clippy::too_many_arguments)] @@ -102,8 +109,8 @@ pub(super) async fn exec_or_requeue( let BlockAndExecutionArtifacts { block, approvals_hashes, - execution_artifacts: execution_results, - step_outcome: maybe_step_effects_and_upcoming_era_validators, + execution_artifacts, + step_outcome: maybe_step_outcome, } = match run_intensive_task(move || { debug!("ContractRuntime: execute_finalized_block"); execute_finalized_block( @@ -118,7 +125,7 @@ pub(super) async fn exec_or_requeue( }) .await { - Ok(block_and_execution_results) => block_and_execution_results, + Ok(ret) => ret, Err(error) => { error!(%error, "failed to execute block"); return fatal!(effect_builder, "{}", error).await; @@ -152,7 +159,7 @@ pub(super) async fn exec_or_requeue( if let Some(StepOutcome { step_effects, mut upcoming_era_validators, - }) = maybe_step_effects_and_upcoming_era_validators + }) = maybe_step_outcome { effect_builder .announce_commit_step_success(current_era_id, step_effects) @@ -185,29 +192,26 @@ pub(super) async fn exec_or_requeue( "executed block" ); - let execution_results_map: HashMap<_, _> = execution_results + let artifacts_map: HashMap<_, _> = execution_artifacts .iter() .cloned() .map(|artifact| (artifact.transaction_hash, artifact.execution_result)) .collect(); + if meta_block_state.register_as_stored().was_updated() { effect_builder - .put_executed_block_to_storage( - Arc::clone(&block), - approvals_hashes, - execution_results_map, - ) + .put_executed_block_to_storage(Arc::clone(&block), approvals_hashes, artifacts_map) .await; } else { effect_builder .put_approvals_hashes_to_storage(approvals_hashes) .await; effect_builder - .put_execution_results_to_storage( + .put_execution_artifacts_to_storage( *block.hash(), block.height(), block.era_id(), - execution_results_map, + artifacts_map, ) .await; } @@ -223,7 +227,7 @@ pub(super) async fn exec_or_requeue( ); } - let meta_block = MetaBlock::new_forward(block, execution_results, meta_block_state); + let meta_block = MetaBlock::new_forward(block, execution_artifacts, meta_block_state); effect_builder.announce_meta_block(meta_block).await; // If the child is already finalized, start execution. diff --git a/node/src/effect.rs b/node/src/effect.rs index 076fea94d4..c6ae7e57e5 100644 --- a/node/src/effect.rs +++ b/node/src/effect.rs @@ -1627,7 +1627,7 @@ impl EffectBuilder { /// Stores the given execution results for the transactions in the given block in the linear /// block store. - pub(crate) async fn put_execution_results_to_storage( + pub(crate) async fn put_execution_artifacts_to_storage( self, block_hash: BlockHash, block_height: u64, diff --git a/storage/src/global_state/state/mod.rs b/storage/src/global_state/state/mod.rs index d39050e7ac..612c5a1ad0 100644 --- a/storage/src/global_state/state/mod.rs +++ b/storage/src/global_state/state/mod.rs @@ -279,7 +279,7 @@ pub trait CommitProvider: StateProvider { } }; - crate::system::runtime_native::Id::Seed(bytes) + Id::Seed(bytes) }; let config = request.config(); @@ -376,7 +376,7 @@ pub trait CommitProvider: StateProvider { } }; - crate::system::runtime_native::Id::Seed(bytes) + Id::Seed(bytes) }; // this runtime uses the system's context @@ -540,7 +540,7 @@ pub trait CommitProvider: StateProvider { } }; - crate::system::runtime_native::Id::Seed(bytes) + Id::Seed(bytes) }; let config = request.config(); @@ -1376,7 +1376,7 @@ pub trait StateProvider { } }; - let id = crate::system::runtime_native::Id::Transaction(request.transaction_hash()); + let id = Id::Transaction(request.transaction_hash()); // IMPORTANT: this runtime _must_ use the payer's context. let mut runtime = RuntimeNative::new( protocol_version, diff --git a/storage/src/system/mint/mint_native.rs b/storage/src/system/mint/mint_native.rs index acd506e8d8..1b1aba9d04 100644 --- a/storage/src/system/mint/mint_native.rs +++ b/storage/src/system/mint/mint_native.rs @@ -219,7 +219,9 @@ where } let transaction_hash = match self.id() { Id::Transaction(transaction_hash) => *transaction_hash, - Id::Seed(_) => return Err(Error::RecordTransferFailure), + // we don't write transfer records for systemic transfers (step, fees, rewards, etc) + // so return Ok and move on. + Id::Seed(_) => return Ok(()), }; let transfer_addr = TransferAddr::new(self.address_generator().create_address());