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

proto: migrate x/evidence to hybridcodec #5634

Merged
merged 97 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
adfae21
Migrate types to use proto
alexanderbez Jan 7, 2020
72f70c0
Add newline
alexanderbez Jan 7, 2020
80ab9d6
Fix rand_util
alexanderbez Jan 7, 2020
bf49ef2
Add nolint
alexanderbez Jan 7, 2020
d9c08cf
Implement amino marshal interface for int, uint, and dec
alexanderbez Jan 7, 2020
c5e5c6b
Update encoding doc
alexanderbez Jan 8, 2020
c1b17a5
Update CircleCI config
alexanderbez Jan 8, 2020
28b2da6
Remove tools target from proto job
alexanderbez Jan 8, 2020
f039b99
Rename to CustomProtobufType
alexanderbez Jan 8, 2020
49aa60d
Merge branch 'master' into bez/5444-types-proto-enc
alexanderbez Jan 8, 2020
cd092c0
Merge branch 'master' into bez/5444-types-proto-enc
alexanderbez Jan 8, 2020
b3463f7
changed proto docker image
Jan 8, 2020
f05929c
changed proto job to skip the binary installs
Jan 8, 2020
52e0a49
removed extra files and update proto CI
Jan 8, 2020
161f23b
Use third_party over vendor
alexanderbez Jan 9, 2020
5098419
Merge branch 'master' into bez/5444-types-proto-enc
alexanderbez Jan 9, 2020
7501af3
Merge PR #5505: Convert Int and Dec to string's on Coin and DecCoin p…
aaronc Jan 13, 2020
5c6c08c
Update go.sum
alexanderbez Jan 13, 2020
2e80b77
Fix protoc-gen-gocosmos target by allowing versioning
alexanderbez Jan 13, 2020
9e6a906
Lint
alexanderbez Jan 13, 2020
33400ef
Update go.{mod, sum} and install
alexanderbez Jan 13, 2020
241eafb
wildcard import
alexanderbez Jan 13, 2020
489d5e0
Merge branch 'master' into bez/5444-types-proto-enc
alexanderbez Jan 13, 2020
01f7766
go mod tidy
alexanderbez Jan 13, 2020
bb4ae4e
Bump cosmos-proto to v0.1.0
alexanderbez Jan 13, 2020
d6182fb
Update go.{mod, sum}
alexanderbez Jan 13, 2020
ba12a87
Update third party proto deps
alexanderbez Jan 15, 2020
153dadd
Define Marshaler and ProtoMarshaler interfaces along with BaseCodec type
alexanderbez Jan 16, 2020
94ca99c
Initial commit/demo
alexanderbez Jan 16, 2020
4113099
Fix MarshalAccount
alexanderbez Jan 17, 2020
4499aa0
proto: migrate x/evidence to hybridcodec
tac0turtle Feb 11, 2020
7fd26dd
Prep merge from master
alexanderbez Feb 11, 2020
b268466
Merge branch 'master' into bez/5444-auth-proto-enc
alexanderbez Feb 11, 2020
d463703
Merge branch 'master' into proto/evidence
tac0turtle Feb 11, 2020
fb6fc91
Update codec pkg
alexanderbez Feb 11, 2020
e1d2287
init on mint module
tac0turtle Feb 11, 2020
2d7e8a8
Fix GetAccountWithHeight
alexanderbez Feb 11, 2020
f8c4632
Use codec json over json pkg
alexanderbez Feb 11, 2020
9ef271e
move to custom type over decproto
tac0turtle Feb 11, 2020
2b3644b
add custom marshlers for evidenceI
tac0turtle Feb 11, 2020
aaeaf2e
Update auth types
alexanderbez Feb 11, 2020
305db41
Update account marshal tests
alexanderbez Feb 11, 2020
31af710
Update vesting types
alexanderbez Feb 11, 2020
c21d5fe
Update module APIs
alexanderbez Feb 11, 2020
769e57f
Update client logic to use pkg-level codec
alexanderbez Feb 11, 2020
c242f1c
Proto
alexanderbez Feb 11, 2020
b1d6213
add mint to app codec
tac0turtle Feb 12, 2020
e896ac3
add evidence to appcodec
tac0turtle Feb 12, 2020
45f516e
decoder test
tac0turtle Feb 12, 2020
dc862d1
yaml.marshler in params
tac0turtle Feb 12, 2020
2fa963a
some missed evidienc to ei changes
tac0turtle Feb 13, 2020
41773be
Update vesting (remove codec)
alexanderbez Feb 13, 2020
b218b1e
Update auth types
alexanderbez Feb 13, 2020
56f824b
Update proto
alexanderbez Feb 13, 2020
38338fd
Undo account interface naming
alexanderbez Feb 13, 2020
df62b47
Update APIs
alexanderbez Feb 13, 2020
d9dbdd6
Update alias
alexanderbez Feb 13, 2020
6849bcb
Update simapp codec
alexanderbez Feb 13, 2020
e2fccc0
Add missing UnmarshalAccountJSON
alexanderbez Feb 13, 2020
66c8beb
Update simapp
alexanderbez Feb 13, 2020
96e36b4
Migrate x/supply to proto and update Supply interface
alexanderbez Feb 13, 2020
4d49c14
cleanup module codecs
alexanderbez Feb 13, 2020
4b1b6bb
Define SupplyCodec
alexanderbez Feb 13, 2020
f0aab9f
Restructure x/supply
alexanderbez Feb 13, 2020
fd1758f
Supply proto updates
alexanderbez Feb 14, 2020
98de856
Merge branch 'master' into bez/5444-auth-proto-enc
alexanderbez Feb 14, 2020
eebcba3
Refactor Module Manager to use codec
alexanderbez Feb 14, 2020
348a7e1
Update genutil
alexanderbez Feb 14, 2020
c52731d
Fix cal to DefaultGenesis
alexanderbez Feb 14, 2020
0dfd3ef
Lint
alexanderbez Feb 14, 2020
e9d161c
Fix supply tests
alexanderbez Feb 14, 2020
098e3a9
Update changelog
alexanderbez Feb 14, 2020
2c721af
Update changelog
alexanderbez Feb 14, 2020
2482e86
Add error checking
alexanderbez Feb 15, 2020
08502d6
Remove x/auth Account test type and codec
alexanderbez Feb 15, 2020
40497b6
Merge branch 'bez/5444-auth-proto-enc' into proto/evidence
tac0turtle Feb 17, 2020
2d2ca85
minor change to evidence
tac0turtle Feb 17, 2020
908454e
remove internal frmo mint and generate proto files
tac0turtle Feb 17, 2020
458f682
fix internal imports
tac0turtle Feb 17, 2020
afdac31
Merge branch 'master' into proto/evidence
tac0turtle Feb 20, 2020
14caef0
fix merge conflict bugs
tac0turtle Feb 20, 2020
804ef66
Merge branch 'master' into proto/evidence
alexanderbez Feb 21, 2020
dc39c6a
Update app codec
alexanderbez Feb 21, 2020
4a6278b
Linting
alexanderbez Feb 21, 2020
44db137
Update app codec
alexanderbez Feb 21, 2020
09a1ca6
Update evidence types
alexanderbez Feb 21, 2020
e8cdf95
Update evidence tests
alexanderbez Feb 21, 2020
cedd9d4
Implement MsgSubmitEvidence interface type
alexanderbez Feb 21, 2020
5043f0b
Update mint
alexanderbez Feb 21, 2020
e823947
Fix evidence keeper tests
alexanderbez Feb 24, 2020
2938880
proto lint
alexanderbez Feb 24, 2020
a61d854
Update x/mint
alexanderbez Feb 24, 2020
b871d4b
lint
alexanderbez Feb 24, 2020
ae1ad5c
Update ADR
alexanderbez Feb 24, 2020
5e4340e
Merge branch 'master' into proto/evidence
alexanderbez Feb 24, 2020
7da1786
Add changelog entries
alexanderbez Feb 24, 2020
08f28d9
Merge branch 'proto/evidence' of github.com:cosmos/cosmos-sdk into pr…
alexanderbez Feb 24, 2020
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
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func NewSimApp(
appCodec, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName],
)
app.MintKeeper = mint.NewKeeper(
app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
appCodec, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
app.SupplyKeeper, auth.FeeCollectorName,
)
app.DistrKeeper = distr.NewKeeper(
Expand All @@ -193,7 +193,7 @@ func NewSimApp(

// create evidence keeper with router
evidenceKeeper := evidence.NewKeeper(
app.cdc, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], &app.StakingKeeper, app.SlashingKeeper,
appCodec, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], &app.StakingKeeper, app.SlashingKeeper,
)
evidenceRouter := evidence.NewRouter()
// TODO: Register evidence routes.
Expand Down
59 changes: 50 additions & 9 deletions simapp/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/evidence"
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
"github.com/cosmos/cosmos-sdk/x/supply"
"github.com/cosmos/cosmos-sdk/x/supply/exported"
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
)

var (
_ auth.Codec = (*Codec)(nil)
_ supply.Codec = (*Codec)(nil)
_ auth.Codec = (*Codec)(nil)
_ supply.Codec = (*Codec)(nil)
_ evidence.Codec = (*Codec)(nil)
)

// Codec defines the application-level codec. This codec contains all the
Expand Down Expand Up @@ -72,7 +75,7 @@ func (c *Codec) UnmarshalAccountJSON(bz []byte) (authexported.Account, error) {
// MarshalSupply marshals a SupplyI interface. If the given type implements
// the Marshaler interface, it is treated as a Proto-defined message and
// serialized that way. Otherwise, it falls back on the internal Amino codec.
func (c *Codec) MarshalSupply(supplyI exported.SupplyI) ([]byte, error) {
func (c *Codec) MarshalSupply(supplyI supplyexported.SupplyI) ([]byte, error) {
supply := &Supply{}
if err := supply.SetSupplyI(supplyI); err != nil {
return nil, err
Expand All @@ -83,7 +86,7 @@ func (c *Codec) MarshalSupply(supplyI exported.SupplyI) ([]byte, error) {

// UnmarshalSupply returns a SupplyI interface from raw encoded account bytes
// of a Proto-based SupplyI type. An error is returned upon decoding failure.
func (c *Codec) UnmarshalSupply(bz []byte) (exported.SupplyI, error) {
func (c *Codec) UnmarshalSupply(bz []byte) (supplyexported.SupplyI, error) {
supply := &Supply{}
if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, supply); err != nil {
return nil, err
Expand All @@ -94,12 +97,12 @@ func (c *Codec) UnmarshalSupply(bz []byte) (exported.SupplyI, error) {

// MarshalSupplyJSON JSON encodes a supply object implementing the SupplyI
// interface.
func (c *Codec) MarshalSupplyJSON(supply exported.SupplyI) ([]byte, error) {
func (c *Codec) MarshalSupplyJSON(supply supplyexported.SupplyI) ([]byte, error) {
return c.Marshaler.MarshalJSON(supply)
}

// UnmarshalSupplyJSON returns a SupplyI from JSON encoded bytes.
func (c *Codec) UnmarshalSupplyJSON(bz []byte) (exported.SupplyI, error) {
func (c *Codec) UnmarshalSupplyJSON(bz []byte) (supplyexported.SupplyI, error) {
supply := &Supply{}
if err := c.Marshaler.UnmarshalJSON(bz, supply); err != nil {
return nil, err
Expand All @@ -108,9 +111,47 @@ func (c *Codec) UnmarshalSupplyJSON(bz []byte) (exported.SupplyI, error) {
return supply.GetSupplyI(), nil
}

// ----------------------------------------------------------------------------
// MarshalEvidence marshals an Evidence interface. If the given type implements
// the Marshaler interface, it is treated as a Proto-defined message and
// serialized that way. Otherwise, it falls back on the internal Amino codec.
func (c *Codec) MarshalEvidence(evidenceI eviexported.Evidence) ([]byte, error) {
evidence := &Evidence{}
if err := evidence.SetEvidence(evidenceI); err != nil {
return nil, err
}

// MakeCodec creates and returns a reference to an Amino codec that has all the
return c.Marshaler.MarshalBinaryLengthPrefixed(evidence)
}

// UnmarshalEvidence returns an Evidence interface from raw encoded evidence
// bytes of a Proto-based Evidence type. An error is returned upon decoding
// failure.
func (c *Codec) UnmarshalEvidence(bz []byte) (eviexported.Evidence, error) {
evidence := &Evidence{}
if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, evidence); err != nil {
return nil, err
}

return evidence.GetEvidence(), nil
}

// MarshalEvidenceJSON JSON encodes an evidence object implementing the Evidence
// interface.
func (c *Codec) MarshalEvidenceJSON(evidence eviexported.Evidence) ([]byte, error) {
return c.Marshaler.MarshalJSON(evidence)
}

// UnmarshalEvidenceJSON returns an Evidence from JSON encoded bytes
func (c *Codec) UnmarshalEvidenceJSON(bz []byte) (eviexported.Evidence, error) {
evidence := &Evidence{}
if err := c.Marshaler.UnmarshalJSON(bz, evidence); err != nil {
return nil, err
}

return evidence.GetEvidence(), nil
}

// ----------------------------------------------------------------------------
// necessary types and interfaces registered. This codec is provided to all the
// modules the application depends on.
//
Expand Down
Loading