Skip to content

Commit

Permalink
Revert "Reapply "add risc0 receipt verifier host function""
Browse files Browse the repository at this point in the history
This reverts commit 1f38455.
  • Loading branch information
jonas089 committed Apr 29, 2024
1 parent 1f38455 commit 29479cf
Show file tree
Hide file tree
Showing 97 changed files with 2,604 additions and 5,819 deletions.
1,945 changes: 1,051 additions & 894 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"utils/global-state-update-gen",
"utils/validation",
"utils/highway-rewards-analysis",
"utils/highway-state-grapher",
]

default-members = [
Expand All @@ -27,6 +28,7 @@ default-members = [
"utils/global-state-update-gen",
"utils/validation",
"utils/highway-rewards-analysis",
"utils/highway-state-grapher",
]

exclude = ["utils/nctl/remotes/casper-client-rs"]
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ test: test-rs-no-default-features test-rs test-as

.PHONY: test-contracts-rs
test-contracts-rs: build-contracts-rs
$(DISABLE_LOGGING) $(CARGO) test $(CARGO_FLAGS) -p casper-engine-tests -- --ignored --skip repeated_ffi_call_should_gas_out_quickly

.PHONY: test-contracts-timings
test-contracts-timings: build-contracts-rs
$(DISABLE_LOGGING) $(CARGO) test --release $(filter-out --release, $(CARGO_FLAGS)) -p casper-engine-tests -- --ignored --test-threads=1 repeated_ffi_call_should_gas_out_quickly
$(DISABLE_LOGGING) $(CARGO) test $(CARGO_FLAGS) -p casper-engine-tests -- --ignored

.PHONY: test-contracts-as
test-contracts-as: build-contracts-rs build-contracts-as
Expand All @@ -105,6 +101,10 @@ test-contracts-as: build-contracts-rs build-contracts-as
.PHONY: test-contracts
test-contracts: test-contracts-rs

.PHONY: check-no-default-features
check-no-default-features:
cd types && $(CARGO) check --all-targets --no-default-features

.PHONY: check-std-features
check-std-features:
cd types && $(CARGO) check --all-targets --no-default-features --features=std
Expand Down Expand Up @@ -161,6 +161,7 @@ check-rs: \
doc \
lint \
audit \
check-no-default-features \
check-std-features \
test-rs \
test-rs-no-default-features \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# casper-node

This is the core application for the Casper blockchain.
Reference node for the Casper Blockchain Protocol.

## Casper Blockchain

Expand Down
15 changes: 0 additions & 15 deletions execution_engine/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ All notable changes to this project will be documented in this file. The format
[comment]: <> (Fixed: any bug fixes)
[comment]: <> (Security: in case of vulnerabilities)

## 7.0.1

### Changed
* Change the cost of `wasm.storage_costs.gas_per_byte` and `shared::storage_costs::DEFAULT_GAS_PER_BYTE_COST` from `630_000` to `1_117_587`.
* Change the cost of the host function `casper_add_associated_key` from `9_000` to `1_200_000`.
* Change the cost of the argument `entry_points_size` of host function `casper_add_contract_version` from `0` to `120_000`.
* Change the cost of the host function `casper_blake2b`and its argument `in_size` from `200` and `0` respectively to `1_200_000` to `120_000`.
* Change the cost of the host function `casper_call_contract` and its arguments `entry_point_name_size` and `runtime_args_size` from `4_500`, `0` and `420` respectively to `300_000_000`, `120_000` and `120_000`.
* Change the cost of the host function `casper_call_versioned_contract` and the arguments `entry_point_name_size` and `runtime_args_size` from `4_500`, `0` and `420` respectively to `300_000_000`, `120_000` and `120_000`.
* Change the cost of the host function `casper_get_balance` from `3_800` to `3_000_000`.
* Change the cost of arguments `name_size` and `dest_size` of host function `casper_get_named_arg` from `0` to `120_000`.
* Change the cost of the host function `casper_put_key` and its arguments `name_size` and `key_size` from `38_000`, `1_100` and `0` respectively to `100_000_000`, `120_000` and `120_000`.
* Change the cost of the host function `casper_read_value` and its argument `key_size` from `6_000` and `0` respectively to `60_000` and `120_000`.
* Change the cost of the argument `urefs_size` of host function `casper_remove_contract_user_group_urefs` from `0` to `120_000`.
* Change the cost of the host function `casper_transfer_from_purse_to_purse` from `82_000` to `82_000_000`.



Expand Down
7 changes: 2 additions & 5 deletions execution_engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "casper-execution-engine"
version = "7.0.1" # when updating, also update 'html_root_url' in lib.rs
version = "7.0.0" # when updating, also update 'html_root_url' in lib.rs
authors = ["Henry Till <[email protected]>", "Ed Hastings <[email protected]>"]
edition = "2021"
description = "Casper execution engine crates."
Expand All @@ -13,7 +13,7 @@ license = "Apache-2.0"
[dependencies]
anyhow = "1.0.33"
base16 = "0.2.1"
#bincode = "1.3.1"
bincode = "1.3.1"
casper-hashing = { version = "3.0.0", path = "../hashing" }
casper-types = { version = "4.0.1", path = "../types", default-features = false, features = ["datasize", "gens", "json-schema"] }
casper-wasm = { version = "0.46.0", default-features = false }
Expand Down Expand Up @@ -48,9 +48,6 @@ thiserror = "1.0.18"
tracing = "0.1.18"
uint = "0.9.0"
uuid = { version = "0.8.1", features = ["serde", "v4"] }
risc0-zkvm = { version="0.21.0" }
kairos-risc0-types = { path="../kairos-risc0-types" }
bincode = "1.3.3"

[dev-dependencies]
assert_matches = "1.3.0"
Expand Down
6 changes: 0 additions & 6 deletions execution_engine/src/core/engine_state/engine_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,6 @@ impl EngineConfig {
pub fn fee_handling(&self) -> FeeHandling {
self.fee_handling
}

/// Sets the `wasm_config.max_memory` to `new_value`.
#[cfg(feature = "test-support")]
pub fn set_max_memory(&mut self, new_value: u32) {
self.wasm_config.max_memory = new_value;
}
}

/// A builder for an [`EngineConfig`].
Expand Down
1 change: 0 additions & 1 deletion execution_engine/src/core/resolvers/v1_function_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pub(crate) enum FunctionIndex {
RandomBytes,
DictionaryReadFuncIndex,
EnableContractVersion,
RiscZeroVerifier
}

impl From<FunctionIndex> for usize {
Expand Down
4 changes: 0 additions & 4 deletions execution_engine/src/core/resolvers/v1_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ impl ModuleImportResolver for RuntimeModuleImportResolver {
Signature::new(&[ValueType::I32; 4][..], Some(ValueType::I32)),
FunctionIndex::EnableContractVersion.into(),
),
"casper_risc_zero_verifier" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 4][..], Some(ValueType::I32)),
FunctionIndex::RiscZeroVerifier.into(),
),
_ => {
return Err(InterpreterError::Function(format!(
"host module doesn't export function with name {}",
Expand Down
41 changes: 6 additions & 35 deletions execution_engine/src/core/runtime/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use casper_types::{

use super::{args::Args, Error, Runtime};
use crate::{
core::{resolvers::v1_function_index::FunctionIndex, runtime::risc0_verifier},
shared::host_function_costs::{Cost, HostFunction},
core::resolvers::v1_function_index::FunctionIndex,
shared::host_function_costs::{Cost, HostFunction, DEFAULT_HOST_FUNCTION_NEW_DICTIONARY},
storage::global_state::StateReader,
};

Expand Down Expand Up @@ -562,9 +562,6 @@ where
existing_urefs_size,
output_size_ptr,
) = Args::parse(args)?;

// TODO - use `num_new_urefs` * costs for unit uref, assuming these aren't
// already charged.
self.charge_host_function_call(
&host_function_costs.create_contract_user_group,
[
Expand Down Expand Up @@ -840,7 +837,6 @@ where
// args(4) = output of size value of host bytes data
let (package_ptr, package_size, label_ptr, label_size, value_size_ptr) =
Args::parse(args)?;
// TODO - add cost for 1x unit uref, assuming this isn't already charged
self.charge_host_function_call(
&host_function_costs.provision_contract_user_group_uref,
[
Expand Down Expand Up @@ -958,9 +954,10 @@ where
// args(0) = pointer to output size (output param)
let (output_size_ptr,): (u32,) = Args::parse(args)?;

// TODO - dynamically calculate the size of the new data. Currently using
// hard-coded 33 which is correct as of now.
self.charge_host_function_call(&host_function_costs.new_uref, [0, 0, 33])?;
self.charge_host_function_call(
&DEFAULT_HOST_FUNCTION_NEW_DICTIONARY,
[output_size_ptr],
)?;
let ret = self.new_dictionary(output_size_ptr)?;
Ok(Some(RuntimeValue::I32(api_error::i32_from(ret))))
}
Expand Down Expand Up @@ -1100,32 +1097,6 @@ where

Ok(Some(RuntimeValue::I32(api_error::i32_from(result))))
}
FunctionIndex::RiscZeroVerifier => {
let (
proof_ptr,
proof_size,
out_ptr,
out_size
) =
Args::parse(args)?;
self.charge_host_function_call(
&host_function_costs.risc0_verifier,
[
proof_ptr,
proof_size,
out_ptr,
out_size
]
)?;
let result: [u8; 1] =
self.checked_memory_slice(proof_ptr as usize, proof_size as usize, |proof| {
risc0_verifier::verify(proof)
})?;
self.try_get_memory().unwrap()
.set(out_ptr, &result)
.map_err(|error| Error::Interpreter(error.into()))?;
Ok(Some(RuntimeValue::I32(0)))
}
}
}
}
1 change: 0 additions & 1 deletion execution_engine/src/core/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod handle_payment_internal;
mod host_function_flag;
mod mint_internal;
pub mod stack;
pub mod risc0_verifier;
mod standard_payment_internal;
mod utils;

Expand Down
17 changes: 0 additions & 17 deletions execution_engine/src/core/runtime/risc0_verifier.rs

This file was deleted.

2 changes: 1 addition & 1 deletion execution_engine/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The engine which executes smart contracts on the Casper network.
#![doc(html_root_url = "https://docs.rs/casper-execution-engine/7.0.1")]
#![doc(html_root_url = "https://docs.rs/casper-execution-engine/7.0.0")]
#![doc(
html_favicon_url = "https://raw.githubusercontent.com/casper-network/casper-node/blob/dev/images/Casper_Logo_Favicon_48.png",
html_logo_url = "https://raw.githubusercontent.com/casper-network/casper-node/blob/dev/images/Casper_Logo_Favicon.png",
Expand Down
Loading

0 comments on commit 29479cf

Please sign in to comment.