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

feat: rollapp genesis token locking upon channel creation #333

Merged
merged 32 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8e72ba0
cleanup before changes
mtsitrin Feb 29, 2024
b8915c8
genereated new proto
mtsitrin Mar 13, 2024
3a4224d
added logic
mtsitrin Mar 13, 2024
695fa8c
starting writing tests
mtsitrin Mar 13, 2024
64ff826
moved test app to be part of this repo
mtsitrin Mar 13, 2024
acb80af
minting UT
mtsitrin Mar 13, 2024
8c2444d
renamed field
mtsitrin Mar 13, 2024
a25f7b8
fixed inflation change. added UT
mtsitrin Mar 13, 2024
c86de44
fixed test and mint hooks
mtsitrin Mar 14, 2024
4c6b8cb
removed readme for now
mtsitrin Mar 14, 2024
04c6685
Removed epochProvisionQueries
mtsitrin Mar 14, 2024
ae4ec48
cleanup and fixed tests
mtsitrin Mar 14, 2024
bf199e2
moved test app to seperate package
mtsitrin Mar 14, 2024
293b0f0
linter
mtsitrin Mar 14, 2024
eccb825
adding annual epoch by default
mtsitrin Mar 14, 2024
958571e
validating epoch identifiers exists
mtsitrin Mar 14, 2024
fbc2d8f
fixed init genesis order
mtsitrin Mar 14, 2024
e8a035a
[WIP] Add new module - hub-genesis
zale144 Mar 15, 2024
126d32a
using minute as default epoch
mtsitrin Mar 17, 2024
b08ac6a
calculating spread factor
mtsitrin Mar 17, 2024
f61d4d6
removed spread factor from params
mtsitrin Mar 17, 2024
d217d56
PR comment fixes
zale144 Mar 18, 2024
e5cfc0c
Test fix
zale144 Mar 18, 2024
84b7154
Merge remote-tracking branch 'origin/mtsitrin/305-rdk-mint-module-min…
zale144 Mar 18, 2024
a3527f2
Merge onto 305, removes the rollapp repo dependency
zale144 Mar 18, 2024
ccba761
Small fix
zale144 Mar 18, 2024
28f91ad
Add linter config and fix linting issues
zale144 Mar 18, 2024
8d82b22
Make markdown linter pass
zale144 Mar 18, 2024
29f69df
linter
mtsitrin Mar 18, 2024
a02a72d
Make markdown linter pass
zale144 Mar 18, 2024
7402cce
Merge remote-tracking branch 'origin/mtsitrin/305-rdk-mint-module-min…
zale144 Mar 18, 2024
320e5b5
Merge branch 'main' into feature/add-hub-genesis-module
zale144 Mar 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
uses: nosborn/github-action-markdown-cli@v3.2.0
with:
files: .
config-file: .markdownlint.yaml
config_file: .markdownlint.yaml
42 changes: 42 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
run:
concurrency: 4
timeout: 5m
modules-download-mode: readonly
# mempool and indexer code is borrowed from Tendermint
skip-dirs:
- mempool
- state/indexer
- state/txindex
skip-files:
- da/celestia/mock/server.go
- ./*_test.go

linters:
disable-all: true
enable:
- errcheck
- gofmt
- goimports
- gosimple
- govet
- errcheck
- ineffassign
- revive
- misspell
- staticcheck
- unused
- gocyclo

issues:
exclude-use-default: false
exclude:
- "^.*SA1019.*$" # Excluding SA1019 errors

linters-settings:
revive:
rules:
- name: exported
severity: warning
disabled: true
errcheck:
check-type-assertions: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
proto-gen: ## Generates protobuf files
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protocgen.sh; fi
sh ./proto/protocgen.sh; fi

proto-format: ## Formats protobuf files
@echo "Formatting Protobuf files"
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ require (
github.com/cosmos/cosmos-sdk v0.46.13
github.com/cosmos/ibc-go/v6 v6.1.1
github.com/dymensionxyz/dymint v0.6.0-beta
github.com/dymensionxyz/rollapp v1.0.0-beta
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/libp2p/go-libp2p v0.26.0
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cast v1.5.1
Expand Down Expand Up @@ -183,7 +183,6 @@ require (
github.com/quic-go/qtls-go1-20 v0.1.1 // indirect
github.com/quic-go/quic-go v0.33.0 // indirect
github.com/quic-go/webtransport-go v0.5.1 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/cors v1.8.3 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,6 @@ github.com/dymensionxyz/cosmosclient v0.4.2-beta h1:sokBefcN1tIOlUKmB8Q2E9XMJ93L
github.com/dymensionxyz/dymension v0.2.0-beta.0.20230607115558-745644a96ea6 h1:dnriGXmMdYEiF/8lMrj+PDlN1vyQc6zgs/ZHL67eoyI=
github.com/dymensionxyz/dymint v0.6.0-beta h1:O531cgADz+iZ256gJ7XQ2juwlq7wacd5pnkckj+/c9c=
github.com/dymensionxyz/dymint v0.6.0-beta/go.mod h1:6gPmjTwN/yGXyehCV3wzez1E31f2zX5n9IeMWATj7ik=
github.com/dymensionxyz/rollapp v1.0.0-beta h1:3OFoeFMT/t5aVRwQ8jR5bge4to/ulhyilVOBgE7fK04=
github.com/dymensionxyz/rollapp v1.0.0-beta/go.mod h1:eH/qCtYW9caA7IDWFuM+QZNg0apDIR9MLGa2GPMQSRI=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
Expand Down
6 changes: 4 additions & 2 deletions proto/epochs/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ service Query {
// CurrentEpoch provide current epoch of specified identifier
rpc CurrentEpoch(QueryCurrentEpochRequest)
returns (QueryCurrentEpochResponse) {
option (google.api.http).get = "/dymensionxyz/dymension-rdk/epochs/current_epoch";
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/epochs/current_epoch";
}
// CurrentEpoch provide current epoch of specified identifier
rpc EpochInfo(QueryEpochInfoRequest) returns (QueryEpochInfoResponse) {
option (google.api.http).get = "/dymensionxyz/dymension-rdk/epochs/epoch_info";
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/epochs/epoch_info";
}
}

Expand Down
15 changes: 15 additions & 0 deletions proto/hub-genesis/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package rollapp.hub_genesis;

import "gogoproto/gogo.proto";
import "hub-genesis/params.proto";
import "hub-genesis/hub.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

// GenesisState defines the hub-genesis module's genesis state.
message GenesisState {
// params defines all the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
Hub hub = 2 [ (gogoproto.nullable) = false ];
}
12 changes: 12 additions & 0 deletions proto/hub-genesis/hub.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package rollapp.hub_genesis;

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

// Hub is a protobuf message that contains the genesis state of the rollapp
message Hub {
string hub_id = 1;

// channel_id will be set to the canonical IBC channel connected to the hub.
string channel_id = 2;
}
25 changes: 25 additions & 0 deletions proto/hub-genesis/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package rollapp.hub_genesis;

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

import "gogoproto/gogo.proto";

// Params holds parameters for the hub-genesis module.
message Params {
option (gogoproto.goproto_stringer) = false;

// genesis_triggerer_whitelist is a list of the
// accounts that are allowed to trigger a genesis event on the rollapp.
// In the case of an empty list, there are no restrictions
repeated GenesisTriggererParams genesis_triggerer_whitelist = 1 [
(gogoproto.moretags) = "yaml:\"genesis_triggerer_whitelist\"",
(gogoproto.nullable) = false
];
}

message GenesisTriggererParams {
// address is a bech32-encoded address of the
// accounts that are allowed to trigger a rollapp genesis event.
string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
}
42 changes: 42 additions & 0 deletions proto/hub-genesis/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
syntax = "proto3";
package rollapp.hub_genesis;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "hub-genesis/params.proto";
import "hub-genesis/hub.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

// Query provides defines the gRPC querier service.
service Query {
// Hub returns the hub information
rpc Hub(QueryGetHubRequest) returns (QueryGetHubResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/hub-genesis/hub/{hub_id}";
}
// Params returns the total set of hub-genesis parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get =
"/dymensionxyz/dymension-rdk/hub-genesis/params";
}
}

message QueryGetHubRequest {
// id is the id of the hub
string hub_id = 1;
}

message QueryGetHubResponse {
// hub is the hub information
Hub hub = 1 [ (gogoproto.nullable) = false ];
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
}
24 changes: 24 additions & 0 deletions proto/hub-genesis/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";
package rollapp.hub_genesis;

option go_package = "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types";

import "gogoproto/gogo.proto";

// Msg defines the Msg service.
service Msg {
rpc TriggerGenesisEvent(MsgHubGenesisEvent)
returns (MsgHubGenesisEventResponse);
}

// MsgHubGenesisEvent is the message type for triggering the hub genesis event
message MsgHubGenesisEvent {
// address is the bech32-encoded address of the sender
string address = 1;
// channel_id is the hub channel id on the rollapp
string channel_id = 2;
// hub_id is the hub id
string hub_id = 3;
}

message MsgHubGenesisEventResponse {}
8 changes: 2 additions & 6 deletions proto/mint/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
syntax = "proto3";
package rollapp.mint.v1beta1;


import "gogoproto/gogo.proto";
import "mint/v1beta1/mint.proto";
import "mint/v1beta1/params.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/mint/types";

// GenesisState defines the mint module's genesis state.
message GenesisState {
// minter is a space for holding current rewards information.
// minter is a space for holding current inflation information.
Minter minter = 1 [ (gogoproto.nullable) = false ];

// params defines all the paramaters of the module.
Params params = 2 [ (gogoproto.nullable) = false ];

// current reduction period start epoch
int64 reduction_started_epoch = 3
[ (gogoproto.moretags) = "yaml:\"reduction_started_epoch\"" ];
}
35 changes: 2 additions & 33 deletions proto/mint/v1beta1/mint.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,9 @@ import "gogoproto/gogo.proto";

// Minter represents the minting state.
message Minter {
// current epoch provisions
string epoch_provisions = 1 [
(gogoproto.moretags) = "yaml:\"epoch_provisions\"",
string current_inflation_rate = 1 [
(gogoproto.moretags) = "yaml:\"current_inflation_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// Params holds parameters for the mint module.
message Params {
option (gogoproto.goproto_stringer) = false;

// type of coin to mint
string mint_denom = 1;
// epoch provisions from the first epoch
string genesis_epoch_provisions = 2 [
(gogoproto.moretags) = "yaml:\"genesis_epoch_provisions\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// mint epoch identifier
string epoch_identifier = 3
[ (gogoproto.moretags) = "yaml:\"epoch_identifier\"" ];
// number of epochs take to reduce rewards
int64 reduction_period_in_epochs = 4
[ (gogoproto.moretags) = "yaml:\"reduction_period_in_epochs\"" ];
// reduction multiplier to execute on each period
string reduction_factor = 5 [
(gogoproto.moretags) = "yaml:\"reduction_factor\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// start epoch to distribute minting rewards
int64 minting_rewards_distribution_start_epoch = 6
[ (gogoproto.moretags) =
"yaml:\"minting_rewards_distribution_start_epoch\"" ];
}
39 changes: 39 additions & 0 deletions proto/mint/v1beta1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";
package rollapp.mint.v1beta1;

option go_package = "github.com/dymensionxyz/dymension-rdk/x/mint/types";

import "gogoproto/gogo.proto";

// Params holds parameters for the mint module.
message Params {
option (gogoproto.goproto_stringer) = false;

// type of coin to mint
string mint_denom = 1;

// mint epoch identifier
string mint_epoch_identifier = 2
[ (gogoproto.moretags) = "yaml:\"mint_epoch_identifier\"" ];

// start epoch to start minting rewards from
int64 mint_start_epoch = 3
[ (gogoproto.moretags) =
"yaml:\"minting_rewards_distribution_start_epoch\"" ];


string inflation_change_epoch_identifier = 4
[ (gogoproto.moretags) = "yaml:\"inflation_change_epoch_identifier\"" ];

string inflation_rate_change = 5 [
(gogoproto.moretags) = "yaml:\"inflation_rate_change\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

string target_inflation_rate = 6 [
(gogoproto.moretags) = "yaml:\"target_inflation_rate\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
21 changes: 1 addition & 20 deletions proto/mint/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package rollapp.mint.v1beta1;
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "mint/v1beta1/mint.proto";
import "mint/v1beta1/params.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/mint/types";

Expand All @@ -13,12 +14,6 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/mint/v1beta1/params";
}

// EpochProvisions current minting epoch provisions value.
rpc EpochProvisions(QueryEpochProvisionsRequest)
returns (QueryEpochProvisionsResponse) {
option (google.api.http).get = "/mint/v1beta1/epoch_provisions";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
Expand All @@ -29,17 +24,3 @@ message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
}

// QueryEpochProvisionsRequest is the request type for the
// Query/EpochProvisions RPC method.
message QueryEpochProvisionsRequest {}

// QueryEpochProvisionsResponse is the response type for the
// Query/EpochProvisions RPC method.
message QueryEpochProvisionsResponse {
// epoch_provisions is the current minting per epoch provisions value.
bytes epoch_provisions = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
1 change: 1 addition & 0 deletions server/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func ShowNodeIDCmd() *cobra.Command {
return err
}
// convert nodeKey to libp2p key
// nolint: typecheck
host, err := libp2p.New(libp2p.Identity(signingKey))
if err != nil {
return err
Expand Down
Loading
Loading