-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Epic) Define semantics (and testing strategy) when SDK version is revved #1095
Comments
There are a couple variations of this. For example:
For (1) the compatibility layer is the host layer, and so the SDK plays very little role in there being compatibility or incompatibility between For (2) things are much more fuzzy and I don't think we should do much other than use semver to the best of our ability. If anything in the SDK is a breaking change, increment the major version, and developers will use Cargo and versioning definitions to appropriately constrain their compatibility like they do for any Rust crate. |
yes, this is why I separated the "host compat issues" and this issue that tracks changes that may impact the contract spec in the broader sense (behavior included).
"failing to build" does not make sense in this context: if you require all contracts to be build against the exact same SDK, there is no way to upgrade them (contracts get deployed if at all independently). |
@MonsieurNicolas I had a chat with @leighmcculloch and talked this through some more, and am recording the results of that for posterity / "an official plan" here.
This bug does mention the testing strategy, which I think is relevant but fairly straightforward. We should test the following:
There's one additional bit of diagnostic work to do here, which is bug #735 -- embedding the SDK version info into the meta section of a contract. That's assigned to me now but is not a strict requirement for anything, just a helper for diagnostics. |
Regarding the testing story, I think it would be good if we could maintain a repo of test vectors for a variety of different SDK versions, that CI builds and runs against a variety of env versions. We could have it run daily against the tip of other repos too, so that we get warning ahead of time as the examples need updating, or things break from a compatibility standpoint. |
Another idea for the testing story, I think it'd be interesting if contracts defined as part of their interface a set of test inputs, with expected outputs. If that existed, we could download latest ledger state, and run the tests across all recently used contracts that have test data, using an unreleased environment. |
(going over "upgrade" related issues) For the testing story, is it as simple as having
On the implementation front, can we try out the proposed steps and see how it goes? As to where we can record both of these.... is this a SEP of sorts (before we even talk about automating some of it)? |
In terms of testing: The scope needs deciding. The scope could be no stellar-core, and just the soroban-env, if the goal is to detect purely contract and environment changes over time. That scope wouldn't be testing features like expiry. Agree on a goal, which I think should be consistency, not correct behavior. i.e. Tests don't assert "correct" outputs, they assert consistent outputs across versions, etc. As a starting point:
Once we get the foundation implemented we could look at:
What are you thinking contract developers will need to implement? Iirc all the components that @graydon noted above should be covered by the SDK and Environment in the sense that we'd aim to not introduce any breakage into any existing API provided at either the Env or SDK levels. Breaking changes would be new functions/types. Changes to contract calling convention would be absorbed by either new SDKs, or the Environment. |
I think we need to write down a compatibility guarantee. What existing functionality won't or will change. E.g. will existing host functions change and if yes under what conditions (e.g. only security fixes, only bug fixes)? What type of things do you see going into a SEP? |
@MonsieurNicolas Could these tests fit into the integration testing that stellar-core does in supercluster? Or do you think this need to be a new thing? |
@leighmcculloch this issue is specifically looking at contract behaviors, your recent comments make it look like this is about "host testing", which is not the intent. So going back to the intent of this issue: which is focused on contract developers. If we're looking at "beta testing" this: maybe using the https://github.com/stellar/soroban-examples repo should do the trick (it should be possible to spin up an AMM.sdk_v_X that swaps tokens implemented with sdk_v_Y and sdk_v_Z)? That way contract developers (could be AMM dev or token dev in this example), can test the various combinations of cross contract behavior when some "automagically generated client" is used. Note that we could use Soroban-examples as part of the validation criteria for Soroban (core, tools, etc) as some sort of smoke test as we expect any "Soroban build" to not break examples. I mentioned having a SEP of sorts because specifying test vectors in a standard way allows to test any possible cross contract matrix, regardless of environment (and I am not sure I fully understand yet how all this would work). |
I agree we need sdkN x sdkM testing, but it is a slice of a larger set testing we need to do. The type of machinery we'll need for sdk testing seems like the same sort of machinery we need for testing envN x envM, and sdkN envM x sdkO envP. Contract behaviors, beyond their own logic, are mostly defined by the host, not by the SDK, because the system is "host heavy" in terms of where functionality lives. The SDK is a very thin layer. It is 99% just changing how a host function is presented, so it looks more like common Rust code. If we intend to test contract behavior consistency outside of the contracts own internal logic, we need to test across all variations of 1) Env versions, 2) a matrix of SDK and Env versions, and 3) a matrix of SDK and SDK versions. Are there other ways we intend to test Env's participation in consistency?
Something that @graydon and I discussed offline previously was the idea of contracts embedding test vectors into their contract interface stored in contracts. It would allow anyone to execute them on an upcoming protocol release, and form part of their guarantees on expected behavior. There's tradeoffs here in terms of binary size which would probably lead to storing them elsewhere, and in general challenge of making it expressive enough though. This idea hasn't been explored beyond this. |
Ah, so yes I see I misunderstood the issues intent. The issue is specifically exampling how do contract developers test their own contracts compatibility across versions. The examples mention SDK version, but ideally it would also include env/protocol versions. If the intent is to give contract developers the tools to run their own tests, then I think we're talking about building versioning tooling into the soroban-cli. I can brainstorm this some more. |
I've opened a new issue for the other problem I was discussing: |
I wrote up a form of this comment, but lost it to a browser bug... (browser ate my homework!) ...hopefully this rewrite captures everything.
I think we've already built the bare minimum tools a contract developer needs to handle the scenarios that this issue is concerned with. There are two approaches to writing integration tests – tests that exercise more than one contract at once – for Soroban contracts: 1) by loading dependencies as .wasm, 2) by registering dependencies natively. The tutorials and docs mostly discuss the former as it has less surprises, several advantages, one being specifically relevant to this discussion. When developing contracts at arms length the docs recommend loading dependencies as .wasm. Because dependencies are loaded as .wasm it doesn't really matter what version of the SDK they're using. The other contract may not even be using a Rust SDK. It could be using the AssemblyScript SDK, or a future Zig SDK. The interface that the contract exposes isn't defined by the SDK it uses, but by the Env interface. And so the process of checking if a contract will upgrade safely is the same process for any integration test run. For example:
The same process works if I find out that contract For developers that develop a set of contracts in close proximity as a single unit, and not at arms length, they have options. They can develop with each dependency being loaded as a .wasm. But more likely they will develop and test with all contracts loaded natively. In this case Rust won't allow us to test contract I think there is one thing we could do to make it easier to do this type of testing:
I don't think we need a SEP to support the above, but we could have a doc page that describes how to test an SDK upgrade. It's unclear to me how useful publishing test vectors would be for this scenario. As a developer of contract |
Whilst we have a decent story so far in the SDK, I've opened #1082 to explore improving the SDKs test framework support for testing general contract consistency over time. |
Opened issue for adding documentation mentioned above: stellar/stellar-docs#480 |
Adding functionality to the SDK to make it trivial to test contract consistency over time: |
With #1137 implemented I think we're providing a lot for developers to use to detect unexpected inconsistencies in their contracts. The main two features we're providing is:
The last thing missing is documentation to capture these important concepts, which will be addressed by: |
Closing this because its done and only doc issue is pending. |
This is similar to stellar/rs-soroban-env#310 but scenarios are around SDK changes that are not impacting the core protocol.
Context:
A
andB
are compiled with SDK 1.0.0A
depends onB
(ie:A
invokesB
)Scenario:
A
's developer wants to upgrade to SDK 2.0.0 and wants to test what happens when callingB
compiled with version 1.0.0B
gets recompiled using SDK 2.0.0,A
's developer wants to test and understand howA
would be impacted.This is somewhat related to stellar/rs-soroban-env#289
Tasks
The text was updated successfully, but these errors were encountered: