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
1 change: 0 additions & 1 deletion runtime/near-test-contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fn main() {

fn try_main() -> Result<(), Error> {
build_contract("./test-contract-rs", &["--features", "latest_protocol"], "test_contract_rs")?;
build_contract("./test-contract-rs", &[], "base_test_contract_rs")?;
build_contract(
"./test-contract-rs",
&["--features", "latest_protocol,nightly"],
Expand Down
Binary file not shown.
9 changes: 9 additions & 0 deletions runtime/near-test-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ pub fn rs_contract() -> &'static [u8] {
/// This is useful for tests that use a specific protocol version rather then
/// just the latest one. In particular, protocol upgrade tests should use this
/// function rather than [`rs_contract`].
///
/// Note: Unlike other contracts, this is not automatically build from source
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we aren't checking-in all of the wasm files right now? This crate was clearly intended to make the tests easily extensible and more maintainable, but it seems like in doing so it has introduced worse maintenance hazards in other places of the codebase and therefore the net benefit is still negative. And this seemingly could have been any of the contracts from this crate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most tests want to test only the latest protocol version and use the latest tool chain to build the WASM. For those, this crate seems to be quite useful still.
For the tests that need a fixed WASM, I am tentatively hopeful that we can delete them all once we have limited replayability.

I'd also argue that it's a good thing that some tests failed in this case (1.70 upgrade) because we do care about compatibility with the latest toolchain.

Overall, I'm not necessarily against the idea to check in all WASM files but I'm also not quite convinced it's a positive change right now.

/// but instead a WASM in checked into source control. To serve the oldest
/// protocol version, we need a WASM that does not contain instructions beyond
/// the WASM MVP. Rustc >=1.70 uses LLVM with the [sign
/// extension](https://github.com/WebAssembly/spec/blob/main/proposals/sign-extension-ops/Overview.md)
/// enabled. So we have to build it with Rustc <= 1.69. If we need to update the
/// contracts content, we can build it manually with an older compiler and check
/// in the new WASM.
pub fn base_rs_contract() -> &'static [u8] {
static CONTRACT: OnceCell<Vec<u8>> = OnceCell::new();
CONTRACT.get_or_init(|| read_contract("base_test_contract_rs.wasm")).as_slice()
Expand Down