Skip to content

Commit

Permalink
Add network cli flag (#1423)
Browse files Browse the repository at this point in the history
Closes #1422

This change also discontinues publishing a dedicated "testnet" docker
container and adds support for the "anagami" testnet.
  • Loading branch information
ChrisSchinnerl authored Aug 12, 2024
2 parents 050aff6 + 2f54bc4 commit 5c61f36
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 362 deletions.
120 changes: 10 additions & 110 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ env:
jobs:
docker:
runs-on: ubuntu-latest
strategy:
matrix:
network: ["mainnet" , "zen"]
permissions:
packages: write
steps:
Expand All @@ -35,31 +32,18 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare environment variables
run: |
if [[ "${{ matrix.network }}" == "zen" ]]; then
echo "BUILD_TAGS=testnet netgo" >> $GITHUB_ENV
echo "DOCKER_METADATA_SUFFIX=-zen" >> $GITHUB_ENV
else
echo "BUILD_TAGS=netgo" >> $GITHUB_ENV
echo "DOCKER_METADATA_SUFFIX=" >> $GITHUB_ENV
fi
- uses: docker/metadata-action@v4
name: Generate tags
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=${{ env.DOCKER_METADATA_SUFFIX }},onlatest=true
tags: |
type=ref,event=branch
type=sha,prefix=
type=semver,pattern={{version}}
- uses: docker/build-push-action@v4
with:
context: .
build-args: |
BUILD_TAGS=${{ env.BUILD_TAGS }}
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
Expand All @@ -68,7 +52,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
network: ["mainnet" , "zen"]
arch: [ amd64, arm64 ]
steps:
- uses: actions/checkout@v4
Expand All @@ -83,53 +66,25 @@ jobs:
sudo apt install -y gcc-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
fi
- name: Set build tag environment variable
run: |
if [[ "${{ matrix.network }}" == "zen" ]]; then
echo "BUILD_TAGS=testnet netgo" >> $GITHUB_ENV
echo "ZIP_OUTPUT_SUFFIX=_zen" >> $GITHUB_ENV
else
echo "BUILD_TAGS=netgo" >> $GITHUB_ENV
echo "ZIP_OUTPUT_SUFFIX=" >> $GITHUB_ENV
fi
- name: Build ${{ matrix.arch }}
env:
CGO_ENABLED: 1
GOOS: linux
GOARCH: ${{ matrix.arch }}
run: |
mkdir -p release
ZIP_OUTPUT=release/renterd${{ env.ZIP_OUTPUT_SUFFIX }}_${GOOS}_${GOARCH}.zip
go build -tags="$BUILD_TAGS" -trimpath -o bin/ -a -ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/renterd
ZIP_OUTPUT=release/renterd_${GOOS}_${GOARCH}.zip
go build -trimpath -o bin/ -a -ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/renterd
cp README.md LICENSE bin/
zip -qj $ZIP_OUTPUT bin/*
- name: Get Release Asset
uses: actions/github-script@v7
id: get_release_asset
env:
ARCH: ${{ matrix.arch }}
NETWORK: ${{ matrix.network }}
with:
result-encoding: string
script: |
const arch = process.env.ARCH,
network = process.env.NETWORK;
switch (network) {
case 'mainnet':
return `renterd_linux_${arch}`;
default:
return `renterd_${network}_linux_${arch}`;
}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_release_asset.outputs.result }}
path: release/
name: renterd_linux_${{ matrix.arch }}
path: release/*
build-mac:
runs-on: macos-latest
strategy:
matrix:
network: ["mainnet" , "zen"]
arch: [ amd64, arm64 ]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -169,15 +124,6 @@ jobs:
# generate
go generate ./...
- name: Set build tag environment variable
run: |
if [[ "${{ matrix.network }}" == "zen" ]]; then
echo "BUILD_TAGS=testnet netgo" >> $GITHUB_ENV
echo "ZIP_OUTPUT_SUFFIX=_zen" >> $GITHUB_ENV
else
echo "BUILD_TAGS=netgo" >> $GITHUB_ENV
echo "ZIP_OUTPUT_SUFFIX=" >> $GITHUB_ENV
fi
- name: Build ${{ matrix.arch }}
env:
APPLE_CERT_ID: ${{ secrets.APPLE_CERT_ID }}
Expand All @@ -193,53 +139,25 @@ jobs:
run: |
mkdir -p release
ZIP_OUTPUT=release/renterd${{ env.ZIP_OUTPUT_SUFFIX }}_${GOOS}_${GOARCH}.zip
go build -tags="$BUILD_TAGS" -trimpath -o bin/ -a -ldflags '-s -w' ./cmd/renterd
go build -trimpath -o bin/ -a -ldflags '-s -w' ./cmd/renterd
cp README.md LICENSE bin/
/usr/bin/codesign --deep -f -v --timestamp -o runtime,library -s $APPLE_CERT_ID bin/renterd
ditto -ck bin $ZIP_OUTPUT
xcrun notarytool submit -k ~/private_keys/AuthKey_$APPLE_API_KEY.p8 -d $APPLE_API_KEY -i $APPLE_API_ISSUER --wait --timeout 10m $ZIP_OUTPUT
- name: Get Release Asset
uses: actions/github-script@v7
id: get_release_asset
env:
ARCH: ${{ matrix.arch }}
NETWORK: ${{ matrix.network }}
with:
result-encoding: string
script: |
const arch = process.env.ARCH,
network = process.env.NETWORK;
switch (network) {
case 'mainnet':
return `renterd_darwin_${arch}`;
default:
return `renterd_${network}_darwin_${arch}`;
}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_release_asset.outputs.result }}
path: release/
name: renterd_darwin_${{ matrix.arch }}
path: release/*
build-windows:
runs-on: windows-latest
strategy:
matrix:
network: ["mainnet" , "zen"]
arch: [ amd64 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Set build tag environment variable
run: |
if ( "${{ matrix.network }}" -eq "zen" ) {
"BUILD_TAGS=testnet netgo" >> $env:GITHUB_ENV
"ZIP_OUTPUT_SUFFIX=_zen" >> $env:GITHUB_ENV
} else {
"BUILD_TAGS=netgo" >> $env:GITHUB_ENV
"ZIP_OUTPUT_SUFFIX=" >> $env:GITHUB_ENV
}
- name: Setup
shell: bash
run: |
Expand All @@ -254,32 +172,14 @@ jobs:
run: |
mkdir -p release
ZIP_OUTPUT=release/renterd${{ env.ZIP_OUTPUT_SUFFIX }}_${GOOS}_${GOARCH}.zip
go build -tags="$BUILD_TAGS" -trimpath -o bin/ -a -ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/renterd
go build -trimpath -o bin/ -a -ldflags '-s -w -linkmode external -extldflags "-static"' ./cmd/renterd
azuresigntool sign -kvu "${{ secrets.AZURE_KEY_VAULT_URI }}" -kvi "${{ secrets.AZURE_CLIENT_ID }}" -kvt "${{ secrets.AZURE_TENANT_ID }}" -kvs "${{ secrets.AZURE_CLIENT_SECRET }}" -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.digicert.com -v bin/renterd.exe
cp README.md LICENSE bin/
7z a $ZIP_OUTPUT bin/*
- name: Get Release Asset
uses: actions/github-script@v7
id: get_release_asset
env:
ARCH: ${{ matrix.arch }}
NETWORK: ${{ matrix.network }}
with:
result-encoding: string
script: |
const arch = process.env.ARCH,
network = process.env.NETWORK;
switch (network) {
case 'mainnet':
return `renterd_windows_${arch}`;
default:
return `renterd_${network}_windows_${arch}`;
}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.get_release_asset.outputs.result }}
path: release/
name: renterd_windows_${{ matrix.arch }}
path: release/*

combine-release-assets:
runs-on: ubuntu-latest
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ overview of all settings configurable through the CLI.
| `Directory` | Directory for storing node state | `.` | `--dir` | - | `directory` |
| `Seed` | Seed for the node | - | - | `RENTERD_SEED` | `seed` |
| `AutoOpenWebUI` | Automatically open the web UI on startup | `true` | `--openui` | - | `autoOpenWebUI` |
| `Network` | Network to run on (mainnet/zen/anagami) | `mainnet` | `--network` | `RENTERD_NETWORK` | `network` |
| `ShutdownTimeout` | Timeout for node shutdown | `5m` | `--node.shutdownTimeout` | - | `shutdownTimeout` |
| `Log.Level` | Global logger level (debug\|info\|warn\|error). Defaults to 'info' | `info` | `--log.level` | `RENTERD_LOG_LEVEL` | `log.level` |
| `Log.File.Enabled` | Enables logging to disk. Defaults to 'true' | `true` | `--log.file.enabled` | `RENTERD_LOG_FILE_ENABLED` | `log.file.enabled` |
Expand Down Expand Up @@ -408,14 +409,14 @@ ghcr.io/siafoundation/renterd.
version: "3.9"
services:
renterd:
image: ghcr.io/siafoundation/renterd:master-zen
image: ghcr.io/siafoundation/renterd:master
environment:
- RENTERD_SEED=put your seed here
- RENTERD_API_PASSWORD=test
ports:
- 9880:9880
- 9881:9881
- 7070:7070
- 9980:9980
- 9981:9981
- 8080:8080
volumes:
- ./data:/data
restart: unless-stopped
Expand All @@ -427,23 +428,16 @@ services:
From within the root of the repo run the following command to build an image of
`renterd` tagged `renterd`.

#### Mainnet

```sh
docker build -t renterd:master -f ./docker/Dockerfile .
```

#### Testnet

```sh
docker build --build-arg BUILD_TAGS='netgo testnet' -t renterd:master-zen -f ./docker/Dockerfile .
```

### Run Container

Run `renterd` in the background as a container named `renterd` that exposes its
API to the host system and the gateway to the world.


#### Mainnet

```bash
Expand All @@ -452,10 +446,16 @@ docker run -d --name renterd -e RENTERD_API_PASSWORD="<PASSWORD>" -e RENTERD_SEE

#### Testnet

To run `renterd` on testnet use the `RENTERD_NETWORK` environment variable.

```bash
docker run -d --name renterd-testnet -e RENTERD_API_PASSWORD="<PASSWORD>" -e RENTERD_SEED="<SEED>" -p 127.0.0.1:9880:9880/tcp -p :9881:9881/tcp ghcr.io/siafoundation/renterd:master-zen
docker run -d --name renterd -e RENTERD_API_PASSWORD="<PASSWORD>" -e RENTERD_NETWORK="<network>" -e RENTERD_SEED="<SEED>" -p 127.0.0.1:9980:9980/tcp -p :9981:9981/tcp ghcr.io/siafoundation/renterd:master
```

Currently available values for `<network>` are:
- `zen`
- `anagami`

## Architecture

`renterd` distinguishes itself from `siad` through a unique architecture
Expand Down
1 change: 1 addition & 0 deletions api/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type (
// BusStateResponse is the response type for the /bus/state endpoint.
BusStateResponse struct {
StartTime TimeRFC3339 `json:"startTime"`
Network string `json:"network"`
BuildState
}
)
48 changes: 48 additions & 0 deletions api/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,54 @@ var (
// ErrSettingNotFound is returned if a requested setting is not present in the
// database.
ErrSettingNotFound = errors.New("setting not found")

// DefaultGougingSettings define the default gouging settings the bus is
// configured with on startup. These values can be adjusted using the
// settings API.
//
DefaultGougingSettings = GougingSettings{
MaxRPCPrice: types.Siacoins(1).Div64(1000), // 1mS per RPC
MaxContractPrice: types.Siacoins(15), // 15 SC per contract
MaxDownloadPrice: types.Siacoins(3000), // 3000 SC per 1 TiB
MaxUploadPrice: types.Siacoins(3000), // 3000 SC per 1 TiB
MaxStoragePrice: types.Siacoins(3000).Div64(1 << 40).Div64(144 * 30), // 3000 SC per TiB per month
HostBlockHeightLeeway: 6, // 6 blocks
MinPriceTableValidity: 5 * time.Minute, // 5 minutes
MinAccountExpiry: 24 * time.Hour, // 1 day
MinMaxEphemeralAccountBalance: types.Siacoins(1), // 1 SC
MigrationSurchargeMultiplier: 10, // 10x
}

// DefaultPricePinSettings define the default price pin settings the bus is
// configured with on startup. These values can be adjusted using the
// settings API.
DefaultPricePinSettings = PricePinSettings{
Enabled: false,
}

// DefaultUploadPackingSettings define the default upload packing settings
// the bus is configured with on startup.
DefaultUploadPackingSettings = UploadPackingSettings{
Enabled: true,
SlabBufferMaxSizeSoft: 1 << 32, // 4 GiB
}

// DefaultRedundancySettings define the default redundancy settings the bus
// is configured with on startup. These values can be adjusted using the
// settings API.
//
// NOTE: default redundancy settings for testnet are different from mainnet.
DefaultRedundancySettings = RedundancySettings{
MinShards: 10,
TotalShards: 30,
}

// Same as DefaultRedundancySettings but for running on testnet networks due
// to their reduced number of hosts.
DefaultRedundancySettingsTestnet = RedundancySettings{
MinShards: 2,
TotalShards: 6,
}
)

type (
Expand Down
1 change: 0 additions & 1 deletion api/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
type (
// BuildState contains static information about the build.
BuildState struct {
Network string `json:"network"`
Version string `json:"version"`
Commit string `json:"commit"`
OS string `json:"os"`
Expand Down
1 change: 0 additions & 1 deletion autopilot/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ func (ap *Autopilot) stateHandlerGET(jc jape.Context) {

StartTime: api.TimeRFC3339(ap.StartTime()),
BuildState: api.BuildState{
Network: build.NetworkName(),
Version: build.Version(),
Commit: build.Commit(),
OS: runtime.GOOS,
Expand Down
Loading

0 comments on commit 5c61f36

Please sign in to comment.