Skip to content

Commit 20926fa

Browse files
jakmeierNikolay Kurtov
authored andcommitted
test: use WASM for backwards-compatibility tests (#9173)
`base_test_contract_rs.wasm` is a WASM used in our tests that is supposed to be compatible with the oldest version. That currently requires rustc < 1.70 or some hacks to use unstable cargo features. (`-Zbuild-std`) The easiest way forward is to check in a WASM built with the correct settings instead or relying on the nearcore toolchain version. This is a pre-requisite to land the 1.70 toolchain upgrade. (#9140)
1 parent 6c81869 commit 20926fa

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

runtime/near-test-contracts/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fn main() {
1414

1515
fn try_main() -> Result<(), Error> {
1616
build_contract("./test-contract-rs", &["--features", "latest_protocol"], "test_contract_rs")?;
17-
build_contract("./test-contract-rs", &[], "base_test_contract_rs")?;
1817
build_contract(
1918
"./test-contract-rs",
2019
&["--features", "latest_protocol,nightly"],
Binary file not shown.

runtime/near-test-contracts/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ pub fn rs_contract() -> &'static [u8] {
5656
/// This is useful for tests that use a specific protocol version rather then
5757
/// just the latest one. In particular, protocol upgrade tests should use this
5858
/// function rather than [`rs_contract`].
59+
///
60+
/// Note: Unlike other contracts, this is not automatically build from source
61+
/// but instead a WASM in checked into source control. To serve the oldest
62+
/// protocol version, we need a WASM that does not contain instructions beyond
63+
/// the WASM MVP. Rustc >=1.70 uses LLVM with the [sign
64+
/// extension](https://github.com/WebAssembly/spec/blob/main/proposals/sign-extension-ops/Overview.md)
65+
/// enabled. So we have to build it with Rustc <= 1.69. If we need to update the
66+
/// contracts content, we can build it manually with an older compiler and check
67+
/// in the new WASM.
5968
pub fn base_rs_contract() -> &'static [u8] {
6069
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
6170
CONTRACT.get_or_init(|| read_contract("base_test_contract_rs.wasm")).as_slice()

0 commit comments

Comments
 (0)