Skip to content

Commit

Permalink
Reply to some of the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Feb 16, 2024
1 parent 4f13ce1 commit 37d245b
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 42 deletions.
4 changes: 0 additions & 4 deletions app/cmd/cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ var createAATCmd = &cobra.Command{
Short: "Creates an application authentication token",
Long: `Creates a signed Application Authentication Token.
WARNING: USE THIS METHOD AT YOUR OWN RISK.
This CLI is hard-coded to generate an AAT with spec version 0.0.1.
The output is intended to be embedded into the Gateway for Relay servicing.
Expand Down Expand Up @@ -223,14 +221,12 @@ Make sure to read doc/specs/application-auth-token.md to understand what's recom
return
}

// Generate the AAT
aat, err := app.GenerateAAT(pubKeyHexEncoded, args[1], privKey)
if err != nil {
fmt.Println(err)
return
}

// Print out the AAT
fmt.Println(string(aat))
},
}
5 changes: 4 additions & 1 deletion app/cmd/cli/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"strconv"
"strings"

"github.com/spf13/cobra"

"github.com/pokt-network/pocket-core/app"
"github.com/pokt-network/pocket-core/types"
govTypes "github.com/pokt-network/pocket-core/x/gov/types"
"github.com/spf13/cobra"
)

func init() {
Expand Down Expand Up @@ -120,6 +121,7 @@ Actions: [burn, transfer]`,
fmt.Println(resp)
},
}

var govChangeParam = &cobra.Command{
Use: "change_param <fromAddr> <networkID> <paramKey module/param> <paramValue (jsonObj)> <fees>",
Short: "Edit a param in the network",
Expand Down Expand Up @@ -205,6 +207,7 @@ func dropTag(version string) string {
}

const FeatureUpgradeKey = "FEATURE"

const FeatureUpgradeHeight = int64(1)

var govFeatureEnable = &cobra.Command{
Expand Down
3 changes: 2 additions & 1 deletion app/cmd/cli/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"fmt"
"strconv"

"github.com/pokt-network/pocket-core/app"
"github.com/spf13/cobra"

"github.com/pokt-network/pocket-core/app"
)

func init() {
Expand Down
11 changes: 8 additions & 3 deletions app/cmd/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"strconv"
"strings"

"github.com/spf13/cobra"

"github.com/pokt-network/pocket-core/app"
"github.com/pokt-network/pocket-core/app/cmd/rpc"
"github.com/pokt-network/pocket-core/types"
types2 "github.com/pokt-network/pocket-core/x/apps/types"

"github.com/pokt-network/pocket-core/app"
nodeTypes "github.com/pokt-network/pocket-core/x/nodes/types"
"github.com/spf13/cobra"
)

func init() {
Expand Down Expand Up @@ -342,9 +342,13 @@ var queryAccount = &cobra.Command{
}

var nodeStakingStatus string

var nodeJailedStatus string

var blockchain string

var nodePage int

var nodeLimit int

func init() {
Expand Down Expand Up @@ -490,6 +494,7 @@ var queryNodeParams = &cobra.Command{
}

var appStakingStatus string

var appPage, appLimit int

func init() {
Expand Down
3 changes: 2 additions & 1 deletion app/cmd/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"syscall"
"time"

"github.com/spf13/cobra"

"github.com/pokt-network/pocket-core/app"
"github.com/pokt-network/pocket-core/app/cmd/rpc"
"github.com/spf13/cobra"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion app/cmd/cli/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"strconv"
"strings"

"github.com/spf13/cobra"

"github.com/pokt-network/pocket-core/app"
"github.com/pokt-network/pocket-core/types"
"github.com/spf13/cobra"
)

func init() {
Expand Down
5 changes: 3 additions & 2 deletions app/cmd/cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package cli

import (
"fmt"
"github.com/pokt-network/pocket-core/x/pocketcore/types"
"os"
"strconv"

"github.com/pokt-network/pocket-core/app"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/state"

"github.com/pokt-network/pocket-core/app"
"github.com/pokt-network/pocket-core/x/pocketcore/types"
)

func init() {
Expand Down
1 change: 0 additions & 1 deletion app/cmd/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func Relay(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
WriteJSONResponseWithCode(w, string(j), r.URL.Path, r.Host, 400)
return
}
// Handling the relay
res, dispatch, err := app.PCA.HandleRelay(relay)
if err != nil {
response := RPCRelayErrorResponse{
Expand Down
31 changes: 16 additions & 15 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ import (

kitlevel "github.com/go-kit/kit/log/level"
"github.com/go-kit/kit/log/term"
"github.com/spf13/cobra"
config2 "github.com/tendermint/tendermint/config"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/libs/cli/flags"
"github.com/tendermint/tendermint/libs/log"
cmn "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/http"
"github.com/tendermint/tendermint/rpc/client/local"
dbm "github.com/tendermint/tm-db"
"golang.org/x/crypto/ssh/terminal"

"github.com/pokt-network/pocket-core/baseapp"
"github.com/pokt-network/pocket-core/codec"
types2 "github.com/pokt-network/pocket-core/codec/types"
Expand All @@ -33,21 +49,6 @@ import (
nodesTypes "github.com/pokt-network/pocket-core/x/nodes/types"
pocket "github.com/pokt-network/pocket-core/x/pocketcore"
"github.com/pokt-network/pocket-core/x/pocketcore/types"
"github.com/spf13/cobra"
config2 "github.com/tendermint/tendermint/config"
cryptoamino "github.com/tendermint/tendermint/crypto/encoding/amino"
"github.com/tendermint/tendermint/libs/cli/flags"
"github.com/tendermint/tendermint/libs/log"
cmn "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/node"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/rpc/client"
"github.com/tendermint/tendermint/rpc/client/http"
"github.com/tendermint/tendermint/rpc/client/local"
dbm "github.com/tendermint/tm-db"
"golang.org/x/crypto/ssh/terminal"
)

var (
Expand Down
2 changes: 0 additions & 2 deletions doc/specs/cli/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ Transaction submitted with hash: <Transaction Hash>
pocket apps create-aat <appAddr> <clientPubKey>
```

**WARNING: USE THIS METHOD AT YOUR OWN RISK.**

This CLI is hard-coded to generate an AAT with spec version 0.0.1.

The output is intended to be embedded into the Gateway for Relay servicing.
Expand Down
17 changes: 6 additions & 11 deletions x/pocketcore/types/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,39 +55,34 @@ func (ps ProofIs) FromProofI() (res Proofs) {

var _ Proof = RelayProof{} // ensure implements interface at compile time

// ValidateLocal validates the Relay Proof object, where the owner of the proof is the local node

// ValidateLocal validates the Relay Proof object is aligned with `sessionBlockHeight` and `verifyAddr`.
func (rp RelayProof) ValidateLocal(
appSupportedBlockchains []string,
sessionNodeCount int,
sessionBlockHeight int64,
verifyAddr sdk.Address,
expectedServicerAddr sdk.Address,
) sdk.Error {
// Basic validation of the relay proof
err := rp.ValidateBasic()
if err != nil {
return err
}
// Retrieve the servicer public key
servicerPublicKey, er := crypto.NewPublicKey(rp.ServicerPubKey)
if er != nil {
return NewInvalidNodePubKeyError(ModuleName)
}
// validate the public key correctness
if !sdk.Address(servicerPublicKey.Address()).Equals(verifyAddr) {
if !sdk.Address(servicerPublicKey.Address()).Equals(expectedServicerAddr) {
// the public key is not this nodes, so they would not get paid
return NewInvalidNodePubKeyError(ModuleName)
}
// ValidateLocal calling `rp.Validate` is important
err = rp.Validate(appSupportedBlockchains, sessionNodeCount, sessionBlockHeight)
err = rp.Validate(appSupportedBlockchains, sessionBlockHeight)
if err != nil {
return err
}
return nil
}

// "Validate" - Validates the relay proof object
func (rp RelayProof) Validate(appSupportedBlockchains []string, sessionNodeCount int, sessionBlockHeight int64) sdk.Error {
func (rp RelayProof) Validate(appSupportedBlockchains []string, sessionBlockHeight int64) sdk.Error {
// validate the session block height
if rp.SessionBlockHeight != sessionBlockHeight {
return NewInvalidBlockHeightError(ModuleName)
Expand Down Expand Up @@ -129,7 +124,7 @@ func (rp RelayProof) ValidateBasic() sdk.Error {
return NewInvalidEntropyError(ModuleName)
}

// verify the AAT token
// validates the AAT in the relay proof
if err := rp.Token.Validate(); err != nil {
return NewInvalidTokenError(ModuleName, err)
}
Expand Down

0 comments on commit 37d245b

Please sign in to comment.