Skip to content
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

formalize how to introduce changes into the compiler #41

Merged
merged 10 commits into from
Sep 23, 2024

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Aug 5, 2024

rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
@ironcev
Copy link
Member

ironcev commented Aug 19, 2024

Proposal is to add additional sub-chapter or a paragraph under the Feature flags chapter. E.g., Feature flags and #[cfg] attribute.

Every experimental flag provides an argument that can be used inside of the #[cfg] attribute. This enables conditional compilation of Sway code only if the experimental feature is opted in. The argument is formed out of the feature flag name prefixed with the experimental. E.g., #[cfg(experimental_composable_storage).

We need this support, because developing a new feature does not mean only extending the compiler, but often also the standard libraries. E.g., when developing new storage, we will have different implementations of storage types like, e.g., StorageVec. We want those implementations to coexist with those expected by the current implementation of storage in the compiler. Supporting #[cfg], of course, goes beyond Sway standard libraries. 3rd party libraries can be adapted as well to continuously follow a new feature development. Also, we had the situation already that tests needed to be conditionally compiled to support different contract IDs for encoding v0 and v1.

@ironcev
Copy link
Member

ironcev commented Aug 19, 2024

Proposal is to explicitly mention that we will not support Sway Editions, the way Rust does it. Once an experimental feature gets promoted to standard behavior, it cannot be turned off anymore in that version and newer versions of the compiler. In other words, it is not possible to take a compiler of a certain version and "ask" it to behave the same as some older version.

@ironcev
Copy link
Member

ironcev commented Aug 26, 2024

How are we going to approach testing the features on CI and in general?

In a near future we will have several features being developed in parallel, all behind feature flags, all with their code in master, either in development or fully developed and waiting for becoming the default behavior. All of them will have their tests or some tests adapted to work with and without the feature.

Can we elaborate more on this in the RFC? Some of the topics:

  • how features will be tested in CI?
  • how artefacts that can differ in features like ABI JSON or storage slots will be defined?
  • how will different features be conditionally compiled in test code? We will need both #[cfg] and #![cfg].
  • how to specify feature-specific filecheck directives or snapshots?

rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
@xunilrj xunilrj requested a review from ironcev August 29, 2024 12:56
Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

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

Just left a single question, it is great that this is getting formalized :)

Out of the scope of this PR but something that we should start thinking about is the is the question that we are putting aside for some time now. The fact that forc and rest of the plugins are getting released at the same time as the compiler does. Which means we do not have any way conveying the breakage in those parts of the released stuff.

To make my point clear, let me give an extreme example: any change to the dependency declaration syntax etc in the Forc.toml would mean all existing projects are no longer building and thus breaking in terms of forc, subsequently the end users as well. So marking that forc version with a minor bump over the last one (imagine no breaking changes included after last release in terms of the compiler), will convey the idea that the project should still be building. But in reality nothing will build.

This comment of mine would be completely irrelevant to this PR, if the compiler had any other entry, like rustc. As then it becomes the forc's own versioning discussion and totally separate from the compiler. But currently forc is the only entrance to the compiler and only way of using it. So it might make sense to discuss this scenario as well for compiler versioning.

rfcs/0000-changes-lifecyle.md Outdated Show resolved Hide resolved
@xunilrj xunilrj marked this pull request as ready for review September 4, 2024 10:39
@xunilrj xunilrj requested a review from IGI-111 September 5, 2024 09:03
Copy link
Member

@ironcev ironcev left a comment

Choose a reason for hiding this comment

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

Looking forward to have the proposal put in practice! (The suggested changes are only typos popping out of the final quick-read 😄)

rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
rfcs/0013-changes-lifecyle.md Outdated Show resolved Hide resolved
The compiler will follow a "rolling release" scheme, which means that periodically (to be specified) a
new version will be released.

This means that as soon as the compiler reaches version "1.0.0", the next **version** will be "1.1.0"; and
Copy link
Member

@Voxelot Voxelot Sep 20, 2024

Choose a reason for hiding this comment

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

following from the torvolds line, "WE DO NOT BREAK USERSPACE!" Should we clarify that patches will respect semver expectations? ie. minor releases and patches don't require any user intervention? Unless we are pre 1.0, then minor releases are treated like major breaking ones.

Its not clear to me from the rolling release scheme description here what guarantees - if any - we are providing to our users and how the versions signal changes.

For example, if the next version after 1.0 is 1.1, at what point do we bump to 2.0?

if a security or bug fix breaks an existing user program, we should maybe yank versions instead of pushing a patch that might break userspace.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should follow the semver guidelines here. Use major for breaking changes, minor for nonbreaking changes and patch for bug fixes only.

A simple mention that we do so and that this document is meant to elucidate what we consider breaking should suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

5. When the feature is ready, a closing PR will be created and wait until the feature flag is enabled by default.
6. On a later date, the feature flag can be removed making the feature the default behavior of the compiler.

Once the feature is merged into `master`, it will not be possible to "turn off" the feature. In the same sense
Copy link
Member

@Voxelot Voxelot Sep 20, 2024

Choose a reason for hiding this comment

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

doesnt need to be specified here necessarily, but if a flag is disabled we should just emit a warning to the user to ensure the presence of flag that is no longer used doesn't break or prevent compilation in any way. ie. if i set an experimental flag on my CI, and then it later becomes stable, we shouldn't throw any errors because the flag is no longer used imo. If flags are specified that never existed then i think it's fair to throw an error to the user so they know it's not working as they may expect.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think forcing you to update your flags when features are stabilized is a feature, not a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with @IGI-111. This does not mean that we can not generate warnings along the way, before removing the flag.


[drawbacks]: #drawbacks

This will increase the complexity of the compiler. Not all flags used to compile end up in the JSON ABI, or other outputs. Which can make reproducibility harder.
Copy link
Member

Choose a reason for hiding this comment

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

this may impact abi verification tools (cc @sdankel)

Copy link
Contributor

Choose a reason for hiding this comment

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

Surely such tools should only use stable compiler features. We may want to extend support which requires recoding what flags are used on top of the compiler version, but we should not encourage people to use experimental features. In fact this should be more discouraged than it is in Rust given our environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I vote for this to be dealt in another RFC.

@xunilrj xunilrj merged commit 08e2a7e into master Sep 23, 2024
2 checks passed
@xunilrj xunilrj deleted the xunilrj/lifecycle-changes branch September 23, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants