Skip to content

Commit

Permalink
Protocol 21 (stellar#1384)
Browse files Browse the repository at this point in the history
This is now ready to merge. Does the following:

- [x] take new XDR from
stellar/rs-stellar-xdr#359
  - [x] bump current protocol 20->21 and next 21->22 
- [x] remove `feature="next"` gates guarding protocol 21 functionality
(note: this is not _all_ `feature="next"` gates, some test the very
concept of next-ness and should remain)
  - [ ] defer to next PR: ~bump workspace version to 21.0.0~
  - [ ] defer to next PR: ~remove `feature="unstable-next-api"` gates~
  - [x] run observations for protocol 21
- [x] modify CI to run tests twice, once with TEST_PROTOCOL=20 and once
with TEST_PROTOCOL=21
- [x] modify recent VMCaller-using secp256r1 tests to go through the env
now that it supports those host functions
  - [x] fix all tests broken by the above

---------

Co-authored-by: Dmytro Kozhevin <[email protected]>
  • Loading branch information
graydon and dmkozh authored Apr 11, 2024
1 parent a8c713d commit 9f23da3
Show file tree
Hide file tree
Showing 527 changed files with 158,527 additions and 658 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
strategy:
matrix:
rust: [msrv, latest]
test-protocol: [20, 21]
sys:
- os: ubuntu-latest
target: wasm32-unknown-unknown
Expand Down Expand Up @@ -115,6 +116,8 @@ jobs:
- run: cargo hack --each-feature clippy --locked --target ${{ matrix.sys.target }}
- if: matrix.sys.test
run: cargo hack --each-feature test --profile test-opt --locked --target ${{ matrix.sys.target }}
env:
TEST_PROTOCOL: ${{ matrix.test-protocol }}

publish-dry-run:
if: github.event_name == 'push' || startsWith(github.head_ref, 'release/')
Expand Down
19 changes: 16 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ wasmparser = "=0.116.1"
[workspace.dependencies.stellar-xdr]
version = "=20.1.0"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "3a001b1fbb20e4cfa2cef2c0cc450564e8528057"
rev = "a80c899c61e869fd00b7b475a4947ab6aaf9dcac"
default-features = false

[workspace.dependencies.wasmi]
Expand Down
8 changes: 6 additions & 2 deletions soroban-env-common/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub const ENV_META_V0_SECTION_NAME: &str = "contractenvmetav0";
// protocol number for testing purposes.
#[cfg(feature = "next")]
soroban_env_macros::generate_env_meta_consts!(
ledger_protocol_version: 21,
ledger_protocol_version: 22,
pre_release_version: 1,
);

Expand All @@ -57,10 +57,14 @@ soroban_env_macros::generate_env_meta_consts!(
// network protocol number.
#[cfg(not(feature = "next"))]
soroban_env_macros::generate_env_meta_consts!(
ledger_protocol_version: 20,
ledger_protocol_version: 21,
pre_release_version: 0,
);

pub const fn make_interface_version(protocol_version: u32, pre_release_version: u32) -> u64 {
((protocol_version as u64) << 32) | (pre_release_version as u64)
}

pub const fn get_ledger_protocol_version(interface_version: u64) -> u32 {
// The ledger protocol version is the high 32 bits of INTERFACE_VERSION
(interface_version >> 32) as u32
Expand Down
6 changes: 6 additions & 0 deletions soroban-env-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,11 @@ bench = true
name = "variation_histograms"
path = "benches/variation_histograms.rs"

[[test]]
name = "secp256r1_sig_ver"
path = "tests/secp256r1_sig_ver.rs"
required-features = ["testutils"]


[package.metadata.docs.rs]
features = ["recording_mode", "tracy", "testutils"]

This file was deleted.

10 changes: 0 additions & 10 deletions soroban-env-host/benches/common/cost_types/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#[cfg(not(feature = "next"))]
mod compute_ecdsa_secp256k1_sig;
mod compute_ed25519_pubkey;
mod compute_keccak256_hash;
mod compute_sha256_hash;
#[cfg(feature = "next")]
mod decode_ecdsa_curve256_sig;
mod host_mem_alloc;
mod host_mem_cmp;
Expand All @@ -12,23 +9,18 @@ mod invoke;
mod num_ops;
mod prng;
mod recover_ecdsa_secp256k1_key;
#[cfg(feature = "next")]
mod sec1_decode_point_uncompressed;
mod val_deser;
mod val_ser;
#[cfg(feature = "next")]
mod verify_ecdsa_secp256r1_sig;
mod verify_ed25519_sig;
mod visit_object;
mod vm_ops;
mod wasm_insn_exec;

#[cfg(not(feature = "next"))]
pub(crate) use compute_ecdsa_secp256k1_sig::*;
pub(crate) use compute_ed25519_pubkey::*;
pub(crate) use compute_keccak256_hash::*;
pub(crate) use compute_sha256_hash::*;
#[cfg(feature = "next")]
pub(crate) use decode_ecdsa_curve256_sig::*;
pub(crate) use host_mem_alloc::*;
pub(crate) use host_mem_cmp::*;
Expand All @@ -37,11 +29,9 @@ pub(crate) use invoke::*;
pub(crate) use num_ops::*;
pub(crate) use prng::*;
pub(crate) use recover_ecdsa_secp256k1_key::*;
#[cfg(feature = "next")]
pub(crate) use sec1_decode_point_uncompressed::*;
pub(crate) use val_deser::*;
pub(crate) use val_ser::*;
#[cfg(feature = "next")]
pub(crate) use verify_ecdsa_secp256r1_sig::*;
pub(crate) use verify_ed25519_sig::*;
pub(crate) use visit_object::*;
Expand Down
3 changes: 0 additions & 3 deletions soroban-env-host/benches/common/cost_types/vm_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ macro_rules! impl_measurement_for_instantiation_cost_type {
let mut cost_inputs = VersionedContractCodeCostInputs::V0 {
wasm_bytes: wasm.len(),
};
#[cfg(feature = "next")]
if $USE_REFINED_INPUTS {
cost_inputs = VersionedContractCodeCostInputs::V1(
soroban_env_host::vm::ParsedModule::extract_refined_contract_cost_inputs(
Expand Down Expand Up @@ -62,9 +61,7 @@ impl_measurement_for_instantiation_cost_type!(
);

// Protocol 21 cost models.
#[cfg(feature = "next")]
pub(crate) use v21::*;
#[cfg(feature = "next")]
mod v21 {
use super::super::wasm_insn_exec::{
wasm_module_with_n_data_segment_bytes, wasm_module_with_n_data_segments,
Expand Down
4 changes: 0 additions & 4 deletions soroban-env-host/benches/common/experimental/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#[cfg(feature = "next")]
mod decode_secp256r1_sig;
mod ecdsa_secp256k1_verify;
mod ecdsa_secp256r1_recover;
mod ed25519_scalar_mul;
mod read_xdr;
#[cfg(feature = "next")]
mod sec1_decode_point_compressed;

#[cfg(feature = "next")]
pub(crate) use decode_secp256r1_sig::*;
pub(crate) use ecdsa_secp256k1_verify::*;
pub(crate) use ecdsa_secp256r1_recover::*;
pub(crate) use ed25519_scalar_mul::*;
pub(crate) use read_xdr::*;
#[cfg(feature = "next")]
pub(crate) use sec1_decode_point_compressed::*;
56 changes: 26 additions & 30 deletions soroban-env-host/benches/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ pub(crate) fn for_each_host_cost_measurement<B: Benchmark>(
let mut params: BTreeMap<CostType, (MeteredCostComponent, MeteredCostComponent)> =
BTreeMap::new();

#[cfg(not(feature = "next"))]
call_bench::<B, ComputeEcdsaSecp256k1Sig>(&mut params)?;

call_bench::<B, ComputeEd25519PubKeyMeasure>(&mut params)?;
call_bench::<B, ComputeKeccak256HashMeasure>(&mut params)?;
call_bench::<B, ComputeSha256HashMeasure>(&mut params)?;
Expand All @@ -89,36 +86,35 @@ pub(crate) fn for_each_host_cost_measurement<B: Benchmark>(
call_bench::<B, Int256ShiftMeasure>(&mut params)?;
call_bench::<B, ChaCha20DrawBytesMeasure>(&mut params)?;

#[cfg(feature = "next")]
{
call_bench::<B, VmCachedInstantiationMeasure>(&mut params)?;
// P21 cost types
call_bench::<B, VmCachedInstantiationMeasure>(&mut params)?;

call_bench::<B, ParseWasmInstructionsMeasure>(&mut params)?;
call_bench::<B, ParseWasmFunctionsMeasure>(&mut params)?;
call_bench::<B, ParseWasmGlobalsMeasure>(&mut params)?;
call_bench::<B, ParseWasmTableEntriesMeasure>(&mut params)?;
call_bench::<B, ParseWasmTypesMeasure>(&mut params)?;
call_bench::<B, ParseWasmDataSegmentsMeasure>(&mut params)?;
call_bench::<B, ParseWasmElemSegmentsMeasure>(&mut params)?;
call_bench::<B, ParseWasmImportsMeasure>(&mut params)?;
call_bench::<B, ParseWasmExportsMeasure>(&mut params)?;
call_bench::<B, ParseWasmDataSegmentBytesMeasure>(&mut params)?;
call_bench::<B, ParseWasmInstructionsMeasure>(&mut params)?;
call_bench::<B, ParseWasmFunctionsMeasure>(&mut params)?;
call_bench::<B, ParseWasmGlobalsMeasure>(&mut params)?;
call_bench::<B, ParseWasmTableEntriesMeasure>(&mut params)?;
call_bench::<B, ParseWasmTypesMeasure>(&mut params)?;
call_bench::<B, ParseWasmDataSegmentsMeasure>(&mut params)?;
call_bench::<B, ParseWasmElemSegmentsMeasure>(&mut params)?;
call_bench::<B, ParseWasmImportsMeasure>(&mut params)?;
call_bench::<B, ParseWasmExportsMeasure>(&mut params)?;
call_bench::<B, ParseWasmDataSegmentBytesMeasure>(&mut params)?;

call_bench::<B, InstantiateWasmInstructionsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmFunctionsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmGlobalsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmTableEntriesMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmTypesMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmDataSegmentsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmElemSegmentsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmImportsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmExportsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmDataSegmentBytesMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmInstructionsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmFunctionsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmGlobalsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmTableEntriesMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmTypesMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmDataSegmentsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmElemSegmentsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmImportsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmExportsMeasure>(&mut params)?;
call_bench::<B, InstantiateWasmDataSegmentBytesMeasure>(&mut params)?;

call_bench::<B, DecodeEcdsaCurve256SigMeasure>(&mut params)?;
call_bench::<B, Sec1DecodePointUncompressedMeasure>(&mut params)?;
call_bench::<B, VerifyEcdsaSecp256r1SigMeasure>(&mut params)?;

call_bench::<B, DecodeEcdsaCurve256SigMeasure>(&mut params)?;
call_bench::<B, Sec1DecodePointUncompressedMeasure>(&mut params)?;
call_bench::<B, VerifyEcdsaSecp256r1SigMeasure>(&mut params)?;
}
// These three mem ones are derived analytically, we do not calibrate them typically
if std::env::var("INCLUDE_ANALYTICAL_COSTTYPES").is_ok() {
call_bench::<B, MemAllocMeasure>(&mut params)?;
Expand Down
2 changes: 1 addition & 1 deletion soroban-env-host/benches/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use soroban_env_host::{budget::AsBudget, meta, Host, LedgerInfo, Val, I256};
pub(crate) fn test_host() -> Host {
let host = Host::default();
host.set_ledger_info(LedgerInfo {
protocol_version: meta::get_ledger_protocol_version(meta::INTERFACE_VERSION),
protocol_version: Host::current_test_protocol(),
..Default::default()
})
.unwrap();
Expand Down
2 changes: 0 additions & 2 deletions soroban-env-host/benches/worst_case_linear_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ fn write_budget_params_code(
ty,
);
}
#[cfg(not(feature = "next"))]
ContractCostType::VmCachedInstantiation => {
println!(
"
Expand Down Expand Up @@ -293,7 +292,6 @@ fn write_budget_params_code(
ty
)
}
#[cfg(not(feature = "next"))]
ContractCostType::VmCachedInstantiation => {
println!(
"
Expand Down
2 changes: 1 addition & 1 deletion soroban-env-host/fuzz/src/debug_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use soroban_env_host::Symbol;
use soroban_synth_wasm::{Arity, LocalRef, ModEmitter, Operand};

pub fn wasm_module_with_linear_memory_logging() -> Vec<u8> {
let mut me = ModEmitter::default();
let mut me = ModEmitter::default_with_test_protocol();
// log_from_linear_memory
let f0 = me.import_func("x", "_", Arity(4));
// the caller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
" 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-",
" 1 call bytes_new_from_slice(65)": "",
" 2 ret bytes_new_from_slice -> Ok(Bytes(obj#1))": "cpu:977, mem:145, objs:-/1@b2474f93",
" 3 call bytes_new_from_slice(32)": "",
" 4 ret bytes_new_from_slice -> Ok(Bytes(obj#3))": "cpu:1946, mem:257, objs:-/2@6c013500",
" 5 call bytes_new_from_slice(64)": "",
" 6 ret bytes_new_from_slice -> Ok(Bytes(obj#5))": "cpu:2923, mem:401, objs:-/3@2fb55113",
" 7 end": "cpu:0, mem:0, prngs:-/-, objs:-/3@2fb55113, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
" 1 end": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
" 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-",
" 1 end": "cpu:0, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
" 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-",
" 1 end": "cpu:0, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
" 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-",
" 1 end": "cpu:0, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
" 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-",
" 1 end": "cpu:0, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
" 0 begin": "cpu:14488, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-",
" 1 end": "cpu:0, mem:0, prngs:-/9b4a753, objs:-/-, vm:-/-, evt:-, store:-/-, foot:-, stk:-, auth:-/-"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
" 0 begin": "cpu:0, mem:0, prngs:-/-, objs:-/-, vm:-/-, evt:-, store:-/2@52b01770, foot:2@a244340d, stk:-, auth:-/-",
" 1 call vec_new()": "cpu:42436, mem:373, objs:-/1@10432200, store:-/1@6f750601, foot:1@2784223c",
" 2 ret vec_new -> Ok(Vec(obj#3))": "cpu:42937, mem:437, objs:-/2@acf0be8f",
" 3 call call(Address(obj#1), Symbol(test), Vec(obj#3))": "",
" 4 ret call -> Err(Error(Storage, ExceededLimit))": "cpu:51600, mem:941",
" 5 end": "cpu:51600, mem:941, prngs:-/-, objs:-/2@acf0be8f, vm:-/-, evt:-, store:-/1@6f750601, foot:1@2784223c, stk:-, auth:-/-"
}
Loading

0 comments on commit 9f23da3

Please sign in to comment.