Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port test/lint actions to v2 #9

Open
wants to merge 35 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
109aebb
Add unit test workflow
jshufro Apr 14, 2024
70d8c55
Fix printfs and printlns
jshufro Apr 14, 2024
cf64b04
Add build workflow
jshufro Apr 14, 2024
df84f4d
Fix claimable challenge states.
0xfornax Apr 15, 2024
e1c7eba
Merge pull request #490 from jshufro/jms/actions
0xfornax Apr 16, 2024
4414671
Don't list prelaunch minipools as closable
0xfornax Apr 16, 2024
998f069
Merge branch 'master' into houston
0xfornax Apr 16, 2024
e7a45f1
Add condition for the Challenged state
0xfornax Apr 16, 2024
9993da9
go mod tidy
0xfornax Apr 17, 2024
8052c8d
Update initializeVoting after contract changes
0xfornax Apr 17, 2024
c3ede9e
Update v2.md
jclapis Apr 17, 2024
ec8f963
Added some debug logs to network balances
jclapis Apr 17, 2024
cdf5853
Updated balance and price submissions for Houston
jclapis Apr 17, 2024
805ff69
Next_account's reader now trims it before parsing
jclapis Apr 17, 2024
00bed16
Add unit test workflow
jshufro Apr 14, 2024
4466a16
Add goimports lint github action
jshufro Apr 17, 2024
d67b899
Resolve go test action errors
jshufro Apr 17, 2024
2b30a8f
goimports format shared/types/rewards.go
jshufro Apr 17, 2024
2aacabd
Add workflow which fails when fixup commits are present
jshufro Apr 17, 2024
24ff315
Removed Atlas price / balance addresses from the watchtower check
jclapis Apr 17, 2024
68524c5
Merge branch 'v2' into dev_v2
jclapis Apr 17, 2024
de992ca
Merge pull request #493 from rocket-pool/fix-claimable-challenge-states
0xfornax Apr 18, 2024
a0802df
Updated go lib
jclapis Apr 18, 2024
59a658e
Merge branch 'houston' into dev_v2
jclapis Apr 18, 2024
64d15c3
Fixed a service-version misprint
jclapis Apr 18, 2024
cdce4c0
Updated build CI for v2
jclapis Apr 18, 2024
1343d3a
Merge pull request #501 from rocket-pool/dev_v2
jclapis Apr 18, 2024
51ee9ee
Remove sszgen.sh
jshufro Apr 19, 2024
095c674
Merge pull request #503 from jshufro/jms/removesszgen
jclapis Apr 19, 2024
92d5b58
Add staticcheck config
jshufro Apr 17, 2024
171ebf4
Enable and fix staticcheck issues
jshufro Apr 17, 2024
dffcfba
Enable and fix ineffassign issues
jshufro Apr 17, 2024
2891528
Enable and fix gosimple issues
jshufro Apr 17, 2024
02f1517
Enable and fix unused issues
jshufro Apr 17, 2024
ea7a83a
Flip all linters on except errcheck
jshufro Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Smart Node Build
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21.8
- run: cd ${GITHUB_WORKSPACE}/rocketpool-cli && go build .
- run: cd ${GITHUB_WORKSPACE}/rocketpool-daemon && go build .
14 changes: 14 additions & 0 deletions .github/workflows/commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Taken from https://github.com/marketplace/actions/block-fixup-commit-merge?version=v2.0.0
# Updated to use newer ubuntu and checkout action
name: Git Checks

on: [pull_request]

jobs:
block-fixup:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Block Fixup Commit Merge
uses: 13rac1/[email protected]
51 changes: 51 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Taken from https://github.com/golangci/golangci-lint-action
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
- v2*
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.21.8
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# For now, Smart Node will enforce everything except errcheck
args: --disable errcheck

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
21 changes: 21 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Smart Node Unit Tests
on:
push:
tags:
- v*
branches:
- master
- main
- v2*
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21.8
- run: go test ./...
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ require (
github.com/prometheus/client_golang v1.19.0
github.com/prysmaticlabs/prysm/v5 v5.0.3
github.com/rivo/tview v0.0.0-20230208211350-7dfff1ce7854 // DO NOT UPGRADE
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417004432-ca6e3e2c4f32
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7
github.com/shirou/gopsutil/v3 v3.24.3
github.com/tyler-smith/go-bip39 v1.1.0
github.com/wealdtech/go-ens/v3 v3.6.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ github.com/rocket-pool/batch-query v1.0.0 h1:5HejmT1n1fIdLIqUhTNwbkG2PGOPl3IVjCp
github.com/rocket-pool/batch-query v1.0.0/go.mod h1:d1CmxShzk0fioJ4yX0eFGhz2an1odnW/LZ2cp3eDGIQ=
github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9KuetSKB9nte9I/MkkiM3pwKFVQgqxxPTQ0y56Ff6s=
github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8 h1:DpNHfImur7EplInBi1mV8ZK8zCBueGFuQWpoDfjJWbw=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417132624-0e7d87e82ec8/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417004432-ca6e3e2c4f32 h1:k+QY2qY5PyktCS9MAPKp6QWlM3sarJXIZ1U7CJtPZng=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240417004432-ca6e3e2c4f32/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a h1:hBuBMT4XT1ne/6eUdnE3BIfnMsFmFPF7pIRud0aWod8=
github.com/rocket-pool/node-manager-core v0.2.1-0.20240417173109-4b54852b003a/go.mod h1:KeVUgf+tc7e+fDUzc/FH3COtgGPoAyIV2Tx3jLN4zng=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7 h1:liWy3ZNMhHmNOlbKfJXZbUgbBaGj4ZyEZJv+0mWaZ+k=
github.com/rocket-pool/rocketpool-go/v2 v2.0.0-20240418131940-9aa4643f67c7/go.mod h1:2IMaRByN0wfkLgNa85LA0I9oJ1QKv1nCNoffFdhF714=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo=
Expand Down
5 changes: 3 additions & 2 deletions rocketpool-cli/client/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
dt "github.com/docker/docker/api/types"
dtc "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
dti "github.com/docker/docker/api/types/image"
)

// Get the current Docker image used by the given container
Expand Down Expand Up @@ -114,7 +115,7 @@ func (c *Client) DeleteImage(imageName string) error {
return err
}
// TODO: handle the response here
_, err = d.ImageRemove(context.Background(), imageName, dt.ImageRemoveOptions{})
_, err = d.ImageRemove(context.Background(), imageName, dti.RemoveOptions{})
return err
}

Expand Down Expand Up @@ -210,7 +211,7 @@ func (c *Client) GetAllDockerImages() ([]DockerImage, error) {
return nil, err
}

imageList, err := d.ImageList(context.Background(), dt.ImageListOptions{All: true})
imageList, err := d.ImageList(context.Background(), dti.ListOptions{All: true})
if err != nil {
return nil, fmt.Errorf("error getting image details: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *Client) InstallService(verbose bool, noDeps bool, version string, path
func (c *Client) InstallUpdateTracker(verbose bool, version string, useLocalInstaller bool) error {
// Get installation script flags
flags := []string{
"-v", fmt.Sprintf("%s", shellescape.Quote(version)),
"-v", shellescape.Quote(version),
}

var script []byte
Expand Down
14 changes: 0 additions & 14 deletions rocketpool-cli/client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"path/filepath"

"github.com/alessio/shellescape"
"github.com/rocket-pool/node-manager-core/api/types"
"github.com/rocket-pool/smartnode/v2/shared/config"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -98,16 +97,3 @@ func SaveConfig(cfg *config.SmartNodeConfig, directory string, filename string)

return nil
}

// Parse and augment the status of a client into a human-readable format
func getClientStatusString(clientStatus types.ClientStatus) string {
if clientStatus.IsSynced {
return "synced and ready"
}

if clientStatus.IsWorking {
return fmt.Sprintf("syncing (%.2f%%)", SyncRatioToPercent(clientStatus.SyncProgress))
}

return fmt.Sprintf("unavailable (%s)", clientStatus.Error)
}
12 changes: 8 additions & 4 deletions rocketpool-cli/commands/minipool/reduce-bond.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ func reduceBondAmount(c *cli.Context) error {

// Check the fee distributor
if !details.Data.IsFeeDistributorInitialized {
fmt.Println("Minipools cannot have their bonds reduced until your fee distributor has been initialized.\nPlease run `rocketpool node initialize-fee-distributor` first, then return here to reduce your bonds.")
fmt.Println("Minipools cannot have their bonds reduced until your fee distributor has been initialized.")
fmt.Println("Please run `rocketpool node initialize-fee-distributor` first, then return here to reduce your bonds.")
return nil
}

fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.\n")
fmt.Println("NOTE: this function is used to complete the bond reduction process for a minipool. If you haven't started the process already, please run `rocketpool minipool begin-bond-reduction` first.")
fmt.Println()

// Get reduceable minipools
reduceableMinipools := []api.MinipoolReduceBondDetails{}
Expand Down Expand Up @@ -109,10 +111,12 @@ func forceFeeDistribution(c *cli.Context, rp *client.Client) error {

balance := response.Data.Balance
if balance.Cmp(common.Big0) == 0 {
fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.\n")
fmt.Println("Your fee distributor does not have any ETH and does not need to be distributed.")
fmt.Println()
return nil
}
fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.\n")
fmt.Println("NOTE: prior to bond reduction, you must distribute the funds in your fee distributor.")
fmt.Println()

// Print info
balanceFloat := eth.WeiToEth(response.Data.Balance)
Expand Down
8 changes: 5 additions & 3 deletions rocketpool-cli/commands/minipool/rescue-dissolved.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ func rescueDissolved(c *cli.Context) error {
// Get RP client
rp := client.NewClientFromCtx(c)

fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.\nPlease read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.\n")
fmt.Println("This command will allow you to manually deposit the remaining ETH for any dissolved minipools, activating them so you can exit them and retrieve your minipool's funds.")
fmt.Println("Please read our guide at https://docs.rocketpool.net/guides/node/rescue-dissolved.html to fully read about the process before continuing.")
fmt.Println()

// Get minipool statuses
details, err := rp.Api.Minipool.GetRescueDissolvedDetails()
Expand Down Expand Up @@ -91,14 +93,14 @@ func rescueDissolved(c *cli.Context) error {
fmt.Printf("\nPlease upgrade the delegate for these minipools using `rocketpool minipool delegate-upgrade` before rescuing them.%s\n\n", terminal.ColorReset)
}
if len(balanceCompletedMinipools) > 0 {
fmt.Printf("%NOTE: The following minipools already have 32 ETH or more deposited:\n", terminal.ColorYellow)
fmt.Printf("%sNOTE: The following minipools already have 32 ETH or more deposited:\n", terminal.ColorYellow)
for _, mp := range balanceCompletedMinipools {
fmt.Printf("\t%s\n", mp.Address)
}
fmt.Printf("\nThese minipools don't need to be rescued.%s\n\n", terminal.ColorReset)
}
if len(invalidBeaconStateMinipools) > 0 {
fmt.Printf("%NOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", terminal.ColorYellow)
fmt.Printf("%sNOTE: The following minipools have an invalid state on the Beacon Chain (expected 'initialized_pending'):\n", terminal.ColorYellow)
for _, mp := range invalidBeaconStateMinipools {
fmt.Printf("\t%s (%s)\n", mp.Address, mp.BeaconState)
}
Expand Down
4 changes: 2 additions & 2 deletions rocketpool-cli/commands/node/create-vacant-minipool.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func createVacantMinipool(c *cli.Context, pubkey beacon.ValidatorPubkey) error {
// Get RP client
rp := client.NewClientFromCtx(c)

// Make sure ETH2 is on the correct chain
// Make sure Beacon is on the correct chain
depositContractInfo, err := rp.Api.Network.GetDepositContractInfo()
if err != nil {
return err
Expand All @@ -41,7 +41,7 @@ func createVacantMinipool(c *cli.Context, pubkey beacon.ValidatorPubkey) error {
return nil
}

fmt.Println("Your eth2 client is on the correct network.")
fmt.Println("Your Beacon Node is on the correct network.")
fmt.Println()

// Check if the fee distributor has been initialized
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-cli/commands/node/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func nodeDeposit(c *cli.Context) error {
// Get RP client
rp := client.NewClientFromCtx(c)

// Make sure ETH2 is on the correct chain
// Make sure Beacon is on the correct chain
depositContractInfo, err := rp.Api.Network.GetDepositContractInfo()
if err != nil {
return err
Expand Down
12 changes: 10 additions & 2 deletions rocketpool-cli/commands/node/set-smoothing-pool-state.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ func setSmoothingPoolState(c *cli.Context, optIn bool) error {
var identifierMsg string
var submitMsg string
if optIn {
fmt.Println("You are about to opt into the Smoothing Pool.\nYour fee recipient will be changed to the Smoothing Pool contract.\nAll priority fees and MEV you earn via proposals will be shared equally with other members of the Smoothing Pool.\n\nIf you desire, you can opt back out after one full rewards interval has passed.")
fmt.Println("You are about to opt into the Smoothing Pool.")
fmt.Println("Your fee recipient will be changed to the Smoothing Pool contract.")
fmt.Println("All priority fees and MEV you earn via proposals will be shared equally with other members of the Smoothing Pool.")
fmt.Println()
fmt.Println("If you desire, you can opt back out after one full rewards interval has passed.")
fmt.Println()
confirmMsg = "Are you sure you want to join the Smoothing Pool?"
identifierMsg = "joining Smoothing Pool"
submitMsg = "Joining the Smoothing Pool..."
} else {
fmt.Println("You are about to opt out of the Smoothing Pool.\nYour fee recipient will be changed back to your node's distributor contract once the next Epoch has been finalized.\nAll priority fees and MEV you earn via proposals will go directly to your distributor and will not be shared by the Smoothing Pool members.\n\nIf you desire, you can opt back in after one full rewards interval has passed.")
fmt.Println("You are about to opt out of the Smoothing Pool.")
fmt.Println("Your fee recipient will be changed back to your node's distributor contract once the next Epoch has been finalized.")
fmt.Println("All priority fees and MEV you earn via proposals will go directly to your distributor and will not be shared by the Smoothing Pool members.")
fmt.Println()
fmt.Println("If you desire, you can opt back in after one full rewards interval has passed.")
fmt.Println()
confirmMsg = "Are you sure you want to leave the Smoothing Pool?"
identifierMsg = "leaving Smoothing Pool"
Expand Down
Loading
Loading