Skip to content

Commit

Permalink
Merge pull request fedimint#5605 from dpc/24-07-11-rel-notes-upgrade
Browse files Browse the repository at this point in the history
chore: require acking v0.4 upgrade instructions via env var
  • Loading branch information
dpc authored Jul 12, 2024
2 parents 389c26d + 515b74e commit 2bcd381
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
1 change: 1 addition & 0 deletions devimint/src/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ declare_vars! {
FM_API_SECRET: Option<String> = std::env::var("FM_API_SECRET").ok().or_else(|| FM_FORCE_API_SECRETS.get_active()); env: "FM_API_SECRET";

FM_IN_DEVIMINT: String = "1".to_string(); env: FM_IN_DEVIMINT_ENV;
FM_SKIP_REL_NOTES_ACK: String = "1".to_string(); env: "FM_SKIP_REL_NOTES_ACK";

FM_FED_SIZE: usize = fed_size; env: "FM_FED_SIZE";
FM_OFFLINE_NODES: usize = offline_nodes; env: "FM_OFFLINE_NODES";
Expand Down
30 changes: 30 additions & 0 deletions docs/RELEASE_NOTES-v0.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Important Fedimint v0.4 Release Notes

This document describes only critically important release notes.
For all the non-critical release notes, see usual places (like github release pages).

### Lock-step upgrade requirement

Upgrading existing Federations that were created using previous (pre v0.4.x)
versions of `fedimintd` requires stopping all peers at the exact same session count
(mint's internal consensus height), and switching to new v0.4.x release at the same time,
before starting them again.


To schedule stopping your `fedimintd` at specific consensus height you can
use `fedimin-cli` command:

**Details to be described in the near feature. Check newer version of this document.**

### Acknowledging

To acknowledge that you are aware of requirements described above please set:

```
FM_REL_NOTES_ACK=0_4_xyz
```

in your `fedimintd` environment when running `fedimintd v0.4.x`.

If you are a `fedimintd` integrator (e.g. wrap `fedimintd` in shell scripts, Dockerfiles, NixOS modules, etc.),
please make sure the end user/operator of `fedimintd` is required to set it.
36 changes: 34 additions & 2 deletions fedimintd/src/fedimintd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::net::SocketAddr;
use std::path::PathBuf;
use std::time::Duration;

use anyhow::{format_err, Context};
use anyhow::{bail, format_err, Context};
use clap::{Parser, Subcommand};
use fedimint_core::admin_client::ConfigGenParamsRequest;
use fedimint_core::config::{
Expand Down Expand Up @@ -39,7 +39,7 @@ use fedimint_wallet_server::common::config::{
};
use fedimint_wallet_server::WalletInit;
use futures::FutureExt;
use tracing::{debug, error, info};
use tracing::{debug, error, info, warn};

use crate::default_esplora_server;
use crate::envs::{
Expand Down Expand Up @@ -215,6 +215,7 @@ impl Fedimintd {
);

handle_version_hash_command(code_version_hash);
check_release_notes_ack()?;

let fedimint_version = env!("CARGO_PKG_VERSION");

Expand Down Expand Up @@ -464,6 +465,37 @@ impl Fedimintd {
}
}

fn check_release_notes_ack() -> anyhow::Result<()> {
const VERSION: &str = "v0.4";
const FM_SKIP_REL_NOTES_ACK_ENV: &str = "FM_SKIP_REL_NOTES_ACK";
const FM_REL_NOTES_ACK_ENV: &str = "FM_REL_NOTES_ACK";
// the suffix here is to prevent people getting to smart and trying to
// automate-it-out change it for every release
const FM_REL_NOTES_CUR_VAL: &str = "0_4_xyz";

// This is here only for upgrade tests and other automated tests, where
// juggling different values might be impossible.
if is_env_var_set(FM_SKIP_REL_NOTES_ACK_ENV) {
warn!("Skipping release notes ack. This should never be happening in production");
return Ok(());
}

// The actual code-path we want end users to take
if std::env::var(FM_REL_NOTES_ACK_ENV).unwrap_or_default() == FM_REL_NOTES_CUR_VAL {
return Ok(());
}

eprintln!(
"This version of fedimintd has some criticallly important requirements you should be aware of."
);
eprintln!("Not following them will likely result in a consensus failure or other problems.");
eprintln!("To ensure you have read them, you must set specific environment variable to a specific value.");
eprintln!("Robustness and safety of your federations is our primary concern.");
eprintln!("See https://github.com/fedimint/fedimint/blob/releases/{VERSION}/docs/RELEASE_NOTES-{VERSION}.md");

bail!("Must acknowledge release notes. See details above.")
}

async fn run(
opts: ServerOpts,
task_group: &TaskGroup,
Expand Down

0 comments on commit 2bcd381

Please sign in to comment.