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

[core] Protocol Upgrades #948

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
729b558
scope: add upgrade feature files and todos
0xBigBoss Jun 30, 2023
8239913
step: the user is an acl owner
0xBigBoss Jul 21, 2023
15dc15f
cleanup
0xBigBoss Jul 22, 2023
68601ba
add message upgrade, start cli
0xBigBoss Jul 22, 2023
f21945e
turn up the debugs
0xBigBoss Jul 23, 2023
c555dcb
show query mempool failing
0xBigBoss Jul 23, 2023
8a3a246
wip handling upgrade
0xBigBoss Jul 28, 2023
52ac14f
📝 message upgrade
0xBigBoss Jul 29, 2023
4408e6a
🐳 docker tweaks
0xBigBoss Jul 29, 2023
d34715a
💸 to acl owner
0xBigBoss Jul 29, 2023
ff0ea16
📝 persistence
0xBigBoss Jul 29, 2023
8ff4565
fix tests, handle when no upgrades
0xBigBoss Jul 29, 2023
f96a3f1
fix tests, handle when no upgrades
0xBigBoss Jul 29, 2023
7a18107
fix flaky test
0xBigBoss Jul 30, 2023
53422aa
e2e checkpoint
0xBigBoss Jul 30, 2023
c843e47
speed up local dev dockerfiles
0xBigBoss Aug 1, 2023
e33bc06
wip on fixing e2e
0xBigBoss Aug 4, 2023
45a0f56
[utility] fix failed to create servicer
0xBigBoss Aug 5, 2023
b784a7e
fix tests
0xBigBoss Aug 5, 2023
4e6e905
add missing message_upgrade_fee to localnet
0xBigBoss Aug 5, 2023
5c07b9d
localnet improvements
0xBigBoss Aug 5, 2023
2cd8bd8
add upgrade validations, update e2e tests
0xBigBoss Aug 6, 2023
f637943
Merge branch 'main' into 0xbigboss/gov/upgrades-and-params
0xBigBoss Aug 9, 2023
71b1c51
clearer var names
0xBigBoss Aug 9, 2023
3357f2e
formatting
0xBigBoss Aug 9, 2023
580dbfb
test handle message upgrade
0xBigBoss Aug 9, 2023
02a8e4c
Update utility/unit_of_work/uow_leader.go
0xBigBoss Aug 9, 2023
08d55bc
format
0xBigBoss Aug 9, 2023
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
80 changes: 78 additions & 2 deletions app/client/cli/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"
"strconv"

"github.com/spf13/cobra"
"google.golang.org/protobuf/types/known/anypb"
Expand Down Expand Up @@ -46,7 +47,7 @@ func govCommands() []*cobra.Command {
key := args[1]
value := args[2]

// TODO(deblasis): implement RPC client, route and handler
// TODO(0xbigboss): implement RPC client, route and handler
fmt.Printf("changing parameter %s owned by %s to %s\n", args[1], args[0], args[2])

kb, err := keybaseForCLI()
Expand Down Expand Up @@ -87,13 +88,88 @@ func govCommands() []*cobra.Command {
if err != nil {
return err
}
// DISCUSS(#310): define UX for return values - should we return the raw response or a parsed/human readable response? For now, I am simply printing to stdout

if resp.StatusCode() != 200 {
return fmt.Errorf("HTTP status code: %d\n", resp.StatusCode())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything else in the response we can print? A single status code, e.g. 404 for a bad request, does not help the user understand why a request failed.

Copy link
Member Author

@0xBigBoss 0xBigBoss Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to my immediate knowledge. I haven't extensively reviewed our rpc error handling nor our openapi spec. In any case, this should be a new opened in a new issue with your requirements here https://github.com/pokt-network/pocket/blob/main/rpc/v1/openapi.yaml#L1

}

fmt.Printf("Successfully sent change parameter %s owned by %s to %s\n", args[1], args[0], args[2])
0xBigBoss marked this conversation as resolved.
Show resolved Hide resolved
fmt.Printf("HTTP status code: %d\n", resp.StatusCode())
fmt.Println(string(resp.Body))

return nil
},
},
{
Use: "Upgrade <owner> <version> <height>",
Short: "Upgrade ",
Long: "Schedules an upgrade to the specified version at the specified height",
Aliases: []string{"upgrade"},
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
// Unpack CLI arguments
fromAddrHex := args[0]
version := args[1]
heightArg := args[2]

fmt.Printf("submitting upgrade for version %s at height %s.\n", args[0], args[1])
0xBigBoss marked this conversation as resolved.
Show resolved Hide resolved

kb, err := keybaseForCLI()
if err != nil {
return err
}

if !flags.NonInteractive {
pwd = readPassphrase(pwd)
}

pk, err := kb.GetPrivKey(fromAddrHex, pwd)
if err != nil {
return err
}
if err := kb.Stop(); err != nil {
return err
}

height, err := strconv.ParseInt(heightArg, 10, 64)
if err != nil {
return err
}

msg := &types.MessageUpgrade{
Signer: pk.Address(),
Version: version,
Height: height,
}

err = msg.ValidateBasic()
if err != nil {
cmd.PrintErrf("invalid message: %s\n", err)
return err
}

tx, err := prepareTxBytes(msg, pk)
if err != nil {
return err
}

resp, err := postRawTx(cmd.Context(), pk, tx)
if err != nil {
return err
}

if resp.StatusCode() != 200 {
return fmt.Errorf("HTTP status code: %d\n", resp.StatusCode())
}

fmt.Printf("Successfully submitted upgrade for version %s at height %s.\n", args[0], args[1])
fmt.Printf("HTTP status code: %d\n", resp.StatusCode())
fmt.Println(string(resp.Body))

return nil
},
},
// TODO: 0xbigboss MessageCancelUpgrade
}
return cmds
}
2 changes: 1 addition & 1 deletion app/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func queryHeightCommands() []*cobra.Command {
Use: "Upgrade [--height]",
Short: "Get the upgrade version",
Long: "Queries the node RPC to obtain the upgrade version for the given (or latest if unspecified) height",
Aliases: []string{"param"},
Aliases: []string{"upgrade"},
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := rpc.NewClientWithResponses(flags.RemoteCLIURL)
Expand Down
4 changes: 2 additions & 2 deletions app/client/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ func keybaseForCLI() (keybase.Keybase, error) {

func unableToConnectToRpc(err error) error {
fmt.Printf("❌ Unable to connect to the RPC @ %s\n\nError: %s", boldText(flags.RemoteCLIURL), err)
return nil
return fmt.Errorf("unable to connect to the RPC @ %s", flags.RemoteCLIURL)
}

func rpcResponseCodeUnhealthy(statusCode int, response []byte) error {
fmt.Printf("❌ RPC reporting unhealthy status HTTP %d @ %s\n\n%s", statusCode, boldText(flags.RemoteCLIURL), response)
return nil
return fmt.Errorf("RPC reporting unhealthy status HTTP %d @ %s", statusCode, flags.RemoteCLIURL)
}

func boldText[T string | []byte](s T) string {
Expand Down
15 changes: 5 additions & 10 deletions build/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
ARG GOLANG_IMAGE_VERSION=golang:1.20-alpine3.16
ARG GOLANG_IMAGE_VERSION=golang:1.20-bookworm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not against this change, but using a bare-minimum image like alpine and adding what we need to it is highly preferable to using a (potentially) bloated image that happens to have the packages we need preinstalled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh ur an infra guy too? yeah i made this change to have parity with the localnet since both were using debian. Alpine is great for prod, a bit tough on people in development.

In any case, what is ur action here and let's move it to a new issue as to not slow down protocol work.

FROM ${GOLANG_IMAGE_VERSION} AS builder

ENV POCKET_ROOT=/go/src/github.com/pocket-network

WORKDIR $POCKET_ROOT

COPY . .

# Install bash
RUN apk add --no-cache bash

# Hot reloading
RUN go install github.com/cespare/reflex@latest

CMD ["/bin/bash"]
RUN apt-get update && apt-get install -y procps bash-completion jq
RUN echo "source /etc/bash_completion" >> ~/.bashrc
# tail -n +2 removes the first line of the completion script since the CLI spits out some logs
RUN echo "source <($POCKET_ROOT/bin/p1 completion bash | tail -n +2)" >> ~/.bashrc
8 changes: 1 addition & 7 deletions build/Dockerfile.localdev
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ ENV POCKET_ROOT=/go/src/github.com/pocket-network/
# Source code
WORKDIR $POCKET_ROOT

COPY . .
RUN apk update && apk add --no-cache build-base gcc musl-dev

# Hot reloading
RUN go install github.com/cespare/reflex@latest

RUN apk add build-base

# Debugging
RUN go install github.com/go-delve/delve/cmd/dlv@latest

# Needed to make `go install dlv` and `dlv debug` work...
RUN apk update && apk add --no-cache gcc musl-dev
RUN go get github.com/go-delve/delve/cmd/dlv@latest
5 changes: 3 additions & 2 deletions build/config/config.validator1.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@
},
"servicer": {
"enabled": true,
"chains": ["0001"]
"chains": ["0001"],
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e"
},
"ibc": {
"enabled": true,
"stores_dir": "/var/ibc",
"host": {
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e"
"private_key": "0ca1a40ddecdab4f5b04fa0bfed1d235beaa2b8082e7554425607516f0862075dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e"
}
}
}
22 changes: 10 additions & 12 deletions build/config/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -1583,15 +1583,17 @@
{
"address": "099044a5282c4089976c6b13ab13e5423dae55ce",
"amount": "100000000000000"
},
{
"address": "da034209758b78eaea06dd99c07909ab54c99b45",
"amount": "100000000000000"
}
],
"applications": [
{
"actor_type": 1,
"address": "00101f2ff54811e84df2d767c661f57a06349b7e",
"chains": [
"0001"
],
"chains": ["0001"],
"output": "00101f2ff54811e84df2d767c661f57a06349b7e",
"paused_height": -1,
"public_key": "bb851ac31120a4c8848738582f358599abbc3d84638f8fa79f74aeafad1eede0",
Expand All @@ -1604,9 +1606,7 @@
{
"actor_type": 3,
"address": "0010336c3a2cc1ec71fecc45c360214f757194aa",
"chains": [
"0001"
],
"chains": ["0001"],
"output": "0010336c3a2cc1ec71fecc45c360214f757194aa",
"paused_height": -1,
"public_key": "d913a05a6f4bde35413bdcc6343238960cfc7d8aff425fb712dcaa52f1476dbf",
Expand Down Expand Up @@ -1652,6 +1652,8 @@
"fisherman_unstaking_blocks_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_change_parameter_fee": "10000",
"message_change_parameter_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_upgrade_fee": "10000",
"message_upgrade_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_double_sign_fee": "10000",
"message_double_sign_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_edit_stake_app_fee": "10000",
Expand Down Expand Up @@ -1761,9 +1763,7 @@
{
"actor_type": 2,
"address": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"chains": [
"0001"
],
"chains": ["0001"],
"output": "00104055c00bed7c983a48aac7dc6335d7c607a7",
"paused_height": -1,
"public_key": "dfe357de55649e6d2ce889acf15eb77e94ab3c5756fe46d3c7538d37f27f115e",
Expand All @@ -1774,9 +1774,7 @@
{
"actor_type": 2,
"address": "001022b138896c4c5466ac86b24a9bbe249905c2",
"chains": [
"0001"
],
"chains": ["0001"],
"output": "001022b138896c4c5466ac86b24a9bbe249905c2",
"paused_height": -1,
"public_key": "56915c1270bc8d9280a633e0be51647f62388a851318381614877ef2ed84a495",
Expand Down
8 changes: 7 additions & 1 deletion build/config/genesis_localhost.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
{
"address": "88a792b7aca673620132ef01f50e62caa58eca83",
"amount": "100000000000000"
},
{
"address": "da034209758b78eaea06dd99c07909ab54c99b45",
"amount": "100000000000000"
}
],
"pools": [
Expand Down Expand Up @@ -195,6 +199,7 @@
"message_pause_servicer_fee": "10000",
"message_unpause_servicer_fee": "10000",
"message_change_parameter_fee": "10000",
"message_upgrade_fee": "10000",
"acl_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"blocks_per_session_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"app_minimum_stake_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
Expand Down Expand Up @@ -250,7 +255,8 @@
"message_unstake_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_pause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_unpause_servicer_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_change_parameter_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45"
"message_change_parameter_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45",
"message_upgrade_fee_owner": "da034209758b78eaea06dd99c07909ab54c99b45"
},
"genesis_time": {
"seconds": 1663610702,
Expand Down
Loading
Loading