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

Implement SIGN_MODE_DIRECT #6216

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
6a1a345
Add Tx, SignDoc from #6111 to types/types.proto, refactor Tx -> TxI a…
aaronc May 13, 2020
621282d
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 13, 2020
4308623
Add CHANGELOG entry
aaronc May 13, 2020
d8703ef
Add proto doc strings
aaronc May 13, 2020
4a889c8
Add proto doc strings
aaronc May 13, 2020
7f09389
ws
aaronc May 13, 2020
b695a24
ws
aaronc May 13, 2020
4818e1b
Implement SIGN_MODE_DIRECT for single signer mode
aaronc May 13, 2020
8e9de14
Merge branch 'master' into aaronc/6213-sign-mode
aaronc May 13, 2020
7fdec59
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 14, 2020
15de659
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 15, 2020
0d875e1
WIP
aaronc May 15, 2020
15bbcb5
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 20, 2020
6e6142c
Cleanup
aaronc May 20, 2020
c638659
WIP on proto ante handlers
aaronc May 20, 2020
93583a0
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 20, 2020
40911b8
WIP on proto signing handlers
aaronc May 21, 2020
bf5bbdc
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 21, 2020
75e9ad5
WIP on multisigs
aaronc May 21, 2020
33a9ff0
WIP on keys, simapp
aaronc May 21, 2020
b0c3071
implement multisig in ante handler
aaronc May 21, 2020
f21b823
Refactoring
aaronc May 21, 2020
c4b35df
Fix build errors
aaronc May 21, 2020
91f2b3d
Add split integration tests
aaronc May 21, 2020
ff80065
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 21, 2020
87409ac
Setup test_amino
aaronc May 21, 2020
2267516
WIP on proto tx generator
aaronc May 21, 2020
2d6955c
typo
aaronc May 21, 2020
c9ecb0e
Fix tests
aaronc May 22, 2020
77ad336
Split proto/amino unit tests
aaronc May 22, 2020
ca25ce8
Fix amino
aaronc May 22, 2020
3cf884c
Fix tests
aaronc May 22, 2020
9aa57d1
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 22, 2020
7af5d55
fix cli tests
aaronc May 22, 2020
f9f3124
Fix CLi test
aaronc May 22, 2020
d8f9d07
Fix some amino store errors
aaronc May 22, 2020
c12fefa
Switch to using HybridCodec with test_amino for now
aaronc May 22, 2020
ab4ea68
Switch to using HybridCodec with test_amino for now
aaronc May 22, 2020
66fc497
fix cli test
aaronc May 22, 2020
2a30b8c
WIP on proto signing
aaronc May 22, 2020
fe2ec41
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 26, 2020
8e442a9
Fix tests
aaronc May 26, 2020
1f2aee7
Make sdk.Msg implement proto.Message
aaronc May 26, 2020
f61c345
Fix tests
aaronc May 26, 2020
c59d51f
Fix amino tests
aaronc May 26, 2020
cf406a3
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 26, 2020
f089efb
Fix amino build
aaronc May 26, 2020
759dd35
Fix tests
aaronc May 27, 2020
bcada32
Switch proto cli tests to amino JSON
aaronc May 27, 2020
a996a71
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc May 27, 2020
e83ca5f
Fix tests
aaronc May 27, 2020
f8584ae
Fix sims
aaronc May 27, 2020
2e797a1
test fixes
aaronc May 27, 2020
bf1bb2a
WIP on making auth cli stuff proto compatible
aaronc May 28, 2020
dd682b5
Add SignatureV2
aaronc May 28, 2020
88e2ab2
Refactor signature, multisig
aaronc May 28, 2020
da98515
Fix build
aaronc May 28, 2020
bfb3ae6
fix validate sigs
aaronc May 28, 2020
e97b368
Refactor TxBuilder
aaronc May 29, 2020
b0e72fc
fixes
aaronc May 29, 2020
a9d9544
fix tests
aaronc Jun 1, 2020
45f0daf
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc Jun 1, 2020
a71dcc6
fixes
aaronc Jun 1, 2020
e0cb203
fix tests
aaronc Jun 1, 2020
bfc7e69
fix amino build
aaronc Jun 1, 2020
8598372
fix tests
aaronc Jun 1, 2020
7241768
WIP on implementing sign and multisign cmd's
aaronc Jun 2, 2020
f9ce60b
Merge branch 'master' of github.com:cosmos/cosmos-sdk into aaronc/621…
aaronc Jun 2, 2020
b314126
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into aa…
aaronc Jun 8, 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
Prev Previous commit
Next Next commit
WIP on proto tx generator
  • Loading branch information
aaronc committed May 21, 2020
commit 2267516345d10a67c5318062276af9d0dfd1a0af
2 changes: 1 addition & 1 deletion simapp/cmd/simcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var (
appCodec, _, cdc = simapp.MakeCodecs()
appCodec, interfaceRegistry, cdc = simapp.MakeCodecs()
)

func init() {
Expand Down
7 changes: 5 additions & 2 deletions simapp/cmd/simcli/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ package main

import (
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)

func MakeTxCLIContext() context.CLIContext {
cliCtx := context.CLIContext{}
protoCdc := codec.NewProtoCodec(interfaceRegistry)
return cliCtx.
WithJSONMarshaler(appCodec).
WithTxGenerator(types.StdTxGenerator{Cdc: cdc}).
WithJSONMarshaler(protoCdc).
WithTxGenerator(signing.TxGenerator{Marshaler: protoCdc}).
WithAccountRetriever(types.NewAccountRetriever(appCodec)).
WithCodec(cdc)
}
94 changes: 94 additions & 0 deletions types/tx/signing/tx_generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package signing

import (
"fmt"

"github.com/gogo/protobuf/proto"

"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
types "github.com/cosmos/cosmos-sdk/types/tx"
)

type TxGenerator struct {
Marshaler codec.Marshaler
}

var _ context.TxGenerator = TxGenerator{}

func (t TxGenerator) NewTx() context.TxBuilder {
return TxBuilder{}
}

func (t TxGenerator) NewFee() context.ClientFee {
panic("implement me")
}

func (t TxGenerator) NewSignature() context.ClientSignature {
panic("implement me")
}

func (t TxGenerator) MarshalTx(tx sdk.Tx) ([]byte, error) {
ptx, ok := tx.(*types.Tx)
if !ok {
return nil, fmt.Errorf("expected protobuf Tx, got %T", tx)
}
return t.Marshaler.MarshalBinaryBare(ptx)
}

type TxBuilder struct {
*types.Tx
}

var _ context.TxBuilder = TxBuilder{}

func (t TxBuilder) GetTx() sdk.Tx {
return t.Tx
}

func (t TxBuilder) SetMsgs(msgs ...sdk.Msg) error {
anys := make([]*codectypes.Any, len(msgs))
for i, msg := range msgs {
pmsg, ok := msg.(proto.Message)
if !ok {
return fmt.Errorf("cannot proto marshal %T", msg)
}
any, err := codectypes.NewAnyWithValue(pmsg)
if err != nil {
return err
}
anys[i] = any
}
t.Body.Messages = anys
return nil
}

func (t TxBuilder) GetSignatures() []sdk.Signature {
panic("implement me")
}

func (t TxBuilder) SetSignatures(signature ...context.ClientSignature) error {
panic("implement me")
}

func (t TxBuilder) GetFee() sdk.Fee {
panic("implement me")
}

func (t TxBuilder) SetFee(fee context.ClientFee) error {
panic("implement me")
}

func (t TxBuilder) GetMemo() string {
panic("implement me")
}

func (t TxBuilder) SetMemo(s string) {
panic("implement me")
}

func (t TxBuilder) CanonicalSignBytes(cid string, num, seq uint64) ([]byte, error) {
panic("implement me")
}
40 changes: 40 additions & 0 deletions types/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,43 @@ func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
}
return nil
}

var _ sdk.Tx = &Tx{}

func (tx *Tx) GetMsgs() []sdk.Msg {
anys := tx.Body.Messages
res := make([]sdk.Msg, len(anys))
for i, any := range anys {
msg := any.GetCachedValue().(sdk.Msg)
res[i] = msg
}
return res
}

func (tx *Tx) ValidateBasic() error {
// TODO
//stdSigs := tx.GetSignatures()
//
//if tx.Fee.Gas > MaxGasWanted {
// return sdkerrors.Wrapf(
// sdkerrors.ErrInvalidRequest,
// "invalid gas supplied; %d > %d", tx.Fee.Gas, MaxGasWanted,
// )
//}
//if tx.Fee.Amount.IsAnyNegative() {
// return sdkerrors.Wrapf(
// sdkerrors.ErrInsufficientFee,
// "invalid fee provided: %s", tx.Fee.Amount,
// )
//}
//if len(stdSigs) == 0 {
// return sdkerrors.ErrNoSignatures
//}
//if len(stdSigs) != len(tx.GetSigners()) {
// return sdkerrors.Wrapf(
// sdkerrors.ErrUnauthorized,
// "wrong number of signers; expected %d, got %d", tx.GetSigners(), len(stdSigs),
// )
//}
return nil
}