Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/casper-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
run: make build-test-artifacts CARGO_FLAGS=--release

- name: archive smart contracts
run: tar -czf smart-contracts.tar.gz resources/local/chainspec.toml target/wasm32-unknown-unknown/release/*.wasm
run: tar -czf smart-contracts.tar.gz resources/local/chainspec.toml target/wasm32v1-none/release/*.wasm

- name: upload smart contracts
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion EVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -1207,4 +1207,4 @@ cargo build -p casper-sidecar
[eip-7702]: https://eips.ethereum.org/EIPS/eip-7702
[eip-7840]: https://eips.ethereum.org/EIPS/eip-7840
[execution-apis]: https://ethereum.github.io/execution-apis/
[geth-pubsub]: https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub
[geth-pubsub]: https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ CARGO = $(or $(shell which cargo), $(HOME)/.cargo/bin/cargo)
RUSTUP = $(or $(shell which rustup), $(HOME)/.cargo/bin/rustup)
CARGO_AUDIT = $(or $(shell which cargo-audit), $(HOME)/.cargo/bin/cargo-audit)

PINNED_NIGHTLY := $(shell cat smart_contracts/rust-toolchain)
PINNED_STABLE := $(shell sed -nr 's/channel *= *\"(.*)\"/\1/p' rust-toolchain.toml)
CARGO_AUDIT_VERSION := 0.22.1
WASM_STRIP_VERSION := $(shell wasm-strip --version)

CARGO_OPTS := --locked
CARGO_PINNED_NIGHTLY := $(CARGO) +$(PINNED_NIGHTLY) $(CARGO_OPTS)
CARGO := $(CARGO) $(CARGO_OPTS)

DISABLE_LOGGING = RUST_LOG=MatchesNothing
Expand All @@ -21,19 +19,22 @@ CLIENT_CONTRACTS = $(shell find ./smart_contracts/contracts/client -mindepth 1 -
EVM_CONTRACTS = $(shell find ./smart_contracts/evm_contracts -mindepth 1 -maxdepth 1 -name '*.sol' -exec basename {} .sol \;)
CARGO_HOME_REMAP = $(if $(CARGO_HOME),$(CARGO_HOME),$(HOME)/.cargo)
RUSTC_FLAGS = "--remap-path-prefix=$(CARGO_HOME_REMAP)=/home/cargo --remap-path-prefix=$$PWD=/dir"
WASM_RUSTC_FLAGS = "--remap-path-prefix=$(CARGO_HOME_REMAP)=/home/cargo --remap-path-prefix=$$PWD=/dir -C target-cpu=mvp -C target-feature=-bulk-memory"
# panic=abort is set explicitly here (rather than via a [profile] in smart_contracts/contract's
# own Cargo.toml) because workspace member manifests can't declare profiles; only the workspace
# root's Cargo.toml can.
WASM_RUSTC_FLAGS = "--remap-path-prefix=$(CARGO_HOME_REMAP)=/home/cargo --remap-path-prefix=$$PWD=/dir -C link-arg=--import-undefined -C panic=abort"
CARGO_TEST_PROFILE_ENV ?=

CONTRACT_TARGET_DIR = target/wasm32-unknown-unknown/release
CONTRACT_TARGET_DIR = target/wasm32v1-none/release
EVM_CONTRACT_TARGET_DIR = target/evm-contracts

build-contract-rs/%:
cd smart_contracts/contracts && RUSTFLAGS=$(WASM_RUSTC_FLAGS) $(CARGO) build --verbose --release -Z build-std=std,core,alloc,panic_abort $(filter-out --release, $(CARGO_FLAGS)) --package $*
cd smart_contracts/contracts && RUSTFLAGS=$(WASM_RUSTC_FLAGS) $(CARGO) build --verbose --release $(filter-out --release, $(CARGO_FLAGS)) --package $*

build-vm2-contract-rs/%:
CMAKE_POLICY_VERSION_MINIMUM=3.5 $(CARGO) build -p cargo-casper --bin cargo-casper
RUSTFLAGS=$(RUSTC_FLAGS) $(CURDIR)/target/debug/cargo-casper build-schema --package $*
cd smart_contracts/contracts/vm2 && RUSTFLAGS=$(WASM_RUSTC_FLAGS) $(CARGO) build --verbose --release -Z build-std=std,core,alloc,panic_abort $(filter-out --release, $(CARGO_FLAGS)) --package $*
cd smart_contracts/contracts/vm2 && RUSTFLAGS=$(WASM_RUSTC_FLAGS) $(CARGO) build --verbose --release $(filter-out --release, $(CARGO_FLAGS)) --package $*

.PHONY: build-vm2-contracts-rs
build-vm2-contracts-rs: $(patsubst %, build-vm2-contract-rs/%, $(VM2_CONTRACTS))
Expand Down Expand Up @@ -134,11 +135,11 @@ check-testing-features:

.PHONY: check-format
check-format:
$(CARGO_PINNED_NIGHTLY) fmt --all -- --check
$(CARGO) fmt --all -- --check

.PHONY: format
format:
$(CARGO_PINNED_NIGHTLY) fmt --all
$(CARGO) fmt --all

lint-contracts-rs:
cd smart_contracts/contracts && $(CARGO) clippy $(patsubst %, -p %, $(ALL_CONTRACTS)) -- -A renamed_and_removed_lints
Expand Down Expand Up @@ -178,8 +179,8 @@ audit: audit-rs

.PHONY: doc
doc:
RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--cfg docsrs" $(CARGO_PINNED_NIGHTLY) doc --all-features $(CARGO_FLAGS) --no-deps
cd smart_contracts/contract && RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--cfg docsrs" $(CARGO_PINNED_NIGHTLY) doc --all-features $(CARGO_FLAGS) --no-deps
RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--cfg docsrs" $(RUSTUP) run nightly $(CARGO) doc --all-features $(CARGO_FLAGS) --no-deps
cd smart_contracts/contract && RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--cfg docsrs" $(RUSTUP) run nightly $(CARGO) doc --all-features $(CARGO_FLAGS) --no-deps

.PHONY: check-rs
check: \
Expand Down Expand Up @@ -223,12 +224,11 @@ setup-cargo-packagers:
.PHONY: setup-rs
setup-rs:
$(RUSTUP) update
$(RUSTUP) toolchain install $(PINNED_STABLE) $(PINNED_NIGHTLY)
$(RUSTUP) target add --toolchain $(PINNED_STABLE) wasm32-unknown-unknown
$(RUSTUP) target add --toolchain $(PINNED_NIGHTLY) wasm32-unknown-unknown
$(RUSTUP) component add --toolchain $(PINNED_NIGHTLY) rustfmt clippy-preview
$(RUSTUP) toolchain install $(PINNED_STABLE) nightly
$(RUSTUP) target add --toolchain $(PINNED_STABLE) wasm32v1-none wasm32-unknown-unknown
$(RUSTUP) component add --toolchain $(PINNED_STABLE) rustfmt clippy-preview
$(RUSTUP) component add --toolchain $(PINNED_STABLE) clippy-preview
$(RUSTUP) component add rust-src --toolchain $(PINNED_NIGHTLY)
$(RUSTUP) component add rust-src --toolchain $(PINNED_STABLE)
$(CARGO_AUDIT) --version 2>/dev/null | grep -q ' $(CARGO_AUDIT_VERSION)$$' || \
$(CARGO) install cargo-audit --version '=$(CARGO_AUDIT_VERSION)'

Expand Down
2 changes: 1 addition & 1 deletion build_wasm_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export RUN_DIR=$(dirname $(abspath $0))
NODE_CONFIG_FILE="$RUN_DIR/node/Cargo.toml"
# have to be sed instead of grep -oP to work in alpine docker image
export WASM_PACKAGE_VERSION="$(grep ^version $NODE_CONFIG_FILE | sed -e s'/.*= "//' | sed -e s'/".*//')"
export CL_WASM_DIR="$RUN_DIR/target/wasm32-unknown-unknown/release"
export CL_WASM_DIR="$RUN_DIR/target/wasm32v1-none/release"
export CL_OUTPUT_S3_DIR="$RUN_DIR/s3_artifacts/${WASM_PACKAGE_VERSION}"
export CL_WASM_PACKAGE="$CL_OUTPUT_S3_DIR/casper-contracts.tar.gz"
export CL_S3_BUCKET='casperlabs-cicd-artifacts'
Expand Down
9 changes: 3 additions & 6 deletions cargo_casper/src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn build_impl(
output_dir: Option<PathBuf>,
embed_schema: bool,
) -> Result<(), anyhow::Error> {
// Build the contract package targetting wasm32-unknown-unknown without
// Build the contract package targetting wasm32v1-none without
// extra feature flags - this is the production contract wasm file.
//
// Optionally (but by default) create an entrypoint in the wasm that will have
Expand All @@ -31,10 +31,7 @@ pub fn build_impl(
None,
vec![("__CARGO_CASPER_INJECT_SCHEMA_MARKER", &contract_schema)],
)
.dispatch(
"wasm32-unknown-unknown",
["casper-contract-sdk/__embed_schema"],
)
.dispatch("wasm32v1-none", ["casper-contract-sdk/__embed_schema"])
.context("Failed to compile user wasm")?
.get_artifact_by_extension("wasm")
.context("Build artifacts for contract wasm didn't include a wasm file")?;
Expand All @@ -53,7 +50,7 @@ pub fn build_impl(
// Compile and move to specified output directory
eprintln!("🔨 Step 2: Building contract...");
CompileJob::new(package_name, None, vec![])
.dispatch("wasm32-unknown-unknown", Option::<String>::None)
.dispatch("wasm32v1-none", Option::<String>::None)
.context("Failed to compile user wasm")?
.get_artifact_by_extension("wasm")
.context("Failed extracting build artifacts to directory")?
Expand Down
2 changes: 1 addition & 1 deletion ci/nctl_upgrade_stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function clean_up() {
# DIRECTORIES
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd)"
BIN_BUILD_DIR="$ROOT_DIR/target/release"
WASM_BUILD_DIR="$ROOT_DIR/target/wasm32-unknown-unknown/release"
WASM_BUILD_DIR="$ROOT_DIR/target/wasm32v1-none/release"
CONFIG_DIR="$ROOT_DIR/resources/local"
TEMP_STAGE_DIR='/tmp/nctl_upgrade_stage'

Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/bin/run_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn run_wasm(
"Not enough arguments supplied"
);
let mut vec = Vec::new();
for (input_arg, func_arg) in cli_args.args.iter().zip(params.into_iter()) {
for (input_arg, func_arg) in cli_args.args.iter().zip(params) {
let value = match func_arg {
casper_wasmi::ValueType::I32 => {
casper_wasmi::RuntimeValue::I32(input_arg.parse().unwrap())
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
trivial_numeric_casts,
unused_qualifications
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod engine_state;
pub mod execution;
Expand Down
2 changes: 1 addition & 1 deletion execution_engine/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4199,7 +4199,7 @@ where
}

// Remove group if it is not referenced by at least one entry_point in active versions.
for (_version, contract_hash) in contract_package.versions().iter() {
for contract_hash in contract_package.versions().values() {
let entry_points = {
self.context
.get_casper_vm_v1_entry_point(Key::contract_entity_key(
Expand Down
14 changes: 6 additions & 8 deletions execution_engine_testing/test_support/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ static RUST_WORKSPACE_PATH: Lazy<PathBuf> = Lazy::new(|| {
path.to_path_buf()
});
// The location of compiled Wasm files if compiled from the Rust sources within the casper-node
// repo, i.e. 'casper-node/target/wasm32-unknown-unknown/release/'.
// repo, i.e. 'casper-node/target/wasm32v1-none/release/'.
static RUST_WORKSPACE_WASM_PATH: Lazy<PathBuf> = Lazy::new(|| {
let path = RUST_WORKSPACE_PATH
.join("target")
.join("wasm32-unknown-unknown")
.join("wasm32v1-none")
.join("release");
assert!(
path.exists() || RUST_TOOL_WASM_PATH.exists(),
Expand All @@ -54,14 +54,12 @@ static RUST_TOOL_WASM_PATH: Lazy<PathBuf> = Lazy::new(|| {
});
// The location of compiled Wasm files if compiled from the Rust sources within the casper-node
// repo where `CARGO_TARGET_DIR` is set, i.e.
// '<CARGO_TARGET_DIR>/wasm32-unknown-unknown/release/'.
// '<CARGO_TARGET_DIR>/wasm32v1-none/release/'.
static MAYBE_CARGO_TARGET_DIR_WASM_PATH: Lazy<Option<PathBuf>> = Lazy::new(|| {
let maybe_target = std::env::var("CARGO_TARGET_DIR").ok();
maybe_target.as_ref().map(|path| {
Path::new(path)
.join("wasm32-unknown-unknown")
.join("release")
})
maybe_target
.as_ref()
.map(|path| Path::new(path).join("wasm32v1-none").join("release"))
});
static WASM_PATHS: Lazy<Vec<PathBuf>> = Lazy::new(get_compiled_wasm_paths);

Expand Down
4 changes: 2 additions & 2 deletions execution_engine_testing/tests/src/test/counter_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn should_not_call_undefined_entrypoints_on_factory() {
assert!(
matches!(&no_such_method_2, Error::Exec(ExecError::TemplateMethod(function_name)) if function_name == INCREASE_ENTRY_POINT),
"{:?}",
&no_such_method_2
no_such_method_2
);

// Can't call abstract entry point "decrease" on the factory.
Expand All @@ -78,7 +78,7 @@ fn should_not_call_undefined_entrypoints_on_factory() {
assert!(
matches!(&no_such_method_3, Error::Exec(ExecError::TemplateMethod(function_name)) if function_name == DECREASE_ENTRY_POINT),
"{:?}",
&no_such_method_3
no_such_method_3
);
}

Expand Down
8 changes: 4 additions & 4 deletions execution_engine_testing/tests/src/test/explorer/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,14 @@ fn faucet_costs() {
// This test will fail if execution costs vary. The expected costs should not be updated
// without understanding why the cost has changed. If the costs do change, it should be
// reflected in the "Costs by Entry Point" section of the faucet crate's README.md.
const EXPECTED_FAUCET_INSTALL_COST: u64 = 118_807_845_390;
const EXPECTED_FAUCET_INSTALL_COST: u64 = 111_710_366_947;
const EXPECTED_FAUCET_INSTALL_COST_ALT: u64 = 149_230_872_143;

const EXPECTED_FAUCET_SET_VARIABLES_COST: u64 = 79_790_440;
const EXPECTED_FAUCET_SET_VARIABLES_COST: u64 = 78_044_800;

const EXPECTED_FAUCET_CALL_BY_INSTALLER_COST: u64 = 2_652_954_573;
const EXPECTED_FAUCET_CALL_BY_INSTALLER_COST: u64 = 2_651_525_838;

const EXPECTED_FAUCET_CALL_BY_USER_COST: u64 = 2_558_820_996;
const EXPECTED_FAUCET_CALL_BY_USER_COST: u64 = 2_557_179_771;

let installer_account = AccountHash::new([1u8; 32]);
let user_account: AccountHash = AccountHash::new([2u8; 32]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ fn invalid_transfer_wasmless(invalid_wasmless_transfer: InvalidWasmlessTransfer)
let account_1_closing_balance = builder.get_purse_balance(account_1_purse);

assert_eq!(
format!("{}", &expected_error),
format!("{}", expected_error),
format!("{}", error),
"expected_error: {} actual error: {}",
expected_error,
Expand Down
2 changes: 1 addition & 1 deletion executor/wasm/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static RUST_WORKSPACE_PATH: Lazy<PathBuf> = Lazy::new(|| {
static RUST_WORKSPACE_WASM_PATH: Lazy<PathBuf> = Lazy::new(|| {
let path = RUST_WORKSPACE_PATH
.join("target")
.join("wasm32-unknown-unknown")
.join("wasm32v1-none")
.join("release");
assert!(
path.exists() || RUST_TOOL_WASM_PATH.exists(),
Expand Down
2 changes: 1 addition & 1 deletion node/src/components/binary_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ where
.try_accept_transaction(transaction)
.await
.map_or_else(
|err| BinaryResponse::new_error(err.into()),
|err| BinaryResponse::new_error((*err).into()),
|()| BinaryResponse::new_empty(),
)
}
Expand Down
1 change: 0 additions & 1 deletion node/src/components/block_accumulator/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use thiserror::Error;
use tracing::error;

use casper_types::{crypto, BlockHash, BlockValidationError, EraId};

Expand Down
8 changes: 4 additions & 4 deletions node/src/components/block_accumulator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,10 @@ fn accumulator_purge() {
// Change the timestamps to old ones so that all blocks would normally
// get purged.
let last_progress = time_before_insertion.saturating_sub(purge_interval * 10);
for (_, acceptor) in block_accumulator.block_acceptors.iter_mut() {
for acceptor in block_accumulator.block_acceptors.values_mut() {
acceptor.set_last_progress(last_progress);
}
for (_, timestamps) in block_accumulator.peer_block_timestamps.iter_mut() {
for timestamps in block_accumulator.peer_block_timestamps.values_mut() {
for (_, timestamp) in timestamps.iter_mut() {
*timestamp = last_progress;
}
Expand Down Expand Up @@ -1544,10 +1544,10 @@ fn accumulator_purge() {
// Change the timestamps to old ones so that all blocks would normally
// get purged.
let last_progress = time_before_insertion.saturating_sub(purge_interval * 10);
for (_, acceptor) in block_accumulator.block_acceptors.iter_mut() {
for acceptor in block_accumulator.block_acceptors.values_mut() {
acceptor.set_last_progress(last_progress);
}
for (_, timestamps) in block_accumulator.peer_block_timestamps.iter_mut() {
for timestamps in block_accumulator.peer_block_timestamps.values_mut() {
for (_, timestamp) in timestamps.iter_mut() {
*timestamp = last_progress;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ impl GlobalStateSynchronizer {
self.tries_awaiting_children = still_incomplete;

let mut effects: Effects<Event> = ready_tries
.into_iter()
.flat_map(|(_, trie_awaiting)| {
.into_values()
.flat_map(|trie_awaiting| {
let trie_raw = trie_awaiting.into_trie_raw();
let request = PutTrieRequest::new(trie_raw.clone());
effect_builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ mod test_harness {
v.finalized_values().cloned().collect::<Vec<_>>(),
v.messages_produced()
.filter(|&hwm| hwm.is_new_unit())
.cloned()
.count(),
)
})
Expand Down
1 change: 0 additions & 1 deletion node/src/components/consensus/protocols/zug/des_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ mod test_harness {
v.finalized_values().cloned().collect::<Vec<_>>(),
v.messages_produced()
.filter(|&zm| zm.is_signed_gossip_message() || zm.is_proposal())
.cloned()
.count(),
)
})
Expand Down
5 changes: 1 addition & 4 deletions node/src/components/contract_runtime/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,7 @@ pub(crate) async fn fetch_data_and_calculate_rewards_for_era<REv: ReactorEventT>
actual_total_seigniorage.low_u128(),
expected_total_seigniorage.low_u128(),
);
let gauge_value = match Ratio::to_f64(&seigniorage_target_fraction) {
Some(v) => v,
None => f64::NAN,
};
let gauge_value = Ratio::to_f64(&seigniorage_target_fraction).unwrap_or(f64::NAN);
metrics.seigniorage_target_fraction.set(gauge_value)
}

Expand Down
2 changes: 1 addition & 1 deletion node/src/components/contract_runtime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ fn valid_wasm_txn(
let contract_file = RESOURCES_PATH
.join("..")
.join("target")
.join("wasm32-unknown-unknown")
.join("wasm32v1-none")
.join("release")
.join(format!("{name}.wasm"));
let module_bytes = Bytes::from(std::fs::read(contract_file).expect("cannot read module bytes"));
Expand Down
2 changes: 1 addition & 1 deletion node/src/components/diagnostics_port/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Command {
pub(super) fn from_line(line: &str) -> Result<Self, Error> {
let mut parts = vec!["casper-diagnostics-port".to_owned()];
parts.extend(shlex::split(line).ok_or(Error::ShlexFailure)?);
Ok(Self::from_iter_safe(parts.into_iter())?)
Ok(Self::from_iter_safe(parts)?)
}
}

Expand Down
1 change: 0 additions & 1 deletion node/src/components/fetcher/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use datasize::DataSize;
use serde::Serialize;
use thiserror::Error;
use tracing::error;

use crate::{components::fetcher::FetchItem, types::NodeId};

Expand Down
1 change: 0 additions & 1 deletion node/src/components/storage/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{fmt::Debug, io, path::PathBuf};

use casper_binary_port::RecordId;
use thiserror::Error;
use tracing::error;

use casper_types::{
bytesrepr, crypto, BlockBody, BlockHash, BlockHeader, BlockValidationError, DeployHash, Digest,
Expand Down
Loading
Loading