diff --git a/Cargo.lock b/Cargo.lock index d824b54a33..cd07e3aef6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,6 +308,7 @@ dependencies = [ "solana-feature-gate-interface", "solana-instruction 2.2.1", "solana-instructions-sysvar 2.2.2", + "solana-invoke", "solana-loader-v3-interface", "solana-msg 2.2.1", "solana-program-entrypoint 2.3.0", @@ -4365,6 +4366,19 @@ dependencies = [ "solana-sysvar-id 3.0.0", ] +[[package]] +name = "solana-invoke" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f5693c6de226b3626658377168b0184e94e8292ff16e3d31d4766e65627565" +dependencies = [ + "solana-account-info 2.3.0", + "solana-define-syscall 2.3.0", + "solana-instruction 2.2.1", + "solana-program-entrypoint 2.3.0", + "solana-stable-layout 2.2.1", +] + [[package]] name = "solana-keccak-hasher" version = "2.2.1" diff --git a/bench/COMPUTE_UNITS.md b/bench/COMPUTE_UNITS.md index c519b8246f..8a19439f86 100644 --- a/bench/COMPUTE_UNITS.md +++ b/bench/COMPUTE_UNITS.md @@ -16,95 +16,95 @@ The programs and their tests are located in [/tests/bench](https://github.com/co Solana version: 2.1.0 -| Instruction | Compute Units | - | -| --------------------------- | ------------- | --- | -| accountInfo1 | 571 | - | -| accountInfo2 | 895 | - | -| accountInfo4 | 1,553 | - | -| accountInfo8 | 2,923 | - | -| accountEmptyInit1 | 5,083 | - | -| accountEmpty1 | 645 | - | -| accountEmptyInit2 | 9,301 | - | -| accountEmpty2 | 1,007 | - | -| accountEmptyInit4 | 17,764 | - | -| accountEmpty4 | 1,724 | - | -| accountEmptyInit8 | 34,723 | - | -| accountEmpty8 | 3,163 | - | -| accountSizedInit1 | 5,192 | - | -| accountSized1 | 693 | - | -| accountSizedInit2 | 9,489 | - | -| accountSized2 | 1,075 | - | -| accountSizedInit4 | 18,170 | - | -| accountSized4 | 1,848 | - | -| accountSizedInit8 | 35,433 | - | -| accountSized8 | 3,387 | - | -| accountUnsizedInit1 | 5,305 | - | -| accountUnsized1 | 746 | - | -| accountUnsizedInit2 | 9,759 | - | -| accountUnsized2 | 1,163 | - | -| accountUnsizedInit4 | 18,603 | - | -| accountUnsized4 | 2,002 | - | -| accountUnsizedInit8 | 35,993 | - | -| accountUnsized8 | 3,673 | - | -| boxedAccountEmptyInit1 | 5,175 | - | -| boxedAccountEmpty1 | 734 | - | -| boxedAccountEmptyInit2 | 9,414 | - | -| boxedAccountEmpty2 | 1,116 | - | -| boxedAccountEmptyInit4 | 17,918 | - | -| boxedAccountEmpty4 | 1,872 | - | -| boxedAccountEmptyInit8 | 34,953 | - | -| boxedAccountEmpty8 | 3,401 | - | -| boxedAccountSizedInit1 | 5,271 | - | -| boxedAccountSized1 | 783 | - | -| boxedAccountSizedInit2 | 9,583 | - | -| boxedAccountSized2 | 1,190 | - | -| boxedAccountSizedInit4 | 18,230 | - | -| boxedAccountSized4 | 1,996 | - | -| boxedAccountSizedInit8 | 35,553 | - | -| boxedAccountSized8 | 3,628 | - | -| boxedAccountUnsizedInit1 | 5,371 | - | -| boxedAccountUnsized1 | 836 | - | -| boxedAccountUnsizedInit2 | 9,759 | - | -| boxedAccountUnsized2 | 1,270 | - | -| boxedAccountUnsizedInit4 | 18,558 | - | -| boxedAccountUnsized4 | 2,132 | - | -| boxedAccountUnsizedInit8 | 36,185 | - | -| boxedAccountUnsized8 | 3,881 | - | -| boxedInterfaceAccountMint1 | 1,351 | - | -| boxedInterfaceAccountMint2 | 2,123 | - | -| boxedInterfaceAccountMint4 | 3,656 | - | -| boxedInterfaceAccountMint8 | 6,738 | - | -| boxedInterfaceAccountToken1 | 2,011 | - | -| boxedInterfaceAccountToken2 | 3,431 | - | -| boxedInterfaceAccountToken4 | 6,260 | - | -| boxedInterfaceAccountToken8 | 11,934 | - | -| interfaceAccountMint1 | 1,476 | - | -| interfaceAccountMint2 | 2,489 | - | -| interfaceAccountMint4 | 4,511 | - | -| interfaceAccountMint8 | 8,550 | - | -| interfaceAccountToken1 | 2,111 | - | -| interfaceAccountToken2 | 3,729 | - | -| interfaceAccountToken4 | 6,955 | - | -| interface1 | 769 | - | -| interface2 | 912 | - | -| interface4 | 1,189 | - | -| interface8 | 1,748 | - | -| program1 | 779 | - | -| program2 | 920 | - | -| program4 | 1,193 | - | -| program8 | 1,744 | - | -| signer1 | 774 | - | -| signer2 | 1,064 | - | -| signer4 | 1,637 | - | -| signer8 | 2,788 | - | -| systemAccount1 | 796 | - | -| systemAccount2 | 1,096 | - | -| systemAccount4 | 1,689 | - | -| systemAccount8 | 2,880 | - | -| uncheckedAccount1 | 783 | - | -| uncheckedAccount2 | 1,056 | - | -| uncheckedAccount4 | 1,594 | - | -| uncheckedAccount8 | 2,679 | - | +| Instruction | Compute Units | - | +| --------------------------- | ------------- | --------------------- | +| accountInfo1 | 571 | - | +| accountInfo2 | 895 | - | +| accountInfo4 | 1,553 | - | +| accountInfo8 | 2,923 | - | +| accountEmptyInit1 | 4,829 | 🟢 **-254 (5.00%)** | +| accountEmpty1 | 645 | - | +| accountEmptyInit2 | 8,793 | 🟢 **-508 (5.46%)** | +| accountEmpty2 | 1,007 | - | +| accountEmptyInit4 | 16,748 | 🟢 **-1,016 (5.72%)** | +| accountEmpty4 | 1,724 | - | +| accountEmptyInit8 | 32,691 | 🟢 **-2,032 (5.85%)** | +| accountEmpty8 | 3,163 | - | +| accountSizedInit1 | 4,938 | 🟢 **-254 (4.89%)** | +| accountSized1 | 693 | - | +| accountSizedInit2 | 8,981 | 🟢 **-508 (5.35%)** | +| accountSized2 | 1,075 | - | +| accountSizedInit4 | 17,154 | 🟢 **-1,016 (5.59%)** | +| accountSized4 | 1,848 | - | +| accountSizedInit8 | 33,401 | 🟢 **-2,032 (5.73%)** | +| accountSized8 | 3,387 | - | +| accountUnsizedInit1 | 5,051 | 🟢 **-254 (4.79%)** | +| accountUnsized1 | 746 | - | +| accountUnsizedInit2 | 9,251 | 🟢 **-508 (5.21%)** | +| accountUnsized2 | 1,163 | - | +| accountUnsizedInit4 | 17,587 | 🟢 **-1,016 (5.46%)** | +| accountUnsized4 | 2,002 | - | +| accountUnsizedInit8 | 33,961 | 🟢 **-2,032 (5.65%)** | +| accountUnsized8 | 3,673 | - | +| boxedAccountEmptyInit1 | 4,921 | 🟢 **-254 (4.91%)** | +| boxedAccountEmpty1 | 734 | - | +| boxedAccountEmptyInit2 | 8,906 | 🟢 **-508 (5.40%)** | +| boxedAccountEmpty2 | 1,116 | - | +| boxedAccountEmptyInit4 | 16,902 | 🟢 **-1,016 (5.67%)** | +| boxedAccountEmpty4 | 1,872 | - | +| boxedAccountEmptyInit8 | 32,921 | 🟢 **-2,032 (5.81%)** | +| boxedAccountEmpty8 | 3,401 | - | +| boxedAccountSizedInit1 | 5,017 | 🟢 **-254 (4.82%)** | +| boxedAccountSized1 | 783 | - | +| boxedAccountSizedInit2 | 9,075 | 🟢 **-508 (5.30%)** | +| boxedAccountSized2 | 1,190 | - | +| boxedAccountSizedInit4 | 17,214 | 🟢 **-1,016 (5.57%)** | +| boxedAccountSized4 | 1,996 | - | +| boxedAccountSizedInit8 | 33,521 | 🟢 **-2,032 (5.72%)** | +| boxedAccountSized8 | 3,628 | - | +| boxedAccountUnsizedInit1 | 5,117 | 🟢 **-254 (4.73%)** | +| boxedAccountUnsized1 | 836 | - | +| boxedAccountUnsizedInit2 | 9,251 | 🟢 **-508 (5.21%)** | +| boxedAccountUnsized2 | 1,270 | - | +| boxedAccountUnsizedInit4 | 17,542 | 🟢 **-1,016 (5.47%)** | +| boxedAccountUnsized4 | 2,132 | - | +| boxedAccountUnsizedInit8 | 34,153 | 🟢 **-2,032 (5.62%)** | +| boxedAccountUnsized8 | 3,881 | - | +| boxedInterfaceAccountMint1 | 1,351 | - | +| boxedInterfaceAccountMint2 | 2,123 | - | +| boxedInterfaceAccountMint4 | 3,656 | - | +| boxedInterfaceAccountMint8 | 6,738 | - | +| boxedInterfaceAccountToken1 | 2,011 | - | +| boxedInterfaceAccountToken2 | 3,431 | - | +| boxedInterfaceAccountToken4 | 6,260 | - | +| boxedInterfaceAccountToken8 | 11,934 | - | +| interfaceAccountMint1 | 1,476 | - | +| interfaceAccountMint2 | 2,489 | - | +| interfaceAccountMint4 | 4,511 | - | +| interfaceAccountMint8 | 8,550 | - | +| interfaceAccountToken1 | 2,111 | - | +| interfaceAccountToken2 | 3,729 | - | +| interfaceAccountToken4 | 6,955 | - | +| interface1 | 769 | - | +| interface2 | 912 | - | +| interface4 | 1,189 | - | +| interface8 | 1,748 | - | +| program1 | 779 | - | +| program2 | 920 | - | +| program4 | 1,193 | - | +| program8 | 1,744 | - | +| signer1 | 774 | - | +| signer2 | 1,064 | - | +| signer4 | 1,637 | - | +| signer8 | 2,788 | - | +| systemAccount1 | 796 | - | +| systemAccount2 | 1,096 | - | +| systemAccount4 | 1,689 | - | +| systemAccount8 | 2,880 | - | +| uncheckedAccount1 | 783 | - | +| uncheckedAccount2 | 1,056 | - | +| uncheckedAccount4 | 1,594 | - | +| uncheckedAccount8 | 2,679 | - | ### Notable changes diff --git a/lang/Cargo.toml b/lang/Cargo.toml index 8bfa87a741..f28bac5ee5 100644 --- a/lang/Cargo.toml +++ b/lang/Cargo.toml @@ -63,6 +63,7 @@ solana-define-syscall = "2" solana-feature-gate-interface = "2" solana-instruction = "2" solana-instructions-sysvar = "2" +solana-invoke = "0.4.0" solana-loader-v3-interface = { version = "3", features = ["bincode"] } solana-msg = "2" solana-program-entrypoint = "2" diff --git a/lang/src/lib.rs b/lang/src/lib.rs index aeb7f71871..a13417f7f8 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -67,12 +67,12 @@ pub mod solana_program { pub use solana_feature_gate_interface as feature; pub use { - solana_account_info as account_info, solana_clock as clock, solana_cpi as program, - solana_msg::msg, solana_program_entrypoint as entrypoint, - solana_program_entrypoint::entrypoint, solana_program_error as program_error, - solana_program_memory as program_memory, solana_program_option as program_option, - solana_program_pack as program_pack, solana_pubkey as pubkey, - solana_sdk_ids::system_program, solana_system_interface::instruction as system_instruction, + solana_account_info as account_info, solana_clock as clock, solana_msg::msg, + solana_program_entrypoint as entrypoint, solana_program_entrypoint::entrypoint, + solana_program_error as program_error, solana_program_memory as program_memory, + solana_program_option as program_option, solana_program_pack as program_pack, + solana_pubkey as pubkey, solana_sdk_ids::system_program, + solana_system_interface::instruction as system_instruction, }; pub mod instruction { pub use solana_instruction::*; @@ -94,6 +94,10 @@ pub mod solana_program { pub mod rent { pub use solana_sysvar::rent::*; } + pub mod program { + pub use solana_cpi::*; + pub use solana_invoke::{invoke, invoke_signed, invoke_signed_unchecked, invoke_unchecked}; + } pub mod bpf_loader_upgradeable { #[allow(deprecated)] diff --git a/tests/auction-house/Cargo.lock b/tests/auction-house/Cargo.lock index 1e36889f2d..34f642ad9a 100644 --- a/tests/auction-house/Cargo.lock +++ b/tests/auction-house/Cargo.lock @@ -177,6 +177,7 @@ dependencies = [ "solana-feature-gate-interface", "solana-instruction", "solana-instructions-sysvar", + "solana-invoke", "solana-loader-v3-interface 3.0.0", "solana-msg", "solana-program-entrypoint", @@ -1627,6 +1628,19 @@ dependencies = [ "solana-sysvar-id", ] +[[package]] +name = "solana-invoke" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f5693c6de226b3626658377168b0184e94e8292ff16e3d31d4766e65627565" +dependencies = [ + "solana-account-info", + "solana-define-syscall", + "solana-instruction", + "solana-program-entrypoint", + "solana-stable-layout", +] + [[package]] name = "solana-keccak-hasher" version = "2.2.1" diff --git a/tests/bench/bench.json b/tests/bench/bench.json index 65517278b3..2bf984e195 100644 --- a/tests/bench/bench.json +++ b/tests/bench/bench.json @@ -1312,53 +1312,53 @@ "accountInfo2": 895, "accountInfo4": 1553, "accountInfo8": 2923, - "accountEmptyInit1": 5083, + "accountEmptyInit1": 4829, "accountEmpty1": 645, - "accountEmptyInit2": 9301, + "accountEmptyInit2": 8793, "accountEmpty2": 1007, - "accountEmptyInit4": 17764, + "accountEmptyInit4": 16748, "accountEmpty4": 1724, - "accountEmptyInit8": 34723, + "accountEmptyInit8": 32691, "accountEmpty8": 3163, - "accountSizedInit1": 5192, + "accountSizedInit1": 4938, "accountSized1": 693, - "accountSizedInit2": 9489, + "accountSizedInit2": 8981, "accountSized2": 1075, - "accountSizedInit4": 18170, + "accountSizedInit4": 17154, "accountSized4": 1848, - "accountSizedInit8": 35433, + "accountSizedInit8": 33401, "accountSized8": 3387, - "accountUnsizedInit1": 5305, + "accountUnsizedInit1": 5051, "accountUnsized1": 746, - "accountUnsizedInit2": 9759, + "accountUnsizedInit2": 9251, "accountUnsized2": 1163, - "accountUnsizedInit4": 18603, + "accountUnsizedInit4": 17587, "accountUnsized4": 2002, - "accountUnsizedInit8": 35993, + "accountUnsizedInit8": 33961, "accountUnsized8": 3673, - "boxedAccountEmptyInit1": 5175, + "boxedAccountEmptyInit1": 4921, "boxedAccountEmpty1": 734, - "boxedAccountEmptyInit2": 9414, + "boxedAccountEmptyInit2": 8906, "boxedAccountEmpty2": 1116, - "boxedAccountEmptyInit4": 17918, + "boxedAccountEmptyInit4": 16902, "boxedAccountEmpty4": 1872, - "boxedAccountEmptyInit8": 34953, + "boxedAccountEmptyInit8": 32921, "boxedAccountEmpty8": 3401, - "boxedAccountSizedInit1": 5271, + "boxedAccountSizedInit1": 5017, "boxedAccountSized1": 783, - "boxedAccountSizedInit2": 9583, + "boxedAccountSizedInit2": 9075, "boxedAccountSized2": 1190, - "boxedAccountSizedInit4": 18230, + "boxedAccountSizedInit4": 17214, "boxedAccountSized4": 1996, - "boxedAccountSizedInit8": 35553, + "boxedAccountSizedInit8": 33521, "boxedAccountSized8": 3628, - "boxedAccountUnsizedInit1": 5371, + "boxedAccountUnsizedInit1": 5117, "boxedAccountUnsized1": 836, - "boxedAccountUnsizedInit2": 9759, + "boxedAccountUnsizedInit2": 9251, "boxedAccountUnsized2": 1270, - "boxedAccountUnsizedInit4": 18558, + "boxedAccountUnsizedInit4": 17542, "boxedAccountUnsized4": 2132, - "boxedAccountUnsizedInit8": 36185, + "boxedAccountUnsizedInit8": 34153, "boxedAccountUnsized8": 3881, "boxedInterfaceAccountMint1": 1351, "boxedInterfaceAccountMint2": 2123, diff --git a/tests/spl/metadata/Cargo.lock b/tests/spl/metadata/Cargo.lock index e6e32fe757..ee11066a97 100644 --- a/tests/spl/metadata/Cargo.lock +++ b/tests/spl/metadata/Cargo.lock @@ -177,6 +177,7 @@ dependencies = [ "solana-feature-gate-interface", "solana-instruction", "solana-instructions-sysvar", + "solana-invoke", "solana-loader-v3-interface 3.0.0", "solana-msg", "solana-program-entrypoint", @@ -1625,6 +1626,19 @@ dependencies = [ "solana-sysvar-id", ] +[[package]] +name = "solana-invoke" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f5693c6de226b3626658377168b0184e94e8292ff16e3d31d4766e65627565" +dependencies = [ + "solana-account-info", + "solana-define-syscall", + "solana-instruction", + "solana-program-entrypoint", + "solana-stable-layout", +] + [[package]] name = "solana-keccak-hasher" version = "2.2.1"