Skip to content

Commit

Permalink
Improve documentation about backwards compatibility (#4627)
Browse files Browse the repository at this point in the history
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Ernesto García <ernestognw@gmail.com>
(cherry picked from commit 2472e51)
  • Loading branch information
frangio committed Sep 28, 2023
1 parent b805cc8 commit 53f2721
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 110 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

:building_construction: **Want to scale your decentralized application?** Check out [OpenZeppelin Defender](https://openzeppelin.com/defender) — a secure platform for automating and monitoring your operations.

> [!IMPORTANT]
> OpenZeppelin Contracts uses semantic versioning to communicate backwards compatibility of its API and storage layout. For upgradeable contracts, the storage layout of different major versions should be assumed incompatible, for example, it is unsafe to upgrade from 4.9.3 to 5.0.0. Learn more at [Backwards Compatibility](https://docs.openzeppelin.com/contracts/backwards-compatibility).
## Overview

### Installation
Expand All @@ -30,8 +33,6 @@
$ npm install @openzeppelin/contracts
```

OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/contracts/releases-stability#api-stability), which means that your contracts won't break unexpectedly when upgrading to a newer minor version.

#### Foundry (git)

> **Warning** When installing via git, it is a common error to use the `master` branch. This is a development branch that should be avoided in favor of tagged releases. The release process involves security measures that the `master` branch does not guarantee.
Expand Down
2 changes: 0 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Releasing

> Visit the documentation for [details about release schedule](https://docs.openzeppelin.com/contracts/releases-stability).
OpenZeppelin Contracts uses a fully automated release process that takes care of compiling, packaging, and publishing the library, all of which is carried out in a clean CI environment (GitHub Actions), implemented in the ([`release-cycle`](.github/workflows/release-cycle.yml)) workflow. This helps to reduce the potential for human error and inconsistencies, and ensures that the release process is ongoing and reliable.

## Changesets
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* xref:extending-contracts.adoc[Extending Contracts]
* xref:upgradeable.adoc[Using with Upgrades]
* xref:releases-stability.adoc[Releases & Stability]
* xref:backwards-compatibility.adoc[Backwards Compatibility]
* xref:access-control.adoc[Access Control]
Expand Down
48 changes: 48 additions & 0 deletions docs/modules/ROOT/pages/backwards-compatibility.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
= Backwards Compatibility
:page-aliases: releases-stability.adoc

OpenZeppelin Contracts uses semantic versioning to communicate backwards compatibility of its API and storage layout. Patch and minor updates will generally be backwards compatible, with rare exceptions as detailed below. Major updates should be assumed incompatible with previous releases. On this page, we provide details about these guarantees.

== API

In backwards compatible releases, all changes should be either additions or modifications to internal implementation details. Most code should continue to compile and behave as expected. The exceptions to this rule are listed below.

=== Security

Infrequently a patch or minor update will remove or change an API in a breaking way, but only if the previous API is considered insecure. These breaking changes will be noted in the changelog and release notes, and published along with a security advisory.

=== Draft or Pre-Final ERCs

ERCs that are not Final can change in incompatible ways. For this reason, we avoid shipping implementations of ERCs before they are Final. Some exceptions are made for ERCs that have been published for a long time and that seem unlikely to change. Breaking changes to the ERC specification are still technically possible in those cases, so these implementations are published in files named `draft-*.sol` to make that condition explicit.

=== Virtual & Overrides

Almost all functions in this library are virtual with some exceptions, but this does not mean that overrides are encouraged. There is a subset of functions that are designed to be overridden. By defining overrides outside of this subset you are potentially relying on internal implementation details. We make efforts to preserve backwards compatibility even in these cases but it is extremely difficult and easy to accidentally break. Caution is advised.

Additionally, some minor updates may result in new compilation errors of the kind "two or more base classes define function with same name and parameter types" or "need to specify overridden contract", due to what Solidity considers ambiguity in inherited functions. This should be resolved by adding an override that invokes the function via `super`.

See xref:extending-contracts.adoc[Extending Contracts] for more about virtual and overrides.

=== Structs

Struct members with an underscore prefix should be considered "private" and may break in minor versions. Struct data should only be accessed and modified through library functions.

=== Errors

The specific error format and data that is included with reverts should not be assumed stable unless otherwise specified.

=== Major Releases

Major releases should be assumed incompatible. Nevertheless, the external interfaces of contracts will remain compatible if they are standardized, or if the maintainers judge that changing them would cause significant strain on the ecosystem.

An important aspect that major releases may break is "upgrade compatibility", in particular storage layout compatibility. It will never be safe for a live contract to upgrade from one major release to another.

== Storage Layout

Minor and patch updates always preserve storage layout compatibility. This means that a live contract can be upgraded from one minor to another without corrupting the storage layout. In some cases it may be necessary to initialize new state variables when upgrading, although we expect this to be infrequent.

We recommend using xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins or CLI] to ensure storage layout safety of upgrades.

== Solidity Version

The minimum Solidity version required to compile the contracts will remain unchanged in minor and patch updates. New contracts introduced in minor releases may make use of newer Solidity features and require a more recent version of the compiler.
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Flexible xref:access-control.adoc[role-based permissioning] scheme.
* Reusable xref:utilities.adoc[Solidity components] to build custom contracts and complex decentralized systems.

IMPORTANT: OpenZeppelin Contracts uses semantic versioning to communicate backwards compatibility of its API and storage layout. For upgradeable contracts, the storage layout of different major versions should be assumed incompatible, for example, it is unsafe to upgrade from 4.9.3 to 5.0.0. Learn more at xref:backwards-compatibility.adoc[Backwards Compatibility].

== Overview

[[install]]
Expand All @@ -17,8 +19,6 @@
$ npm install @openzeppelin/contracts
```

OpenZeppelin Contracts features a xref:releases-stability.adoc#api-stability[stable API], which means that your contracts won't break unexpectedly when upgrading to a newer minor version.

==== Foundry (git)

WARNING: When installing via git, it is a common error to use the `master` branch. This is a development branch that should be avoided in favor of tagged releases. The release process involves security measures that the `master` branch does not guarantee.
Expand Down
85 changes: 0 additions & 85 deletions docs/modules/ROOT/pages/releases-stability.adoc

This file was deleted.

36 changes: 18 additions & 18 deletions scripts/upgradeable/upgradeable.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 2797a088..00000000
index 2797a0889..000000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,21 +0,0 @@
Expand All @@ -26,7 +26,7 @@ index 2797a088..00000000
-
-<!-- We will be able to better help if you provide a minimal example that triggers the bug. -->
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 4018cef2..d343a53d 100644
index 4018cef29..d343a53d8 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,4 +1,8 @@
Expand All @@ -40,7 +40,7 @@ index 4018cef2..d343a53d 100644
about: Ask in the OpenZeppelin Forum
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index ff596b0c..00000000
index ff596b0c3..000000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,14 +0,0 @@
Expand All @@ -59,29 +59,29 @@ index ff596b0c..00000000
-<!-- Make sure that you have reviewed the OpenZeppelin Contracts Contributor Guidelines. -->
-<!-- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/CONTRIBUTING.md -->
diff --git a/README.md b/README.md
index 38197f3a..bc934d1c 100644
index 53c29e5f8..666a667d3 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,9 @@
@@ -23,6 +23,9 @@
> [!IMPORTANT]
> OpenZeppelin Contracts uses semantic versioning to communicate backwards compatibility of its API and storage layout. For upgradeable contracts, the storage layout of different major versions should be assumed incompatible, for example, it is unsafe to upgrade from 4.9.3 to 5.0.0. Learn more at [Backwards Compatibility](https://docs.openzeppelin.com/contracts/backwards-compatibility).

:building_construction: **Want to scale your decentralized application?** Check out [OpenZeppelin Defender](https://openzeppelin.com/defender) — a secure platform for automating and monitoring your operations.

+> **Note**
+> You are looking at the upgradeable variant of OpenZeppelin Contracts. Be sure to review the documentation on [Using OpenZeppelin Contracts with Upgrades](https://docs.openzeppelin.com/contracts/4.x/upgradeable).
+
++> [!NOTE]
++> You are looking at the upgradeable variant of OpenZeppelin Contracts. Be sure to review the documentation on [Using OpenZeppelin Contracts with Upgrades](https://docs.openzeppelin.com/contracts/upgradeable).
++
## Overview

### Installation
@@ -26,7 +29,7 @@
@@ -30,7 +33,7 @@
#### Hardhat, Truffle (npm)

```
-$ npm install @openzeppelin/contracts
+$ npm install @openzeppelin/contracts-upgradeable
```

OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/contracts/releases-stability#api-stability), which means that your contracts won't break unexpectedly when upgrading to a newer minor version.
@@ -38,10 +41,10 @@ OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/con
#### Foundry (git)
@@ -40,10 +43,10 @@ $ npm install @openzeppelin/contracts
> **Warning** Foundry installs the latest version initially, but subsequent `forge update` commands will use the `master` branch.

```
Expand All @@ -94,7 +94,7 @@ index 38197f3a..bc934d1c 100644

### Usage

@@ -50,10 +53,11 @@ Once installed, you can use the contracts in the library by importing them:
@@ -52,10 +55,11 @@ Once installed, you can use the contracts in the library by importing them:
```solidity
pragma solidity ^0.8.20;

Expand All @@ -110,7 +110,7 @@ index 38197f3a..bc934d1c 100644
}
```
diff --git a/contracts/package.json b/contracts/package.json
index df141192..1cf90ad1 100644
index df141192d..1cf90ad14 100644
--- a/contracts/package.json
+++ b/contracts/package.json
@@ -1,5 +1,5 @@
Expand All @@ -130,7 +130,7 @@ index df141192..1cf90ad1 100644
"keywords": [
"solidity",
diff --git a/contracts/utils/cryptography/EIP712.sol b/contracts/utils/cryptography/EIP712.sol
index 3800804a..90c1db78 100644
index 644f6f531..ab8ba05ff 100644
--- a/contracts/utils/cryptography/EIP712.sol
+++ b/contracts/utils/cryptography/EIP712.sol
@@ -4,7 +4,6 @@
Expand Down Expand Up @@ -297,7 +297,7 @@ index 3800804a..90c1db78 100644
}
}
diff --git a/package.json b/package.json
index ffa868ac..e254d962 100644
index e6804c4cd..612ec513e 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
Expand All @@ -310,7 +310,7 @@ index ffa868ac..e254d962 100644
"keywords": [
"solidity",
diff --git a/test/utils/cryptography/EIP712.test.js b/test/utils/cryptography/EIP712.test.js
index 7ea535b7..32e3a370 100644
index faf01f1a3..b25171a56 100644
--- a/test/utils/cryptography/EIP712.test.js
+++ b/test/utils/cryptography/EIP712.test.js
@@ -47,26 +47,6 @@ contract('EIP712', function (accounts) {
Expand Down

0 comments on commit 53f2721

Please sign in to comment.