Skip to content

Commit

Permalink
Merge pull request #128 from stader-labs/separate_checkpoint_url
Browse files Browse the repository at this point in the history
Update copies
  • Loading branch information
batphonghan authored Oct 16, 2023
2 parents 8b12f4e + 839f69c commit e397d94
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 12 deletions.
2 changes: 1 addition & 1 deletion shared/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package shared

const BinaryBucket string = "/stader-node-build/permissionless"
const DockerAccount string = "staderlabs"
const StaderVersion string = "1.4.0"
const StaderVersion string = "1.4.0-dev"

const Logo string = `
_____ _ _ _ _ 𝅺
Expand Down
2 changes: 1 addition & 1 deletion stader-cli/node/deposit-sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func nodeDepositSd(c *cli.Context) error {
}

if allowance.Allowance.Cmp(amountWei) < 0 {
fmt.Println("Before depositing SD, you must first give the collateral contract approval to interact with your SD. Amount to approve: ", amountWei)
fmt.Println("Before depositing SD, you must first give the collateral contract approval to interact with your SD. Amount to approve: ", eth.WeiToEth(amountWei))
err = nodeApproveSdWithAmount(c, staderClient, amountWei)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions stader-cli/node/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func registerNode(c *cli.Context, operatorName string) error {

operatorRewardAddressString := walletStatus.AccountAddress.String()

confirmText := "Would you wish to join the ETHx Socializing pool?\nType 'Yes' to Opt-in or 'No' to Opt-out. \nNote: The Opt-In and Opt-Out of socializing pool will have a cool-off period of 56 days.\ni.e you will have to wait for 56 days to Opt-Out of the Socializing pool once you Opt-In and vice versa.\nLearn more about the ETHx Socializing Pool here:\nhttps://staderlabs.gitbook.io/ethereum/node-operator/permissionless-node-operator/ethx-rewards-for-permissionless-node-operators/socializing-pool\n"
confirmText := "Would you wish to join the ETHx Socializing pool?\nType 'Y' to Opt-in or 'N' to Opt-out. \nNote: The Opt-In and Opt-Out of socializing pool will have a cool-off period of 56 days.\ni.e you will have to wait for 56 days to Opt-Out of the Socializing pool once you Opt-In and vice versa.\nLearn more about the ETHx Socializing Pool here:\nhttps://staderlabs.gitbook.io/ethereum/node-operator/permissionless-node-operator/ethx-rewards-for-permissionless-node-operators/socializing-pool\n"

socializeEl := cliutils.Confirm(confirmText)
// Check node can be registered
Expand Down Expand Up @@ -82,7 +82,7 @@ func registerNode(c *cli.Context, operatorName string) error {
}

// Log & return
fmt.Printf("Congratulation, your node is now registered on the stader \network. Your current Operator and Reward address is the same. We \nstrongly recommend changing your Reward address. To do so, run the \nfollowing command: 'stader-cli node set-reward-address -ora <new reward address>'.\n")
fmt.Printf("Congratulation, your node is now registered on the Stader \nnetwork. Your current Operator and Reward address is the same. We \nstrongly recommend changing your Reward address. To do so, run the \nfollowing command: ~/bin/stader-cli node set-reward-address -ora <new reward address>.\n")
return nil

}
95 changes: 87 additions & 8 deletions stader-cli/node/update-operator-reward-address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/stader-labs/stader-node/shared/services/config"
"github.com/stader-labs/stader-node/shared/services/gas"
"github.com/stader-labs/stader-node/shared/services/stader"
cfTypes "github.com/stader-labs/stader-node/shared/types/config"
cliutils "github.com/stader-labs/stader-node/shared/utils/cli"
"github.com/urfave/cli"
)
Expand All @@ -27,6 +29,10 @@ func SetRewardAddress(c *cli.Context, operatorRewardAddress common.Address) erro
}
defer staderClient.Close()

cfg, _, err := staderClient.LoadConfig()
if err != nil {
return err
}
// check if we can update the el
res, err := staderClient.CanUpdateOperatorRewardAddress(operatorRewardAddress)
if err != nil {
Expand Down Expand Up @@ -55,9 +61,7 @@ func SetRewardAddress(c *cli.Context, operatorRewardAddress common.Address) erro
}

if res.OperatorAddressAndRewardNotTheSame {
fmt.Printf("%sFor node security, only your existing Reward Address can \npropose a change. To propose and confirm a Reward address \nchange, please use the PermissionlessNodeRegistry Smart Contract: \n%s %s\n\n", colorLightBlue, infoResponse.PermissionlessNodeRegistry, colorReset)

promptNote()
promptHowToChangeReward(cfg, infoResponse.PermissionlessNodeRegistry)
return nil
}

Expand All @@ -66,8 +70,18 @@ func SetRewardAddress(c *cli.Context, operatorRewardAddress common.Address) erro
return err
}

confirmMessage := `
This action will change your Reward Address. Once it's changed, all future SD and ETH rewards will be sent to the New Reward Address.
After you propose the change, your New Reward Address will initially be in a
'Confirmation pending' state until you confirm the change using your New RewardAddress on the
PermissionlessNodeRegistry Smart Contract. Please make sure that your New Reward Address
is linked to a web3-compatible wallet, such as MetaMask, to connect with the Smart Contract
Do you wish to proceed with the Reward Address change?`

if !(c.Bool("yes") || cliutils.Confirm(fmt.Sprintf(
"\n%sThis action will change your Reward address. Once it's \nchanged, all future SD and ETH reward will be sent to the new address. \n\nYour new Reward address will initially be in a \"Confirmation pending\" state. \nTo confirm the change, please use \nthe PermissionlessNodeRegistry Smart Contract: %s \n\nStader will continue to send reward to your existing address until you \nconfirm the change using your new Reward Address. To complete \nthe confirmation process, make sure you have a web3-compatible wallet like \nMetaMask. Connect your wallet with the Smart Contract using \nyour new Reward address and confirm the Reward address change \nusing the ConfirmRewardAddressChange function. \n\n%sDo you wish to processed with the Reward address change?%s", colorLightBlue, infoResponse.PermissionlessNodeRegistry, colorGreen, colorReset))) {
"\n%s %s %s", colorLightBlue, confirmMessage, colorReset))) {
fmt.Println("Cancelled.")
return nil
}
Expand All @@ -86,11 +100,76 @@ func SetRewardAddress(c *cli.Context, operatorRewardAddress common.Address) erro
return err
}

fmt.Printf("%sYour reward address changed in pending state. Please \nconfirm the request using this contract: %s and the reward address.%s", colorLightBlue, infoResponse.PermissionlessNodeRegistry, colorReset)

promptSuccessChangedRewardAndNextStep(cfg, infoResponse.PermissionlessNodeRegistry)
return nil
}

func promptNote() {
fmt.Printf("%sFollow these steps for your Reward address change: \nStep1: Propose the Reward address change by connecting your wallet \nto the Smart Contract using your EXISTING Reward address and the ProposeRewardAddress function. \nStep2: Confirm the Reward address change by connecting your wallet \nto the Smart Contract using your NEW Reward address and the ConfirmRewardAddressChange function. \n\n%sNote: Stader will continue to send reward to your existing Reward \naddress until you confirm the change using your new Reward Address%s", colorGreen, colorRed, colorReset)
func promptSuccessChangedRewardAndNextStep(cfg *config.StaderConfig, contractAddr common.Address) {
switch cfg.StaderNode.Network.Value.(cfTypes.Network) {
case cfTypes.Network_Mainnet:
msg := `
You have successfully raised a request to change your Reward Address.
To confirm the Reward Address change please follow these steps:
Step 1: Visit the PermissionlessNodeRegistry Smart Contract: https://etherscan.io/address/%s#writeProxyContract#F3
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function.
Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Mainnet-Permissionless-8ef1137e9c2647c88db3911da1642ca2
Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your new Reward Address.
`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n", colorLightBlue, msg, colorReset)
case cfTypes.Network_Prater:
msg := `
You have successfully raised a request to change your Reward Address.
To confirm the Reward Address change please follow these steps:
Step 1: Visit the PermissionlessNodeRegistry Smart Contract: https://goerli.etherscan.io/address/%s#writeProxyContract#F3
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function.
Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Testnet-Permissionless-db692621a305426bab2e3ad232acbc14
Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your new Reward Address.`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n", colorLightBlue, msg, colorReset)
default:
fmt.Println("Unsupported network")
}
}

func promptHowToChangeReward(cfg *config.StaderConfig, contractAddr common.Address) {
network := cfg.StaderNode.Network.Value.(cfTypes.Network)
switch network {
case cfTypes.Network_Mainnet:
msg := `
For node security, only your existing Reward Address can propose a change. To propose and confirm a Reward Address change, please use the PermissionlessNodeRegistry Smart Contract: https://etherscan.io/address/%s#writeProxyContract#F10
Follow these steps for your Reward address change:
Step 1: Propose the Reward Address change by connecting your Existing Reward Address wallet with the Smart Contract and execute the "ProposeRewardAddress" function.
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function
Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Mainnet-Permissionless-8ef1137e9c2647c88db3911da1642ca2
Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your New Reward Address.
`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n\n", colorLightBlue, msg, colorReset)
case cfTypes.Network_Prater:
msg := `
For node security, only your existing Reward Address can propose a change. To propose and confirm a Reward Address change, please use the PermissionlessNodeRegistry Smart Contract: https://goerli.etherscan.io/address/%s#writeProxyContract#F10
Follow these steps for your Reward Address change:
Step 1: Propose the Reward Address change by connecting your Existing Reward Address wallet with the Smart Contract and execute the "ProposeRewardAddress" function.
Step 2: Confirm the Reward Address change by connecting your New Reward Address wallet with the Smart Contract and execute the "ConfirmRewardAddressChange" function
Please refer to the Reward Address change guide here - https://staderlabs.notion.site/staderlabs/Stader-ETHx-Reward-address-change-flow-Testnet-Permissionless-db692621a305426bab2e3ad232acbc14
Note: Stader will continue to send rewards to your existing Reward Address until you confirm the change using your New Reward Address.
`
msg = fmt.Sprintf(msg, contractAddr.String())
fmt.Printf("%s %s %s\n\n", colorLightBlue, msg, colorReset)
default:
fmt.Println("Unsupported network")
}
}

0 comments on commit e397d94

Please sign in to comment.