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 lint and test CI to v2 #498

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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/block-fixup-merge-action@v2.0.0
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 only enforce goimports linting
args: --disable-all --enable goimports

# 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 ./...
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
3 changes: 2 additions & 1 deletion rocketpool-cli/commands/service/export-ec-data.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func exportEcData(c *cli.Context, targetDir string) error {

fmt.Println("This will export your execution client's chain data to an external directory, such as a portable hard drive.")
fmt.Println("If your execution client is running, it will be shut down.")
fmt.Println("Once the export is complete, your execution client will restart automatically.\n")
fmt.Println("Once the export is complete, your execution client will restart automatically.")
fmt.Println()

// Get the EC volume name
executionContainerName := cfg.GetDockerArtifactName(config.ExecutionClientSuffix)
Expand Down
3 changes: 2 additions & 1 deletion rocketpool-cli/commands/service/import-ec-data.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func importEcData(c *cli.Context, sourceDir string) error {

fmt.Println("This will import execution layer chain data that you previously exported into your execution client.")
fmt.Println("If your execution client is running, it will be shut down.")
fmt.Println("Once the import is complete, your execution client will restart automatically.\n")
fmt.Println("Once the import is complete, your execution client will restart automatically.")
fmt.Println()

// Get the volume to import into
executionContainerName := cfg.GetDockerArtifactName(config.ExecutionClientSuffix)
Expand Down
3 changes: 2 additions & 1 deletion rocketpool-cli/commands/service/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func getSyncProgress(c *cli.Context) error {
depositContractInfo.Data.BeaconDepositContract)
return nil
} else {
fmt.Println("Your Beacon Node is on the correct network.\n")
fmt.Println("Your Beacon Node is on the correct network.")
fmt.Println()
}

// Get node status
Expand Down
4 changes: 3 additions & 1 deletion rocketpool-cli/commands/wallet/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ func promptForCustomKeyPasswords(cfg *config.SmartNodeConfig, testOnly bool) (st
}

// Notify the user
fmt.Println("It looks like you have some custom keystores for your minipool's validators.\nYou will be prompted for the passwords each one was encrypted with, so they can be loaded into the Validator Client that Rocket Pool manages for you.\n")
fmt.Println("It looks like you have some custom keystores for your minipool's validators.")
fmt.Println("You will be prompted for the passwords each one was encrypted with, so they can be loaded into the Validator Client that Rocket Pool manages for you.")
fmt.Println()

// Get the passwords for each one
pubkeyPasswords := map[string]string{}
Expand Down
4 changes: 2 additions & 2 deletions rocketpool-cli/utils/gas/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func handleEtherchainGasPrices(gasSuggestion gas.EtherchainGasFeeSuggestion, gas

desiredPriceFloat, err := strconv.ParseFloat(desiredPrice, 64)
if err != nil {
fmt.Println("Not a valid gas price (%s), try again.", err.Error())
fmt.Printf("Not a valid gas price (%s), try again.\n", err.Error())
continue
}
if desiredPriceFloat <= 0 {
Expand Down Expand Up @@ -271,7 +271,7 @@ func handleEtherscanGasPrices(gasSuggestion gas.EtherscanGasFeeSuggestion, gasIn

desiredPriceFloat, err := strconv.ParseFloat(desiredPrice, 64)
if err != nil {
fmt.Println("Not a valid gas price (%s), try again.", err.Error())
fmt.Printf("Not a valid gas price (%s), try again.\n", err.Error())
continue
}
if desiredPriceFloat <= 0 {
Expand Down
3 changes: 2 additions & 1 deletion rocketpool-cli/utils/migration/import-key.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func ImportKey(c *cli.Context, rp *client.Client, minipoolAddress common.Address
fmt.Printf("failed!\n%sWARNING: error restarting validator client: %s\n\nPlease restart it manually so it picks up the new validator key for your minipool.%s", terminal.ColorYellow, err.Error(), terminal.ColorReset)
return false
}
fmt.Println("done!\n")
fmt.Println("done!")
fmt.Println()
}
return true

Expand Down
2 changes: 1 addition & 1 deletion rocketpool-daemon/api/node/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (c *nodeDepositContext) PrepareData(data *api.NodeDepositData, opts *bind.T
if status.Exists {
return types.ResponseStatus_InvalidChainState, fmt.Errorf("**** ALERT ****\n"+
"Your minipool %s has the following as a validator pubkey:\n\t%s\n"+
"This key is already in use by validator %d on the Beacon chain!\n"+
"This key is already in use by validator %s on the Beacon chain!\n"+
"Rocket Pool will not allow you to deposit this validator for your own safety so you do not get slashed.\n"+
"PLEASE REPORT THIS TO THE ROCKET POOL DEVELOPERS.\n"+
"***************\n", minipoolAddress.Hex(), pubkey.Hex(), status.Index)
Expand Down
7 changes: 4 additions & 3 deletions rocketpool-daemon/node/verify-pdao-props.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,16 @@ func (t *VerifyPdaoProps) getChallengeOrDefeatForProposal(prop *protocol.Protoco
}

// Check if the index has been challenged yet
var state func() types.ChallengeState
var getState func() types.ChallengeState
err = t.rp.Query(func(mc *batch.MultiCaller) error {
prop.GetChallengeState(mc, newChallengedIndex)
getState = prop.GetChallengeState(mc, newChallengedIndex)
return nil
}, opts)
if err != nil {
return nil, nil, fmt.Errorf("error checking challenge state for proposal %d, index %d: %w", prop.ID, challengedIndex, err)
}
switch state() {
state := getState()
switch state {
case types.ChallengeState_Unchallenged:
// If it's unchallenged, this is the index to challenge
return &challenge{
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-daemon/watchtower/generate-rewards-tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (t *GenerateRewardsTree) generateRewardsTreeImpl(logger *slog.Logger, rp *r
}
rewardsFile, err := treegen.GenerateTree(t.ctx)
if err != nil {
t.handleError(fmt.Errorf("%s Error generating Merkle tree: %w", err), logger)
t.handleError(fmt.Errorf("Error generating Merkle tree: %w", err), logger)
return
}
header := rewardsFile.GetHeader()
Expand Down
2 changes: 1 addition & 1 deletion rocketpool-daemon/watchtower/submit-rpl-price.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (t *SubmitRplPrice) Run(state *state.NetworkState) error {
err := t.updateL2Prices(state)
if err != nil {
// Error is not fatal for this task so print and continue
t.logger.Error("Error updating L2 prices: %s", err.Error())
t.logger.Error("Error updating L2 prices", log.Err(err))
}

// Make a new RP binding just for this portion
Expand Down
2 changes: 1 addition & 1 deletion shared/types/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type IntervalInfo struct {
SmoothingPoolEthAmount *QuotedBigInt `json:"smoothingPoolEthAmount"`
MerkleProof []common.Hash `json:"merkleProof"`

TotalNodeWeight *QuotedBigInt `json:"-"`
TotalNodeWeight *QuotedBigInt `json:"-"`
}

type QuotedBigInt struct {
Expand Down
Loading