Skip to content

Commit

Permalink
Merge pull request #27 from nodeset-org/constellation
Browse files Browse the repository at this point in the history
Add support for Constellation
  • Loading branch information
jclapis authored Sep 20, 2024
2 parents b34c0e6 + f25a2e1 commit 45766bc
Show file tree
Hide file tree
Showing 99 changed files with 2,685 additions and 809 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.10
go-version: 1.22.7
- run: cd ${GITHUB_WORKSPACE} && go build .
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.10
go-version: 1.22.7
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.10
go-version: 1.22.7

- name: Run tests
env:
Expand Down
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
issues:
exclude-rules:
- linters:
- staticcheck
text: "ST1005"
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"program": "${workspaceFolder}",
"args": [
"-u",
"${env:HOME}/.hyperdrive"
"${env:HOME}/.hyperdrive",
"-s",
"/usr/share/hyperdrive/networks"
]
}
]
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
},
"go.testFlags": [
"-p",
"1",
"-count",
"1"
],
"go.lintFlags": [
"-e",
"ST1005"
]
}
30 changes: 16 additions & 14 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ import (

// Binder for the Hyperdrive daemon API server
type ApiClient struct {
context client.IRequesterContext
NodeSet *NodeSetRequester
NodeSet_StakeWise *NodeSetStakeWiseRequester
Service *ServiceRequester
Tx *TxRequester
Utils *UtilsRequester
Wallet *WalletRequester
context client.IRequesterContext
NodeSet *NodeSetRequester
NodeSet_StakeWise *NodeSetStakeWiseRequester
NodeSet_Constellation *NodeSetConstellationRequester
Service *ServiceRequester
Tx *TxRequester
Utils *UtilsRequester
Wallet *WalletRequester
}

// Creates a new API client instance
func NewApiClient(apiUrl *url.URL, logger *slog.Logger, tracer *httptrace.ClientTrace) *ApiClient {
context := client.NewNetworkRequesterContext(apiUrl, logger, tracer)

client := &ApiClient{
context: context,
NodeSet: NewNodeSetRequester(context),
NodeSet_StakeWise: NewNodeSetStakeWiseRequester(context),
Service: NewServiceRequester(context),
Tx: NewTxRequester(context),
Utils: NewUtilsRequester(context),
Wallet: NewWalletRequester(context),
context: context,
NodeSet: NewNodeSetRequester(context),
NodeSet_StakeWise: NewNodeSetStakeWiseRequester(context),
NodeSet_Constellation: NewNodeSetConstellationRequester(context),
Service: NewServiceRequester(context),
Tx: NewTxRequester(context),
Utils: NewUtilsRequester(context),
Wallet: NewWalletRequester(context),
}
return client
}
Expand Down
67 changes: 67 additions & 0 deletions client/nodeset-constellation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package client

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/nodeset-org/hyperdrive-daemon/shared/types/api"
nscommon "github.com/nodeset-org/nodeset-client-go/common"
"github.com/rocket-pool/node-manager-core/api/client"
"github.com/rocket-pool/node-manager-core/api/types"
)

// Requester for Constellation module calls to the nodeset.io service
type NodeSetConstellationRequester struct {
context client.IRequesterContext
}

func NewNodeSetConstellationRequester(context client.IRequesterContext) *NodeSetConstellationRequester {
return &NodeSetConstellationRequester{
context: context,
}
}

func (r *NodeSetConstellationRequester) GetName() string {
return "NodeSet-Constellation"
}
func (r *NodeSetConstellationRequester) GetRoute() string {
return "nodeset/constellation"
}
func (r *NodeSetConstellationRequester) GetContext() client.IRequesterContext {
return r.context
}

// Gets the address the node's user has assigned as the registered Constellation address
func (r *NodeSetConstellationRequester) GetRegisteredAddress() (*types.ApiResponse[api.NodeSetConstellation_GetRegisteredAddressData], error) {
args := map[string]string{}
return client.SendGetRequest[api.NodeSetConstellation_GetRegisteredAddressData](r, "get-registered-address", "GetRegisteredAddress", args)
}

// Gets a signature for registering / whitelisting the node with the Constellation contracts
func (r *NodeSetConstellationRequester) GetRegistrationSignature() (*types.ApiResponse[api.NodeSetConstellation_GetRegistrationSignatureData], error) {
args := map[string]string{}
return client.SendGetRequest[api.NodeSetConstellation_GetRegistrationSignatureData](r, "get-registration-signature", "GetRegistrationSignature", args)
}

// Gets the deposit signature for a minipool from the Constellation contracts
func (r *NodeSetConstellationRequester) GetDepositSignature(minipoolAddress common.Address, salt *big.Int) (*types.ApiResponse[api.NodeSetConstellation_GetDepositSignatureData], error) {
args := map[string]string{
"minipoolAddress": minipoolAddress.Hex(),
"salt": salt.String(),
}
return client.SendGetRequest[api.NodeSetConstellation_GetDepositSignatureData](r, "get-deposit-signature", "GetDepositSignature", args)
}

// Gets the validators that have been registered with the NodeSet service for this node as part of Constellation
func (r *NodeSetConstellationRequester) GetValidators() (*types.ApiResponse[api.NodeSetConstellation_GetValidatorsData], error) {
args := map[string]string{}
return client.SendGetRequest[api.NodeSetConstellation_GetValidatorsData](r, "get-validators", "GetValidators", args)
}

// Uploads signed exit messages to the NodeSet service
func (r *NodeSetConstellationRequester) UploadSignedExits(exitMessages []nscommon.ExitData) (*types.ApiResponse[api.NodeSetConstellation_UploadSignedExitsData], error) {
body := api.NodeSetConstellation_UploadSignedExitsRequestBody{
ExitMessages: exitMessages,
}
return client.SendPostRequest[api.NodeSetConstellation_UploadSignedExitsData](r, "upload-signed-exits", "UploadSignedExits", body)
}
18 changes: 13 additions & 5 deletions client/nodeset-stakewise.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package client
import (
"github.com/ethereum/go-ethereum/common"
"github.com/nodeset-org/hyperdrive-daemon/shared/types/api"
apiv1 "github.com/nodeset-org/nodeset-client-go/api-v1"
nscommon "github.com/nodeset-org/nodeset-client-go/common"
"github.com/rocket-pool/node-manager-core/api/client"
"github.com/rocket-pool/node-manager-core/api/types"
"github.com/rocket-pool/node-manager-core/beacon"
Expand Down Expand Up @@ -55,11 +55,19 @@ func (r *NodeSetStakeWiseRequester) GetDepositDataSet(vault common.Address) (*ty
}

// Uploads new validator deposit data to the NodeSet service
func (r *NodeSetStakeWiseRequester) UploadDepositData(data []beacon.ExtendedDepositData) (*types.ApiResponse[api.NodeSetStakeWise_UploadDepositDataData], error) {
return client.SendPostRequest[api.NodeSetStakeWise_UploadDepositDataData](r, "upload-deposit-data", "UploadDepositData", data)
func (r *NodeSetStakeWiseRequester) UploadDepositData(vault common.Address, data []beacon.ExtendedDepositData) (*types.ApiResponse[api.NodeSetStakeWise_UploadDepositDataData], error) {
body := api.NodeSetStakeWise_UploadDepositDataRequestBody{
Vault: vault,
DepositData: data,
}
return client.SendPostRequest[api.NodeSetStakeWise_UploadDepositDataData](r, "upload-deposit-data", "UploadDepositData", body)
}

// Uploads signed exit messages to the NodeSet service
func (r *NodeSetStakeWiseRequester) UploadSignedExits(data []apiv1.ExitData) (*types.ApiResponse[api.NodeSetStakeWise_UploadSignedExitsData], error) {
return client.SendPostRequest[api.NodeSetStakeWise_UploadSignedExitsData](r, "upload-signed-exits", "UploadSignedExits", data)
func (r *NodeSetStakeWiseRequester) UploadSignedExits(vault common.Address, data []nscommon.ExitData) (*types.ApiResponse[api.NodeSetStakeWise_UploadSignedExitsData], error) {
body := api.NodeSetStakeWise_UploadSignedExitsRequestBody{
Vault: vault,
ExitData: data,
}
return client.SendPostRequest[api.NodeSetStakeWise_UploadSignedExitsData](r, "upload-signed-exits", "UploadSignedExits", body)
}
10 changes: 10 additions & 0 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ func (r *ServiceRequester) ClientStatus() (*types.ApiResponse[api.ServiceClientS
return client.SendGetRequest[api.ServiceClientStatusData](r, "client-status", "ClientStatus", nil)
}

// Gets the resources for the daemon's selected network
func (r *ServiceRequester) GetResources() (*types.ApiResponse[api.ServiceGetResourcesData], error) {
return client.SendGetRequest[api.ServiceGetResourcesData](r, "get-resources", "GetResources", nil)
}

// Gets the network settings for the daemon's selected network
func (r *ServiceRequester) GetNetworkSettings() (*types.ApiResponse[api.ServiceGetNetworkSettingsData], error) {
return client.SendGetRequest[api.ServiceGetNetworkSettingsData](r, "get-network-settings", "GetNetworkSettings", nil)
}

// Gets the Hyperdrive configuration
func (r *ServiceRequester) GetConfig() (*types.ApiResponse[api.ServiceGetConfigData], error) {
return client.SendGetRequest[api.ServiceGetConfigData](r, "get-config", "GetConfig", nil)
Expand Down
Loading

0 comments on commit 45766bc

Please sign in to comment.