-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Migrate x/staking to Protobuf #5600
Changes from 25 commits
dec703b
31311cb
0d2938b
60dc367
f0f6f50
c268a9e
95edc79
46be4b4
7503396
97ac0b5
8e84801
c35939a
febaae8
5b83d9b
0a904f1
2450409
97148e2
da9d51f
11a0d8b
db45cfc
c5a7baa
3e1b445
d31577c
3dcfea6
05ceef7
c84d960
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ import ( | |
"github.com/cosmos/cosmos-sdk/version" | ||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
"github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
"github.com/cosmos/cosmos-sdk/x/auth/vesting" | ||
"github.com/cosmos/cosmos-sdk/x/bank" | ||
"github.com/cosmos/cosmos-sdk/x/crisis" | ||
distr "github.com/cosmos/cosmos-sdk/x/distribution" | ||
|
@@ -79,16 +78,6 @@ var ( | |
} | ||
) | ||
|
||
// MakeCodec - custom tx codec | ||
func MakeCodec() *codec.Codec { | ||
var cdc = codec.New() | ||
ModuleBasics.RegisterCodec(cdc) | ||
vesting.RegisterCodec(cdc) | ||
sdk.RegisterCodec(cdc) | ||
codec.RegisterCrypto(cdc) | ||
return cdc | ||
} | ||
|
||
// Verify app interface at compile time | ||
var _ App = (*SimApp)(nil) | ||
|
||
|
@@ -135,6 +124,9 @@ func NewSimApp( | |
invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp), | ||
) *SimApp { | ||
|
||
appCodec := NewAppCodec() | ||
|
||
// TODO: Remove cdc in favor of appCodec once all modules are migrated. | ||
cdc := MakeCodec() | ||
|
||
bApp := bam.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) | ||
|
@@ -180,7 +172,7 @@ func NewSimApp( | |
app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms, | ||
) | ||
stakingKeeper := staking.NewKeeper( | ||
app.cdc, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], | ||
appCodec.Staking, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I get it now. Would keepers also receive a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes! Unless they need a custom interface like |
||
) | ||
app.MintKeeper = mint.NewKeeper( | ||
app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package simapp | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/vesting" | ||
"github.com/cosmos/cosmos-sdk/x/staking" | ||
) | ||
|
||
// AppCodec defines the application-level codec. This codec contains all the | ||
// required module-specific codecs that are to be provided upon initialization. | ||
type AppCodec struct { | ||
amino *codec.Codec | ||
|
||
Staking *staking.Codec | ||
} | ||
|
||
func NewAppCodec() *AppCodec { | ||
amino := MakeCodec() | ||
|
||
return &AppCodec{ | ||
amino: amino, | ||
Staking: staking.NewCodec(amino), | ||
} | ||
} | ||
|
||
// MakeCodec creates and returns a reference to an Amino codec that has all the | ||
// necessary types and interfaces registered. This codec is provided to all the | ||
// modules the application depends on. | ||
// | ||
// NOTE: This codec will be deprecated in favor of AppCodec once all modules are | ||
// migrated. | ||
func MakeCodec() *codec.Codec { | ||
var cdc = codec.New() | ||
ModuleBasics.RegisterCodec(cdc) | ||
vesting.RegisterCodec(cdc) | ||
sdk.RegisterCodec(cdc) | ||
codec.RegisterCrypto(cdc) | ||
return cdc | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is golang/protobuf required? This likely means there's a directive needed to make a golang/protobuf type point to a gogo/protobuf type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of our dependency on
e.g.
In addition, gogo proto itself depends on
google/protobuf
. Does gogo proto itself provide these? If so, what advantage is there with one over the other?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need this in protocgen.sh:
See https://github.com/gogo/protobuf#more-speed-and-more-generated-code