Skip to content

Commit

Permalink
feat: add mainnet channel, remove betas (#677)
Browse files Browse the repository at this point in the history
* feat: add mainnet channel, remove betas

* update test

* add missing import

* clippy

* remove beta-1 test

* clippy

* rename to is_dateless_distributed_toolchain

* point latest to mainnet

* update docs

* Update link for mainnet
  • Loading branch information
sdankel authored Oct 15, 2024
1 parent 5316d29 commit b442d9e
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 129 deletions.
27 changes: 7 additions & 20 deletions docs/src/concepts/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

<!-- This section should give an overview of fuelup channels -->
<!-- channels:example:start -->
`fuelup` adopts a simplified version of `rustup` [channels](https://rust-lang.github.io/rustup/concepts/channels.html). Currently, the `latest`, `nightly`, `testnet`, and `beta` channels are published and serve as a source of distribution of Fuel toolchain binaries.
`fuelup` adopts a simplified version of `rustup` [channels](https://rust-lang.github.io/rustup/concepts/channels.html). Currently, the `latest`, `nightly`, `testnet`, and `mainnet` channels are published and serve as a source of distribution of Fuel toolchain binaries.

| Channel | Source | Integration Tested | Update Frequency | Available |
| ------------- | --------------- | -------------------- | ------------------------ | --------- |
| **[latest]** | published bins | ✔️ | only when necessary | ✔️ |
| **[nightly]** | `master` branch || nightly (1:00 AM UTC) | ✔️ |
| **[testnet]** | published bins || only when necessary | ✔️ |
| **[beta-5]** | published bins || only when necessary | ✔️ |
| **[beta-4]** | published bins || only when necessary | ✔️ |
| **[beta-3]** | published bins || only when necessary | ✔️ |
| **[mainnet]** | published bins || only when necessary | ✔️ |
| **[testnet]** | published bins || only when necessary | ✔️ |
<!-- channels:example:end -->

## The `latest` channel
Expand Down Expand Up @@ -39,21 +37,13 @@ You should use `nightly` if you want the latest changes to `master` that have no
Keep in mind that compatibility between `forc` and `fuel-core` is not guaranteed here, and you should expect unstable features to break.
<!-- nightly:example:end -->

## The `testnet` channel

The `testnet` channel is a published TOML file describing the toolchain that is compatible with our final public [testnet](https://fuel.mirror.xyz/fztu8P_NJz6k7qLXhaGHX3ArctlQpxsUp87pgRpJ4bE) on the Sepolia network. This toolchain should be used to interact with and build on the testnet. The components to be installed can be found [here](https://github.com/FuelLabs/fuelup/blob/gh-pages/channel-fuel-testnet.toml).

## The `beta-5` channel
## The `mainnet` channel

The `beta-5` channel is a published TOML file describing the toolchain that is compatible with our [beta-5 testnet](https://fuel.mirror.xyz/5JCTjM3jSG84QYLKqQ4idHf6X_zVtwTInQvg7kWhaMA). The components to be installed can be found [here](https://github.com/FuelLabs/fuelup/blob/gh-pages/channel-fuel-beta-5.toml).
The `mainnet` channel is a published TOML file describing the toolchain that is compatible with our final public [mainnet](https://fuel.mirror.xyz/U2xqey0oZFCrIBf7bO3yYyFplJKiJ0sfzAyYmhrPjag) on the Ignition network. This toolchain should be used to interact with and build on the mainnet. The components to be installed can be found [here](https://github.com/FuelLabs/fuelup/blob/gh-pages/channel-fuel-mainnet.toml).

## The `beta-4` channel

The `beta-4` channel is a published TOML file describing the toolchain that is compatible with our [beta-4 testnet](https://fuel-labs.ghost.io/announcing-beta-4-testnet/). The components to be installed can be found [here](https://github.com/FuelLabs/fuelup/blob/gh-pages/channel-fuel-beta-4.toml).

## The `beta-3` channel
## The `testnet` channel

The `beta-3` channel is a published TOML file describing the toolchain that is compatible with our [beta-3 testnet](https://fuel-labs.ghost.io/announcing-beta-3-testnet/). The components to be installed can be found [here](https://github.com/FuelLabs/fuelup/blob/gh-pages/channel-fuel-beta-3.toml).
The `testnet` channel is a published TOML file describing the toolchain that is compatible with our final public [testnet](https://fuel.mirror.xyz/fztu8P_NJz6k7qLXhaGHX3ArctlQpxsUp87pgRpJ4bE) on the Sepolia network. This toolchain should be used to interact with and build on the testnet. The components to be installed can be found [here](https://github.com/FuelLabs/fuelup/blob/gh-pages/channel-fuel-testnet.toml).

## Developer Guide

Expand Down Expand Up @@ -93,6 +83,3 @@ You may also use [`nektos/act`](https://github.com/nektos/act) to run the workfl
[latest]: #the-latest-channel
[nightly]: #the-nightly-channel
[testnet]: #the-testnet-channel
[beta-5]: #the-beta-5-channel
[beta-4]: #the-beta-4-channel
[beta-3]: #the-beta-3-channel
6 changes: 3 additions & 3 deletions docs/src/developer_guide/building_a_channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ There may be times when we need a channel for a one-off event e.g. testnets. Dur

require a routine update, and can essentially publish once and be done. This is when manual publishing is done.

For example, building a `beta-3` toolchain is done like so:
For example, building a `testnet` toolchain is done like so:

```sh
# from fuelup project root
cd ci/build-channel && cargo run -- channel-fuel-beta-3.toml 2023-02-13 forc=0.35.0 fuel-core=0.17.1
cd ci/build-channel && cargo run -- channel-fuel-testnet.toml 2023-02-13 forc=0.35.0 fuel-core=0.17.1
```

The above command means that we're building a channel named `channel-fuel-beta-3.toml` with the date `2023-02-13` (`YYYY-MM-DD`)
The above command means that we're building a channel named `channel-fuel-testnet.toml` with the date `2023-02-13` (`YYYY-MM-DD`)
and `forc` and `fuel-core` versions `0.35.0` and `0.17.1` respectively, and the latest versions for the other unlisted components.

Other than for these one-off events, manually running `build-channel` locally is a good sanity check when working
Expand Down
12 changes: 6 additions & 6 deletions docs/src/overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ $ tree -L 1 # 'tree -L 1' shows the project structure up to the depth of 1

### Examples

An application using the [`beta-3`] toolchain:
An application using the [`testnet`] toolchain:

```toml
[toolchain]
channel = "beta-3"
channel = "testnet"
```

Let's say we have a project on the `beta-3` testnet, and we want to try using a different version forc to develop on it:
Let's say we have a project on the Fuel testnet network, and we want to try using a different version forc to develop on it:

```toml
[toolchain]
channel = "beta-3"
channel = "testnet"

[components]
forc = "0.36.0" # in beta-3, forc is pinned to v0.37.3
forc = "0.65.0" # in testnet, forc is pinned to v0.66.1
```

[toolchain]: concepts/toolchains.md
[distributed toolchains]: concepts/toolchains.md#toolchains
[`beta-3`]: concepts/channels.md#the-beta-3-channel
[`testnet`]: concepts/channels.md#the-testnet-channel
35 changes: 8 additions & 27 deletions src/channel.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::{
constants::{
CHANNEL_BETA_1_FILE_NAME, CHANNEL_BETA_2_FILE_NAME, CHANNEL_BETA_3_FILE_NAME,
CHANNEL_BETA_4_FILE_NAME, CHANNEL_BETA_5_FILE_NAME, CHANNEL_DEVNET_FILE_NAME,
CHANNEL_LATEST_FILE_NAME, CHANNEL_NIGHTLY_FILE_NAME, CHANNEL_TESTNET_FILE_NAME,
DATE_FORMAT_URL_FRIENDLY, FUELUP_GH_PAGES,
CHANNEL_LATEST_FILE_NAME, CHANNEL_MAINNET_FILE_NAME, CHANNEL_NIGHTLY_FILE_NAME,
CHANNEL_TESTNET_FILE_NAME, DATE_FORMAT_URL_FRIENDLY, FUELUP_GH_PAGES,
},
download::{download, DownloadCfg},
toolchain::{DistToolchainDescription, DistToolchainName},
Expand All @@ -19,18 +17,12 @@ use tracing::warn;

pub const LATEST: &str = "latest";
pub const STABLE: &str = "stable";
pub const BETA_1: &str = "beta-1";
pub const BETA_2: &str = "beta-2";
pub const BETA_3: &str = "beta-3";
pub const BETA_4: &str = "beta-4";
pub const BETA_5: &str = "beta-5";
pub const DEVNET: &str = "devnet";
pub const IGNITION: &str = "ignition";
pub const TESTNET: &str = "testnet";
pub const MAINNET: &str = "mainnet";
pub const NIGHTLY: &str = "nightly";

pub const CHANNELS: [&str; 9] = [
LATEST, NIGHTLY, BETA_1, BETA_2, BETA_3, BETA_4, BETA_5, DEVNET, TESTNET,
];
pub const CHANNELS: [&str; 4] = [LATEST, NIGHTLY, TESTNET, MAINNET];

#[derive(Debug, Deserialize, Serialize)]
pub struct HashedBinary {
Expand All @@ -50,14 +42,8 @@ pub struct Package {
pub fuels_version: Option<String>,
}

pub fn is_beta_toolchain(name: &str) -> bool {
name == BETA_1
|| name == BETA_2
|| name == BETA_3
|| name == BETA_4
|| name == BETA_5
|| name == DEVNET
|| name == TESTNET
pub fn is_dateless_distributed_toolchain(name: &str) -> bool {
name == TESTNET || name == MAINNET
}

fn format_nightly_url(date: &Date) -> Result<String> {
Expand Down Expand Up @@ -85,13 +71,8 @@ fn construct_channel_url(desc: &DistToolchainDescription) -> Result<String> {
}
url.push_str(CHANNEL_NIGHTLY_FILE_NAME);
}
DistToolchainName::Beta1 => url.push_str(CHANNEL_BETA_1_FILE_NAME),
DistToolchainName::Beta2 => url.push_str(CHANNEL_BETA_2_FILE_NAME),
DistToolchainName::Beta3 => url.push_str(CHANNEL_BETA_3_FILE_NAME),
DistToolchainName::Beta4 => url.push_str(CHANNEL_BETA_4_FILE_NAME),
DistToolchainName::Beta5 => url.push_str(CHANNEL_BETA_5_FILE_NAME),
DistToolchainName::Devnet => url.push_str(CHANNEL_DEVNET_FILE_NAME),
DistToolchainName::Testnet => url.push_str(CHANNEL_TESTNET_FILE_NAME),
DistToolchainName::Mainnet => url.push_str(CHANNEL_MAINNET_FILE_NAME),
};

Ok(url)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum ToolchainCommand {

#[derive(Debug, Parser)]
pub struct InstallCommand {
/// Toolchain name [possible values: latest, nightly, testnet, beta-1, beta-2, beta-3, beta-4, beta-5]
/// Toolchain name [possible values: latest, nightly, testnet, mainnet]
pub name: String,
}

Expand Down
9 changes: 2 additions & 7 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@ pub const FUELS_VERSION_FILE: &str = "fuels_version";

pub const CHANNEL_LATEST_URL: &str =
"https://raw.githubusercontent.com/FuelLabs/fuelup/gh-pages/channel-fuel-testnet.toml";
pub const CHANNEL_LATEST_FILE_NAME: &str = "channel-fuel-testnet.toml";
pub const CHANNEL_NIGHTLY_FILE_NAME: &str = "channel-fuel-nightly.toml";
pub const CHANNEL_BETA_1_FILE_NAME: &str = "channel-fuel-beta-1.toml";
pub const CHANNEL_BETA_2_FILE_NAME: &str = "channel-fuel-beta-2.toml";
pub const CHANNEL_BETA_3_FILE_NAME: &str = "channel-fuel-beta-3.toml";
pub const CHANNEL_BETA_4_FILE_NAME: &str = "channel-fuel-beta-4.toml";
pub const CHANNEL_BETA_5_FILE_NAME: &str = "channel-fuel-beta-5.toml";
pub const CHANNEL_DEVNET_FILE_NAME: &str = "channel-fuel-devnet.toml";
pub const CHANNEL_TESTNET_FILE_NAME: &str = "channel-fuel-testnet.toml";
pub const CHANNEL_MAINNET_FILE_NAME: &str = "channel-fuel-mainnet.toml";
pub const CHANNEL_LATEST_FILE_NAME: &str = CHANNEL_MAINNET_FILE_NAME;

pub const DATE_FORMAT: &[FormatItem] = format_description!("[year]-[month]-[day]");
pub const DATE_FORMAT_URL_FRIENDLY: &[FormatItem] = format_description!("[year]/[month]/[day]");
2 changes: 1 addition & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ mod tests {
fn test_agent() -> anyhow::Result<()> {
// this test case is used to illustrate the bug of ureq that sometimes doesn't return "Content-Length" header
let handle = build_agent()?;
let response = handle.get("https://raw.githubusercontent.com/FuelLabs/fuelup/gh-pages/channel-fuel-beta-4.toml").call()?;
let response = handle.get("https://raw.githubusercontent.com/FuelLabs/fuelup/gh-pages/channel-fuel-testnet.toml").call()?;
assert!(response.header("Content-Length").is_none());
Ok(())
}
Expand Down
29 changes: 5 additions & 24 deletions src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,28 @@ use tracing::{error, info};

pub const RESERVED_TOOLCHAIN_NAMES: &[&str] = &[
channel::LATEST,
channel::BETA_1,
channel::BETA_2,
channel::BETA_3,
channel::BETA_4,
channel::BETA_5,
channel::NIGHTLY,
channel::DEVNET,
// Stable is reserved, although currently unused.
channel::STABLE,
// Ignition is reserved, although currently unused.
channel::IGNITION,
];

#[derive(Debug, Eq, PartialEq)]
pub enum DistToolchainName {
Beta1,
Beta2,
Beta3,
Beta4,
Beta5,
Latest,
Nightly,
Devnet,
Testnet,
Mainnet,
}

impl fmt::Display for DistToolchainName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
DistToolchainName::Latest => write!(f, "{}", channel::LATEST),
DistToolchainName::Nightly => write!(f, "{}", channel::NIGHTLY),
DistToolchainName::Beta1 => write!(f, "{}", channel::BETA_1),
DistToolchainName::Beta2 => write!(f, "{}", channel::BETA_2),
DistToolchainName::Beta3 => write!(f, "{}", channel::BETA_3),
DistToolchainName::Beta4 => write!(f, "{}", channel::BETA_4),
DistToolchainName::Beta5 => write!(f, "{}", channel::BETA_5),
DistToolchainName::Devnet => write!(f, "{}", channel::DEVNET),
DistToolchainName::Testnet => write!(f, "{}", channel::TESTNET),
DistToolchainName::Mainnet => write!(f, "{}", channel::MAINNET),
}
}
}
Expand All @@ -72,13 +58,8 @@ impl FromStr for DistToolchainName {
match s {
channel::LATEST => Ok(Self::Latest),
channel::NIGHTLY => Ok(Self::Nightly),
channel::BETA_1 => Ok(Self::Beta1),
channel::BETA_2 => Ok(Self::Beta2),
channel::BETA_3 => Ok(Self::Beta3),
channel::BETA_4 => Ok(Self::Beta4),
channel::BETA_5 => Ok(Self::Beta5),
channel::DEVNET => Ok(Self::Devnet),
channel::TESTNET => Ok(Self::Testnet),
channel::MAINNET => Ok(Self::Mainnet),
_ => bail!("Unknown name for toolchain: {}", s),
}
}
Expand Down
19 changes: 9 additions & 10 deletions src/toolchain_override.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
channel::{is_beta_toolchain, LATEST, NIGHTLY},
channel::{is_dateless_distributed_toolchain, LATEST, NIGHTLY},
constants::{DATE_FORMAT, FUEL_TOOLCHAIN_TOML_FILE},
download::DownloadCfg,
file,
Expand Down Expand Up @@ -69,7 +69,7 @@ where
|_| {
Err(Error::invalid_value(
serde::de::Unexpected::Str(&channel_str),
&"one of <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|beta-1|beta-2|beta-3|beta-4|beta-5|testnet|devnet>",
&"one of <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|testnet|mainnet>",
))
},
Result::Ok,
Expand All @@ -88,7 +88,7 @@ impl fmt::Display for Channel {
impl FromStr for Channel {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self> {
if is_beta_toolchain(s) {
if is_dateless_distributed_toolchain(s) {
return Ok(Self {
name: s.to_string(),
date: None,
Expand Down Expand Up @@ -213,7 +213,7 @@ impl OverrideCfg {
#[cfg(test)]
mod tests {
use super::*;
use crate::channel::{BETA_1, BETA_2, BETA_3, NIGHTLY};
use crate::channel::{MAINNET, NIGHTLY, TESTNET};
use indoc::indoc;

#[test]
Expand Down Expand Up @@ -262,15 +262,15 @@ mod tests {
let e = result.unwrap_err();
assert_eq!(e
.to_string(),
"invalid value: string \"latest\", expected one of <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|beta-1|beta-2|beta-3|beta-4|beta-5|testnet|devnet> for key `toolchain.channel`".to_string());
"invalid value: string \"latest\", expected one of <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|testnet|mainnet> for key `toolchain.channel`".to_string());

let result = OverrideCfg::from_toml(NIGHTLY);
assert!(result.is_err());
let e = result.unwrap_err();

assert_eq!(e
.to_string(),
"invalid value: string \"nightly\", expected one of <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|beta-1|beta-2|beta-3|beta-4|beta-5|testnet|devnet> for key `toolchain.channel`".to_string());
"invalid value: string \"nightly\", expected one of <latest-YYYY-MM-DD|nightly-YYYY-MM-DD|testnet|mainnet> for key `toolchain.channel`".to_string());
}

#[test]
Expand All @@ -285,7 +285,7 @@ mod tests {
"#};
const EMPTY_COMPONENTS: &str = indoc! {r#"
[toolchain]
channel = "beta-2"
channel = "testnet"
[components]
"#};
Expand All @@ -302,9 +302,8 @@ mod tests {

#[test]
fn channel_from_str() {
assert!(Channel::from_str(BETA_1).is_ok());
assert!(Channel::from_str(BETA_2).is_ok());
assert!(Channel::from_str(BETA_3).is_ok());
assert!(Channel::from_str(TESTNET).is_ok());
assert!(Channel::from_str(MAINNET).is_ok());
assert!(Channel::from_str(NIGHTLY).is_err());
assert!(Channel::from_str(LATEST).is_err());
}
Expand Down
14 changes: 1 addition & 13 deletions tests/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use fuelup::target_triple::TargetTriple;
use testcfg::FuelupState;

#[test]
fn fuelup_check() -> Result<()> {
fn test_fuelup_check() -> Result<()> {
let latest = format!("latest-{}", TargetTriple::from_host().unwrap());
let beta_1 = format!("beta-1-{}", TargetTriple::from_host().unwrap());
let forc = "forc -";
let fuel_core = "fuel-core -";
let fuel_indexer = "fuel-indexer -";
Expand All @@ -31,16 +30,5 @@ fn fuelup_check() -> Result<()> {
assert!(stdout.contains(fuel_core));
})?;

// Test that toolchain names with '-' inside are parsed correctly.
testcfg::setup(FuelupState::Beta1Installed, &|cfg| {
let output = cfg.fuelup(&["check", "--verbose"]);
let stripped = strip_ansi_escapes::strip(output.stdout);
let stdout = String::from_utf8_lossy(&stripped);
assert!(stdout.contains(&beta_1));
assert!(stdout.contains(forc));
assert!(stdout.contains(fuel_core));
assert!(!stdout.contains(fuel_indexer));
})?;

Ok(())
}
4 changes: 2 additions & 2 deletions tests/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ fn fuelup_default_nightly_and_nightly_date() -> Result<()> {

#[test]
fn fuelup_default_override() -> Result<()> {
testcfg::setup(FuelupState::LatestWithBetaOverride, &|cfg| {
testcfg::setup(FuelupState::LatestWithTestnetOverride, &|cfg| {
let output = cfg.fuelup(&["default"]);
let triple = TargetTriple::from_host().unwrap();
let expected_stdout = format!("beta-1-{triple} (override), latest-{triple} (default)\n");
let expected_stdout = format!("testnet-{triple} (override), latest-{triple} (default)\n");
assert_eq!(output.stdout, expected_stdout);
})?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions tests/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn fuelup_show_custom() -> Result<()> {

#[test]
fn fuelup_show_override() -> Result<()> {
testcfg::setup(FuelupState::LatestWithBetaOverride, &|cfg| {
testcfg::setup(FuelupState::LatestWithTestnetOverride, &|cfg| {
let stripped = strip_ansi_escapes::strip(cfg.fuelup(&["show"]).stdout);
let stdout = String::from_utf8_lossy(&stripped);
let target = TargetTriple::from_host().unwrap();
Expand All @@ -188,7 +188,7 @@ fn fuelup_show_override() -> Result<()> {
active toolchain
----------------
beta-1-{target} (override), path: {}
testnet-{target} (override), path: {}
forc : not found
- forc-client
- forc-deploy : not found
Expand Down
Loading

0 comments on commit b442d9e

Please sign in to comment.