diff --git a/Cargo.lock b/Cargo.lock index feff9d956297ed..67d99283a85511 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1773,6 +1773,17 @@ dependencies = [ "hmac 0.7.1", ] +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.3", + "hmac 0.8.1", +] + [[package]] name = "http" version = "0.2.1" @@ -2255,13 +2266,61 @@ dependencies = [ "arrayref", "crunchy", "digest 0.8.1", - "hmac-drbg", + "hmac-drbg 0.2.0", "rand 0.7.3", "sha2 0.8.2", "subtle 2.2.2", "typenum", ] +[[package]] +name = "libsecp256k1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg 0.3.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.7.3", + "serde", + "sha2 0.9.2", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee11012b293ea30093c129173cac4335513064094619f4639a25b310fd33c11" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle 2.2.2", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32239626ffbb6a095b83b37a02ceb3672b2443a87a000a884fc3c4d16925c9c0" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76acb433e21d10f5f9892b1962c2856c58c7f39a9e4bd68ac82b9436a0ffd5b9" +dependencies = [ + "libsecp256k1-core", +] + [[package]] name = "linked-hash-map" version = "0.5.3" @@ -4125,12 +4184,8 @@ version = "1.7.5" dependencies = [ "bincode", "byteorder", -<<<<<<< HEAD + "libsecp256k1 0.5.0", "log 0.4.11", -======= - "libsecp256k1", - "log 0.4.14", ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) "num-derive", "num-traits", "rand 0.7.3", @@ -5041,12 +5096,8 @@ dependencies = [ "hex", "itertools", "lazy_static", -<<<<<<< HEAD + "libsecp256k1 0.5.0", "log 0.4.11", -======= - "libsecp256k1", - "log 0.4.14", ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) "num-derive", "num-traits", "rand 0.7.3", @@ -5244,7 +5295,7 @@ dependencies = [ "hmac 0.10.1", "itertools", "lazy_static", - "libsecp256k1", + "libsecp256k1 0.3.5", "log 0.4.11", "memmap2", "num-derive", @@ -5303,7 +5354,7 @@ version = "1.7.5" dependencies = [ "bincode", "digest 0.9.0", - "libsecp256k1", + "libsecp256k1 0.3.5", "rand 0.7.3", "sha3", "solana-logger 1.7.5", diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index 0a7b4843adef87..5c72eba44f9d5a 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -1318,6 +1318,17 @@ dependencies = [ "hmac 0.7.1", ] +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.3", + "hmac 0.8.1", +] + [[package]] name = "http" version = "0.2.1" @@ -1566,13 +1577,61 @@ dependencies = [ "arrayref", "crunchy", "digest 0.8.1", - "hmac-drbg", + "hmac-drbg 0.2.0", "rand 0.7.3", "sha2 0.8.2", "subtle 2.2.2", "typenum", ] +[[package]] +name = "libsecp256k1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd1137239ab33b41aa9637a88a28249e5e70c40a42ccc92db7f12cc356c1fcd7" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg 0.3.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.7.3", + "serde", + "sha2 0.9.2", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee11012b293ea30093c129173cac4335513064094619f4639a25b310fd33c11" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle 2.2.2", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32239626ffbb6a095b83b37a02ceb3672b2443a87a000a884fc3c4d16925c9c0" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76acb433e21d10f5f9892b1962c2856c58c7f39a9e4bd68ac82b9436a0ffd5b9" +dependencies = [ + "libsecp256k1-core", +] + [[package]] name = "linked-hash-map" version = "0.5.4" @@ -2800,12 +2859,8 @@ name = "solana-bpf-loader-program" version = "1.7.5" dependencies = [ "bincode", -<<<<<<< HEAD "byteorder 1.3.4", -======= - "byteorder 1.4.3", - "libsecp256k1", ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) + "libsecp256k1 0.5.0", "log", "num-derive 0.3.0", "num-traits", @@ -3073,9 +3128,9 @@ dependencies = [ [[package]] name = "solana-bpf-rust-secp256k1-recover" -version = "1.8.0" +version = "1.7.5" dependencies = [ - "solana-program 1.8.0", + "solana-program 1.7.5", ] [[package]] @@ -3429,7 +3484,7 @@ dependencies = [ "hex", "itertools 0.9.0", "lazy_static", - "libsecp256k1", + "libsecp256k1 0.5.0", "log", "num-derive 0.3.0", "num-traits", @@ -3567,7 +3622,7 @@ dependencies = [ "hmac 0.10.1", "itertools 0.9.0", "lazy_static", - "libsecp256k1", + "libsecp256k1 0.3.5", "log", "memmap2", "num-derive 0.3.0", @@ -3625,7 +3680,7 @@ version = "1.7.5" dependencies = [ "bincode", "digest 0.9.0", - "libsecp256k1", + "libsecp256k1 0.3.5", "rand 0.7.3", "sha3", "solana-logger 1.7.5", diff --git a/programs/bpf/rust/secp256k1_recover/Cargo.toml b/programs/bpf/rust/secp256k1_recover/Cargo.toml index dd21f9def05fc5..8548c6a356ded4 100644 --- a/programs/bpf/rust/secp256k1_recover/Cargo.toml +++ b/programs/bpf/rust/secp256k1_recover/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-bpf-rust-secp256k1-recover" -version = "1.8.0" +version = "1.7.5" description = "Solana BPF test program written in Rust" authors = ["Solana Maintainers "] repository = "https://github.com/solana-labs/solana" @@ -10,7 +10,7 @@ documentation = "https://docs.rs/solana-bpf-rust-secp256k1-recover" edition = "2018" [dependencies] -solana-program = { path = "../../../../sdk/program", version = "=1.8.0" } +solana-program = { path = "../../../../sdk/program", version = "=1.7.5" } [lib] crate-type = ["cdylib"] diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index 4c16d77838832d..e8d9575dc7fae3 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -1281,16 +1281,10 @@ fn assert_instruction_count() { ("noop", 42), ("noop++", 42), ("relative_call", 10), -<<<<<<< HEAD ("sanity", 174), ("sanity++", 174), - ("sha", 694), -======= - ("sanity", 169), - ("sanity++", 168), ("secp256k1_recover", 357), - ("sha", 1040), ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) + ("sha", 694), ("struct_pass", 8), ("struct_ret", 22), ]); @@ -1309,16 +1303,10 @@ fn assert_instruction_count() { ("solana_bpf_rust_membuiltins", 4069), ("solana_bpf_rust_noop", 495), ("solana_bpf_rust_param_passing", 46), -<<<<<<< HEAD ("solana_bpf_rust_rand", 498), ("solana_bpf_rust_sanity", 917), - ("solana_bpf_rust_sha", 29099), -======= - ("solana_bpf_rust_rand", 481), - ("solana_bpf_rust_sanity", 900), - ("solana_bpf_rust_secp256k1_recover", 301), - ("solana_bpf_rust_sha", 32333), ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) + ("solana_bpf_rust_secp256k1_recover", 306), + ("solana_bpf_rust_sha", 29131), ]); } diff --git a/programs/bpf_loader/Cargo.toml b/programs/bpf_loader/Cargo.toml index c2d41216bd7326..58bacf695cedb6 100644 --- a/programs/bpf_loader/Cargo.toml +++ b/programs/bpf_loader/Cargo.toml @@ -15,12 +15,8 @@ byteorder = "1.3.4" log = "0.4.11" num-derive = "0.3" num-traits = "0.2" -<<<<<<< HEAD rand_core = "0.6.2" -======= -rand_core = "0.6.3" libsecp256k1 = "0.5.0" ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) sha3 = "0.9.1" solana-measure = { path = "../../measure", version = "=1.7.5" } solana-runtime = { path = "../../runtime", version = "=1.7.5" } diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index d81df26d009b29..d84d7eaf629783 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -19,14 +19,9 @@ use solana_sdk::{ entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS}, epoch_schedule::EpochSchedule, feature_set::{ -<<<<<<< HEAD cpi_data_cost, enforce_aligned_host_addrs, keccak256_syscall_enabled, memory_ops_syscalls, - set_upgrade_authority_via_cpi_enabled, sysvar_via_syscall, update_data_on_realloc, -======= - blake3_syscall_enabled, cpi_data_cost, enforce_aligned_host_addrs, - keccak256_syscall_enabled, memory_ops_syscalls, secp256k1_recover_syscall_enabled, + secp256k1_recover_syscall_enabled, set_upgrade_authority_via_cpi_enabled, sysvar_via_syscall, update_data_on_realloc, ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) }, hash::{Hasher, HASH_BYTES}, ic_msg, @@ -142,18 +137,11 @@ pub fn register_syscalls( syscall_registry.register_syscall_by_name(b"sol_keccak256", SyscallKeccak256::call)?; } -<<<<<<< HEAD -======= if invoke_context.is_feature_active(&secp256k1_recover_syscall_enabled::id()) { syscall_registry .register_syscall_by_name(b"sol_secp256k1_recover", SyscallSecp256k1Recover::call)?; } - if invoke_context.is_feature_active(&blake3_syscall_enabled::id()) { - syscall_registry.register_syscall_by_name(b"sol_blake3", SyscallBlake3::call)?; - } - ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) if invoke_context.is_feature_active(&sysvar_via_syscall::id()) { syscall_registry .register_syscall_by_name(b"sol_get_clock_sysvar", SyscallGetClockSysvar::call)?; @@ -1359,8 +1347,6 @@ impl<'a> SyscallObject for SyscallMemset<'a> { } } -<<<<<<< HEAD -======= /// secp256k1_recover pub struct SyscallSecp256k1Recover<'a> { cost: u64, @@ -1447,66 +1433,6 @@ impl<'a> SyscallObject for SyscallSecp256k1Recover<'a> { } } -// Blake3 -pub struct SyscallBlake3<'a> { - base_cost: u64, - byte_cost: u64, - compute_meter: Rc>, - loader_id: &'a Pubkey, -} -impl<'a> SyscallObject for SyscallBlake3<'a> { - fn call( - &mut self, - vals_addr: u64, - vals_len: u64, - result_addr: u64, - _arg4: u64, - _arg5: u64, - memory_mapping: &MemoryMapping, - result: &mut Result>, - ) { - question_mark!(self.compute_meter.consume(self.base_cost), result); - let hash_result = question_mark!( - translate_slice_mut::( - memory_mapping, - result_addr, - blake3::HASH_BYTES as u64, - self.loader_id, - true, - ), - result - ); - let mut hasher = blake3::Hasher::default(); - if vals_len > 0 { - let vals = question_mark!( - translate_slice::<&[u8]>(memory_mapping, vals_addr, vals_len, self.loader_id, true), - result - ); - for val in vals.iter() { - let bytes = question_mark!( - translate_slice::( - memory_mapping, - val.as_ptr() as u64, - val.len() as u64, - self.loader_id, - true, - ), - result - ); - question_mark!( - self.compute_meter - .consume(self.byte_cost * (val.len() as u64 / 2)), - result - ); - hasher.hash(bytes); - } - } - hash_result.copy_from_slice(&hasher.result().to_bytes()); - *result = Ok(0); - } -} - ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) // Cross-program invocation syscalls struct AccountReferences<'a> { diff --git a/sdk/program/Cargo.toml b/sdk/program/Cargo.toml index 820d97371d3755..b001f12b6737cf 100644 --- a/sdk/program/Cargo.toml +++ b/sdk/program/Cargo.toml @@ -34,13 +34,9 @@ solana-sdk-macro = { path = "../macro", version = "=1.7.5" } thiserror = "1.0" [target.'cfg(not(target_arch = "bpf"))'.dependencies] -<<<<<<< HEAD blake3 = "0.3.7" curve25519-dalek = "2.1.0" -======= -curve25519-dalek = "3.0.0" libsecp256k1 = "0.5.0" ->>>>>>> 1f288ce52 (Add ecrecover syscall (#17720)) rand = "0.7.0" solana-logger = { path = "../../logger", version = "=1.7.5" }