You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this transaction is successful, the new bytecode will be written to the VM.--
247
-
sidebar_position: 9
248
-
sidebar_label: 'Hot Upgrades'
249
-
description: 'Upgrading Framework Libraries'
250
-
---
251
-
252
-
253
-
254
-
# Network Hot Upgrades
255
-
256
-
## Overview
257
-
258
-
The "framework" which contains all the consensus, account, econ policies, etc. for the network is written in Move. This code is stored in the network database, and effectively executed on demand. This means that framework upgrades can occur without redeploying the Move VM itself, or the supporting system code (network node software). It also means the state machine can upgrade without a coordinated halt.
259
-
260
-
- To do this we require the `libra` cli tool. The command `libra move framework` is used for building the artifacts, and `libra txs` for proposing, voting, and ultimately deploying the artifacts.
261
-
262
-
- Metadata with the upgrade artifacts and proposal documentation can be found at: https://github.com/0LNetworkCommunity/upgrades
263
-
264
-
265
-
## Historical Upgrade Information and Proposing Upgrades
266
-
Historical upgrade information since release 7.0.0 is canonically stored in the [upgrade repository](https://github.com/0LNetworkCommunity/upgrades). To submit an upgrade proposal, you should draft a PR with the relevant information detailing the upgrade using the provided [template](https://github.com/0LNetworkCommunity/upgrades/tree/main/proposals/template) and include the upgrade script packages.
When performing upgrades within the network framework, two primary approaches can be employed: single and multiple module upgrades. The key distinction lies in how these upgrades are proposed, voted on, and executed, particularly with respect to handling multiple modules.
306
-
307
-
### Single Framework Upgrade
308
-
A single framework upgrade involves updating a singular set of modules within the framework. This process is straightforward and includes the following steps:
309
-
310
-
-**Build Framework**: Generate the upgrade Move transaction scripts for the module.
311
-
-**Proposal Submission**: Propose the upgrade for the specific framework module.
312
-
-**Validator Voting**: Validators within the network vote for or against the proposed upgrade.
313
-
-**Achieving Consensus**: The proposal moves forward once it receives support from at least 66% of active validators.
314
-
-**Resolution and Deployment**: Resolve the proposal using the exact framework directory that matches the build of the proposed upgrade. This can be done by any validator using the same release branch from the `libra-framework` repository.
315
-
316
-
### Multiple Framework Upgrades
317
-
Multiple framework upgrades require a more nuanced approach, especially regarding resolution stages, to ensure a coherent and secure update across several modules.
318
-
319
-
-**Build Framework**: Similar to a single upgrade, start by generating Move transaction scripts for all relevant modules.
320
-
321
-
-**Proposal for Initial Module**: Propose the upgrade by using the first module (`1-move-stdlib`). This initial proposal is critical as it kickstarts the governance process for the entire upgrade.
322
-
323
-
*WARN: Do not repeat proposals for subsequent modules, the three modules can be upgraded with a single instance.*
324
-
325
-
Importantly, the transaction script for upgrading this first module includes a significant addition: **the transaction hash for the subsequent modules** that needs upgrading. These hashes, produced during the artifact building phase, serve as secure identifiers for each module's upgrade script. Do not run this step twice.
326
-
327
-
-**Validator Voting**: As with single upgrades, validators vote for or against the proposed upgrade.
328
-
-**Achieving Consensus and Sequential Resolution**: Once at least 66% of active validators support the proposal, the initial upgrade can be resolved.
329
-
-**Sequential Upgrade Execution**: Execute the resolution process for all involved modules, following the order 1-3.
330
-
331
-
332
-
## Upgrade Policy
333
-
The diem framework has information in the metadata that controls the policy that a publisher can set for upgrading their modules. These are:
334
-
- Arbitrary(0): Allows code upgrades without compatibility checks, for non-shared packages.
335
-
- Compatible(1): Requires compatibility checks to ensure no breaking changes in public functions or resource layouts.
336
-
- Immutable(2): Prevents any upgrades, ensuring the permanence of critical code.
337
-
338
-
Due to some circumstances, a publisher may want to downgrade the policy to allow changes to go through that a restrictive policy would not allow. We can do this by building the framework with a flag(`--danger-force-upgrade`) that sets the upgrade policy as Arbitrary
We will use this guide to do a multi-step upgrade as this is the most common upgrade that is done.
349
-
350
-
### Build Artifacts
351
-
352
-
##### 1. Build the upgrade Move transaction scripts
353
-
354
-
This will be a Move package which is machine-generated for a one-time execution. It contains bytecode which will be allowed to be executed (by anyone), once there is a vote and agreement on the proposal passing. The on-chain execution is guarded with a hash of this transaction, which the proposer provides in the proposal transaction (in advance of the vote).
355
-
356
-
An upgrade script that is tampered with will yield a different execution hash, and will be prevented from running (it is likely to be blocked by the transaction size limits before entering the mempool).
357
-
358
-
The `libra-framework upgrade` command will produce a newly compiled Move upgrade transaction script, its binary, and the hash.
359
-
360
-
You need to provide:
361
-
-`--output-dir`: this directory the upgrade transaction files should be saved to. A new folder called `framework_upgrade` will be created under the output-dir path.
362
-
363
-
-`--framework-local-dir`: the source code for the framework so that the transaction script can import it as a dependency.
364
-
365
-
Optionally you could provide the flag `--danger-force-upgrade
366
-
367
-
#### Multi or Single Upgrade
368
-
Know the difference between a single step, and multi-step upgrades.
369
-
An upgrade that changes, all three (stdlib, vendor-stdlib, libra-framework) looks like this:
#### NOTE: This creates 3 separate library upgrade script directories
392
-
- 1-move-stdlib
393
-
- 2-vendor-stdlib
394
-
- 3-libra-framework
395
-
396
-
All the artifacts are now created, the proposal transaction can be submitted. But it's a good idea to document this on github first.
397
-
398
-
# Light: Only update one of the modules
399
-
If the code is backwards compatible you can update a single module. This can be true for `libra-framework`, when there are no changes to `stdlib` or `vendor-stdlib`.
400
-
401
-
In that case you can include the argument `--core-modules libra-framework`
If you already have this upgrades repo locally, you should run the command in the previous step (build artifacts) with `--output-dir` pointed to `./upgrades/proposals/up-000x`
421
-
422
-
423
-
### Upgrade Ceremony
424
-
425
-
##### 3. With `txs` anyone (no authority needed) can submit the proposal and metadata.
426
-
427
-
You'll need to provide the actual script compiled path, and an optional URL which contains documentation of the proposal (e.g github).
428
-
429
-
```
430
-
431
-
# NOTE: multi-step upgrades (all modules) only need ONE proposal, and it should reference the first module, usually 1-move-stdlib
##### 4. With `libra txs` anyone with governance authority (the epoch's validators as of `V7`), can submit a vote in favor (or against it with `--should-fail`).
450
-
451
-
We assume the default is to vote in favor. To vote "approve" simply:
After everyone has voted (to reach the consensus threshold of 66% as of `V7`), the proposal will be in a "Resolvable" state. Anyone can resolve it by submitting the upgrade transaction. This means the sender must have the source transaction script for the upgrade (step #1 above).
468
-
469
-
##### 6. Use `txs` to resolve a successfully approved proposal
0 commit comments