Skip to content

Commit

Permalink
Merge pull request #485 from maticnetwork/arpit/gov_porting
Browse files Browse the repository at this point in the history
gov porting
  • Loading branch information
jdkanani authored Jan 22, 2021
2 parents bd5827f + ff823a1 commit 880c2fb
Show file tree
Hide file tree
Showing 107 changed files with 10,697 additions and 4,938 deletions.
55 changes: 42 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ import (
"github.com/maticnetwork/heimdall/x/chainmanager"
chainKeeper "github.com/maticnetwork/heimdall/x/chainmanager/keeper"
chainmanagerTypes "github.com/maticnetwork/heimdall/x/chainmanager/types"
"github.com/maticnetwork/heimdall/x/clerk"

// "github.com/maticnetwork/heimdall/x/clerk"
// clerkkeeper "github.com/maticnetwork/heimdall/x/clerk/keeper"
// clerktypes "github.com/maticnetwork/heimdall/x/clerk/types"
"github.com/maticnetwork/heimdall/x/clerk"
clerkkeeper "github.com/maticnetwork/heimdall/x/clerk/keeper"
clerktypes "github.com/maticnetwork/heimdall/x/clerk/types"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand All @@ -62,6 +61,9 @@ import (
hmtypes "github.com/maticnetwork/heimdall/types"
"github.com/maticnetwork/heimdall/types/common"
hmmodule "github.com/maticnetwork/heimdall/types/module"
"github.com/maticnetwork/heimdall/x/gov"
govkeeper "github.com/maticnetwork/heimdall/x/gov/keeper"
govtypes "github.com/maticnetwork/heimdall/x/gov/types"
"github.com/maticnetwork/heimdall/x/sidechannel"
sidechannelkeeper "github.com/maticnetwork/heimdall/x/sidechannel/keeper"
sidechanneltypes "github.com/maticnetwork/heimdall/x/sidechannel/types"
Expand Down Expand Up @@ -97,6 +99,7 @@ var (
sidechannel.AppModuleBasic{},
staking.AppModuleBasic{},
params.AppModuleBasic{},
gov.AppModuleBasic{},
checkpoint.AppModuleBasic{},
topup.AppModuleBasic{},
clerk.AppModuleBasic{},
Expand All @@ -105,6 +108,7 @@ var (
// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
govtypes.ModuleName: {},
}

// module accounts that are allowed to receive tokens
Expand Down Expand Up @@ -132,13 +136,14 @@ type HeimdallApp struct {
tkeys map[string]*sdk.TransientStoreKey

// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
ChainKeeper chainKeeper.Keeper
// ClerkKeeper clerkkeeper.Keeper
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
ChainKeeper chainKeeper.Keeper
ClerkKeeper clerkkeeper.Keeper
SidechannelKeeper sidechannelkeeper.Keeper
StakingKeeper stakingkeeper.Keeper
ParamsKeeper paramskeeper.Keeper
GovKeeper govkeeper.Keeper
CheckpointKeeper checkpointkeeper.Keeper
TopupKeeper topupkeeper.Keeper

Expand Down Expand Up @@ -201,7 +206,7 @@ func NewHeimdallApp(
checkpointtypes.StoreKey,
// distrtypes.StoreKey,
// slashingtypes.StoreKey,
// govtypes.StoreKey,
govtypes.StoreKey,
paramstypes.StoreKey,
topuptypes.StoreKey,
)
Expand Down Expand Up @@ -273,6 +278,22 @@ func NewHeimdallApp(
nil,
)

app.GovKeeper = govkeeper.NewKeeper(
appCodec,
keys[govtypes.StoreKey], // target store
app.GetSubspace(govtypes.ModuleName),
app.BankKeeper,
govtypes.NewRouter(),
&app.StakingKeeper,
app.AccountKeeper,
)

app.ClerkKeeper = clerkkeeper.NewKeeper(
appCodec,
keys[clerktypes.StoreKey], // target store
app.ChainKeeper,
)

app.TopupKeeper = topupkeeper.NewKeeper(
appCodec,
keys[topuptypes.StoreKey],
Expand All @@ -281,6 +302,7 @@ func NewHeimdallApp(
app.BankKeeper,
app.StakingKeeper,
)

// Contract caller
contractCallerObj, err := helper.NewContractCaller()
if err != nil {
Expand Down Expand Up @@ -308,7 +330,8 @@ func NewHeimdallApp(
sidechannel.NewAppModule(appCodec, app.SidechannelKeeper),
chainmanager.NewAppModule(appCodec, app.ChainKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper, &app.caller),
// clerk.NewAppModule(appCodec, app.ClerkKeeper, &app.caller),
clerk.NewAppModule(appCodec, app.ClerkKeeper, &app.caller),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
params.NewAppModule(app.ParamsKeeper),
checkpoint.NewAppModule(appCodec, app.CheckpointKeeper, &app.caller),
)
Expand All @@ -324,6 +347,11 @@ func NewHeimdallApp(
app.mm.SetOrderEndBlockers(
sidechanneltypes.ModuleName,
stakingtypes.ModuleName,
govtypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
stakingtypes.ModuleName,
govtypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand All @@ -340,6 +368,7 @@ func NewHeimdallApp(
checkpointtypes.ModuleName,
// clerktypes.ModuleName,
genutiltypes.ModuleName,
govtypes.ModuleName,
)

// app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down Expand Up @@ -490,9 +519,9 @@ func (app *HeimdallApp) LoadHeight(height int64) error {
// ModuleAccountAddrs returns all the app's module account addresses.
func (app *HeimdallApp) ModuleAccountAddrs() map[string]bool {
modAccAddrs := make(map[string]bool)
// for acc := range maccPerms {
// modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
// }
for acc := range maccPerms {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
}

return modAccAddrs
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/heimdalld/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ func initCmd(ctx *server.Context, amino *codec.LegacyAmino, mbm module.BasicMana
return fmt.Errorf("failed to convert accounts into any's: %w", err)
}
authGenState.Accounts = genAccs
appState[authtypes.ModuleName] = authclient.Codec.MustMarshalJSON(&authGenState)
// TODO - check this
// appState[authtypes.ModuleName] = authclient.Codec.MustMarshalJSON(&authGenState)

//
// staking state change
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4
google.golang.org/grpc v1.35.0
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down
28 changes: 15 additions & 13 deletions proto/chainmanager/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package chainmanager.v1beta1;
package heimdall.chainmanager.v1beta1;

import "gogoproto/gogo.proto";

Expand All @@ -17,22 +17,24 @@ message GenesisState {
message ChainParams {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
string bor_chain_id = 1 [(gogoproto.customname) = "BorChainID"];
string matic_token_address = 2;
string staking_manager_address = 3;
string slash_manager_address = 4;
string root_chain_address = 5;
string staking_info_address = 6;
string state_sender_address = 7;
string state_receiver_address = 8;
string validator_set_address = 9;
string bor_chain_id = 1
[(gogoproto.customname) = "BorChainID", (gogoproto.moretags) = "yaml:\"bor_chain_id\""];
string matic_token_address = 2 [(gogoproto.moretags) = "yaml:\"matic_token_address\""];
string staking_manager_address = 3 [(gogoproto.moretags) = "yaml:\"staking_manager_address\""];
string slash_manager_address = 4 [(gogoproto.moretags) = "yaml:\"slash_manager_address\""];
string root_chain_address = 5 [(gogoproto.moretags) = "yaml:\"root_chain_address\""];
string staking_info_address = 6 [(gogoproto.moretags) = "yaml:\"staking_info_address\""];
string state_sender_address = 7 [(gogoproto.moretags) = "yaml:\"state_sender_address\""];
string state_receiver_address = 8 [(gogoproto.moretags) = "yaml:\"state_receiver_address\""];
string validator_set_address = 9 [(gogoproto.moretags) = "yaml:\"validator_set_address\""];
}

message Params {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

uint64 mainchain_tx_confirmations = 1;
uint64 maticchain_tx_confirmations = 2;
ChainParams chain_params = 3 [(gogoproto.nullable) = false];
uint64 mainchain_tx_confirmations = 1 [(gogoproto.moretags) = "yaml:\"mainchain_tx_confirmations\""];
uint64 maticchain_tx_confirmations = 2 [(gogoproto.moretags) = "yaml:\"maticchain_tx_confirmations\""];
ChainParams chain_params = 3
[(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"chain_params\""];
}
4 changes: 2 additions & 2 deletions proto/chainmanager/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package chainmanager.v1beta1;
package heimdall.chainmanager.v1beta1;

import "chainmanager/v1beta1/genesis.proto";
import "google/api/annotations.proto";
Expand All @@ -15,7 +15,7 @@ option (gogoproto.unmarshaler_all) = true;
service Query {
// Params queries all parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/chainmanager/v1beta1/params";
option (google.api.http).get = "/heimdall/chainmanager/v1beta1/params";
}
}

Expand Down
16 changes: 9 additions & 7 deletions proto/checkpoint/v1beta/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ message Params {
option (gogoproto.goproto_stringer) = false;

google.protobuf.Duration checkpoint_buffer_time = 1
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
uint64 avg_checkpoint_length = 2;
uint64 max_checkpoint_length = 3;
uint64 child_block_interval = 4;
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true,
(gogoproto.moretags) = "yaml:\"checkpoint_buffer_time\""];
uint64 avg_checkpoint_length = 2 [(gogoproto.moretags) = "yaml:\"avg_checkpoint_length\""];
uint64 max_checkpoint_length = 3 [(gogoproto.moretags) = "yaml:\"max_checkpoint_length\""];
uint64 child_block_interval = 4 [(gogoproto.moretags) = "yaml:\"child_block_interval\""];
}

// GenesisState defines the checkpoint module's genesis state.
Expand All @@ -28,8 +29,9 @@ message GenesisState {
option (gogoproto.goproto_stringer) = true;

Params params = 1 [(gogoproto.nullable) = false];
heimdall.types.Checkpoint buffered_checkpoint = 2;
uint64 last_no_ack = 3 [(gogoproto.customname) = "LastNoACK"];
uint64 ack_count = 4;
heimdall.types.Checkpoint buffered_checkpoint = 2 [(gogoproto.moretags) = "yaml:\"buffered_checkpoint\""];
uint64 last_no_ack = 3 [(gogoproto.customname) = "LastNoACK",
(gogoproto.moretags) = "yaml:\"last_no_ack\""];
uint64 ack_count = 4 [(gogoproto.moretags) = "yaml:\"ack_count\""];
repeated heimdall.types.Checkpoint checkpoints = 5;
}
22 changes: 11 additions & 11 deletions proto/checkpoint/v1beta/msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option (gogoproto.sizer_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;

// Msg defines the checkpoing Msg service.
// Msg defines the checkpoint Msg service.
service Msg {
// Checkpoint defines Checkpoint.
rpc Checkpoint(MsgCheckpoint) returns (MsgCheckpointResponse);
Expand All @@ -28,11 +28,11 @@ message MsgCheckpoint {
option (gogoproto.goproto_getters) = false;

string proposer = 1;
uint64 start_block = 2;
uint64 end_block = 3;
bytes root_hash = 4;
bytes account_root_hash = 5;
string bor_chainID = 6;
uint64 start_block = 2 [(gogoproto.moretags) = "yaml:\"start_block\""];
uint64 end_block = 3 [(gogoproto.moretags) = "yaml:\"end_block\""];
string root_hash = 4 [(gogoproto.moretags) = "yaml:\"root_hash\""];
string account_root_hash = 5 [(gogoproto.moretags) = "yaml:\"account_root_hash\""];
string bor_chainID = 6 [(gogoproto.moretags) = "yaml:\"bor_chainID\""];
}

// MsgValidatorJoinResponse defines ValidatorJoin response type.
Expand All @@ -46,11 +46,11 @@ message MsgCheckpointAck {
string from = 1;
uint64 number = 2;
string proposer = 3;
uint64 start_block = 4;
uint64 end_block = 5;
string root_hash = 6;
string tx_hash = 7;
uint64 log_index = 8;
uint64 start_block = 4 [(gogoproto.moretags) = "yaml:\"start_block\""];
uint64 end_block = 5 [(gogoproto.moretags) = "yaml:\"end_block\""];
string root_hash = 6 [(gogoproto.moretags) = "yaml:\"root_hash\""];
string tx_hash = 7 [(gogoproto.moretags) = "yaml:\"tx_hash\""];
uint64 log_index = 8 [(gogoproto.moretags) = "yaml:\"log_index\""];
}

// MsgCheckpointAckResponse defines CheckpointAck response type.
Expand Down
2 changes: 1 addition & 1 deletion proto/checkpoint/v1beta/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "checkpoint/v1beta/genesis.proto";
import "checkpoint/v1beta/msg.proto";
import "google/api/annotations.proto";
import "heimdall/types/headers.proto";
import "heimdall/types/querier.proto";
import "heimdall/types/query.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/maticnetwork/heimdall/x/checkpoint/types";
Expand Down
9 changes: 4 additions & 5 deletions proto/clerk/v1beta/clerk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ message EventRecord {

uint64 id = 1
[(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""];
string contract = 2 [(gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress"];
string contract = 2;
bytes data = 3;
google.protobuf.Timestamp record_time = 4 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"record_time\""
];
uint64 log_index = 5;
bytes tx_hash = 6;
string chain_id = 7;
uint64 log_index = 5 [(gogoproto.moretags) = "yaml:\"log_index\""];
string tx_hash = 6 [(gogoproto.moretags) = "yaml:\"tx_hash\""];
string chain_id = 7 [(gogoproto.moretags) = "yaml:\"chain_id\""];
}
4 changes: 2 additions & 2 deletions proto/clerk/v1beta/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ option (gogoproto.unmarshaler_all) = true;

// GenesisState defines the clerk module's genesis state.
message GenesisState {
repeated EventRecord event_records = 1;
repeated string record_sequences = 2;
repeated EventRecord event_records = 1 [(gogoproto.moretags) = "yaml:\"event_records\""];
repeated string record_sequences = 2 [(gogoproto.moretags) = "yaml:\"record_sequences\""];
}
21 changes: 8 additions & 13 deletions proto/clerk/v1beta/msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ service Msg {

message MsgEventRecordRequest {
option (gogoproto.goproto_getters) = false;
string from = 1 [(gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress"];
string tx_hash = 2
[(gogoproto.casttype) =
"github.com/maticnetwork/heimdall/types/common.HeimdallHash"];
uint64 log_index = 3;
uint64 block_number = 4;
string contract_address = 5
[(gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress"];
bytes data = 6;
uint64 id = 7;
string chain_id = 8;
string from = 1;
string tx_hash = 2 [(gogoproto.moretags) = "yaml:\"tx_hash\""];
uint64 log_index = 3 [(gogoproto.moretags) = "yaml:\"log_index\""];
uint64 block_number = 4 [(gogoproto.moretags) = "yaml:\"block_number\""];
string contract_address = 5 [(gogoproto.moretags) = "yaml:\"contract_address\""];
bytes data = 6;
uint64 id = 7;
string chain_id = 8 [(gogoproto.moretags) = "yaml:\"chain_id\""];
}

// MsgEventRecordResponse defines MsgEventRecord response type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ service Query {

// QueryRecordParams is request type for the Query/Record RPC method
message QueryRecordParams {
uint64 record_id = 1;
uint64 record_id = 1 ;
}

// QueryRecordResponse is response type for the Query/Record RPC method
Expand Down
Loading

0 comments on commit 880c2fb

Please sign in to comment.