diff --git a/hermes_config.toml b/hermes_config.toml index 294a29f5..3c9d7a02 100644 --- a/hermes_config.toml +++ b/hermes_config.toml @@ -1,5 +1,6 @@ [global] log_level = 'info' + [mode.clients] enabled = true refresh = true @@ -16,6 +17,7 @@ enabled = true clear_interval = 100 clear_on_start = true tx_confirmation = false +auto_register_counterparty_payee = false [rest] enabled = false @@ -44,6 +46,7 @@ max_msg_num = 30 max_tx_size = 2097152 clock_drift = '5s' max_block_time = '30s' +trusting_period = '14days' memo_prefix = '' sequential_batch_tx = false @@ -76,6 +79,7 @@ max_msg_num = 30 max_tx_size = 2097152 clock_drift = '5s' max_block_time = '30s' +trusting_period = '14days' memo_prefix = '' sequential_batch_tx = false diff --git a/proto/fairyring/pep/packet.proto b/proto/fairyring/pep/packet.proto index 9ec7aaa4..aa2005b5 100644 --- a/proto/fairyring/pep/packet.proto +++ b/proto/fairyring/pep/packet.proto @@ -21,6 +21,6 @@ message CurrentKeysPacketData { // CurrentKeysPacketAck defines a struct for the packet acknowledgment message CurrentKeysPacketAck { - ActivePubKey activeKey = 2; - QueuedPubKey queuedKey = 3; + ActivePubKey activeKey = 1; + QueuedPubKey queuedKey = 2; } diff --git a/x/pep/keeper/current_keys.go b/x/pep/keeper/current_keys.go index f4967978..6b30e947 100644 --- a/x/pep/keeper/current_keys.go +++ b/x/pep/keeper/current_keys.go @@ -2,6 +2,7 @@ package keeper import ( "errors" + cosmoserror "github.com/cosmos/cosmos-sdk/types/errors" "time" "fairyring/x/pep/types" @@ -61,7 +62,10 @@ func (k Keeper) TransmitCurrentKeysPacket( return sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") } - packetBytes := packetData.GetBytes() + packetBytes, err := packetData.GetBytes() + if err != nil { + return sdkerrors.Wrap(cosmoserror.ErrJSONMarshal, "cannot marshal the packet: "+err.Error()) + } if _, err := k.ChannelKeeper.SendPacket(ctx, channelCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, packetBytes); err != nil { return err diff --git a/x/pep/module_ibc.go b/x/pep/module_ibc.go index 4640db83..8edd84dc 100644 --- a/x/pep/module_ibc.go +++ b/x/pep/module_ibc.go @@ -194,7 +194,7 @@ func (im IBCModule) OnAcknowledgementPacket( // this line is used by starport scaffolding # oracle/packet/module/ack var modulePacketData types.PepPacketData - if err := modulePacketData.Unmarshal(modulePacket.GetData()); err != nil { + if err := types.ModuleCdc.UnmarshalJSON(modulePacket.GetData(), &modulePacketData); err != nil { return sdkerrors.Wrapf(cosmoserror.ErrUnknownRequest, "cannot unmarshal packet data: %s", err.Error()) } diff --git a/x/pep/types/codec.go b/x/pep/types/codec.go index d36fe726..835af657 100644 --- a/x/pep/types/codec.go +++ b/x/pep/types/codec.go @@ -46,7 +46,7 @@ func init() { // NOTE: Copied from https://github.com/cosmos/cosmos-sdk/blob/971c542453e0972ef1dfc5a80159ad5049c7211c/codec/json.go // and modified in order to allow `EmitDefaults` to be set to false for ics20 packet marshalling. // This allows for the introduction of the memo field to be backwards compatible. -func MustProtoMarshalJSON(msg proto.Message) []byte { +func MustProtoMarshalJSON(msg proto.Message) ([]byte, error) { anyResolver := cdctypes.NewInterfaceRegistry() // EmitDefaults is set to false to prevent marshalling of unpopulated fields (memo) @@ -59,13 +59,13 @@ func MustProtoMarshalJSON(msg proto.Message) []byte { err := cdctypes.UnpackInterfaces(msg, cdctypes.ProtoJSONPacker{JSONPBMarshaler: jm}) if err != nil { - panic(err) + return nil, err } buf := new(bytes.Buffer) if err := jm.Marshal(buf, msg); err != nil { - panic(err) + return nil, err } - return buf.Bytes() + return buf.Bytes(), err } diff --git a/x/pep/types/current_keys.go b/x/pep/types/current_keys.go index 32768ee9..173844c8 100644 --- a/x/pep/types/current_keys.go +++ b/x/pep/types/current_keys.go @@ -8,10 +8,14 @@ func (p CurrentKeysPacketData) ValidateBasic() error { } // GetBytes is a helper for serialising -func (p CurrentKeysPacketData) GetBytes() []byte { +func (p CurrentKeysPacketData) GetBytes() ([]byte, error) { var modulePacket PepPacketData modulePacket.Packet = &PepPacketData_CurrentKeysPacket{&p} - return sdk.MustSortJSON(MustProtoMarshalJSON(&modulePacket)) + b, err := MustProtoMarshalJSON(&modulePacket) + if err != nil { + return nil, err + } + return sdk.MustSortJSON(b), nil } diff --git a/x/pep/types/packet.pb.go b/x/pep/types/packet.pb.go index f5387f87..c19c9a24 100644 --- a/x/pep/types/packet.pb.go +++ b/x/pep/types/packet.pb.go @@ -182,8 +182,8 @@ var xxx_messageInfo_CurrentKeysPacketData proto.InternalMessageInfo // CurrentKeysPacketAck defines a struct for the packet acknowledgment type CurrentKeysPacketAck struct { - ActiveKey *ActivePubKey `protobuf:"bytes,2,opt,name=activeKey,proto3" json:"activeKey,omitempty"` - QueuedKey *QueuedPubKey `protobuf:"bytes,3,opt,name=queuedKey,proto3" json:"queuedKey,omitempty"` + ActiveKey *ActivePubKey `protobuf:"bytes,1,opt,name=activeKey,proto3" json:"activeKey,omitempty"` + QueuedKey *QueuedPubKey `protobuf:"bytes,2,opt,name=queuedKey,proto3" json:"queuedKey,omitempty"` } func (m *CurrentKeysPacketAck) Reset() { *m = CurrentKeysPacketAck{} } @@ -255,12 +255,12 @@ var fileDescriptor_69dc34a7ea22bf8e = []byte{ 0x1d, 0xd4, 0x28, 0x4c, 0x03, 0x9c, 0x38, 0xb8, 0xd8, 0x20, 0x9e, 0x52, 0xe2, 0xe0, 0x62, 0x83, 0xd8, 0xa9, 0x24, 0xce, 0x25, 0x8a, 0xd5, 0x04, 0xa5, 0x1e, 0x46, 0x2e, 0x11, 0x0c, 0x19, 0xc7, 0xe4, 0x6c, 0x21, 0x4b, 0x2e, 0xce, 0xc4, 0xe4, 0x92, 0xcc, 0xb2, 0x54, 0xef, 0xd4, 0x4a, 0xa8, - 0x9b, 0xa4, 0xd1, 0xdc, 0xe4, 0x08, 0x96, 0x0f, 0x28, 0x4d, 0xf2, 0x4e, 0xad, 0x0c, 0x42, 0xa8, - 0x06, 0x69, 0x2d, 0x2c, 0x4d, 0x2d, 0x4d, 0x4d, 0x01, 0x69, 0x65, 0xc6, 0xaa, 0x35, 0x10, 0x2c, + 0x7f, 0xa4, 0xd1, 0xdc, 0xe4, 0x08, 0x96, 0x0f, 0x28, 0x4d, 0xf2, 0x4e, 0xad, 0x0c, 0x42, 0xa8, + 0x06, 0x69, 0x2d, 0x2c, 0x4d, 0x2d, 0x4d, 0x4d, 0x01, 0x69, 0x65, 0xc2, 0xaa, 0x35, 0x10, 0x2c, 0x0f, 0xd3, 0x0a, 0x57, 0xed, 0xa4, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa2, 0x88, 0xb8, 0xa8, 0x00, 0xc7, 0x46, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, - 0x32, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x46, 0x47, 0xf2, 0x92, 0xd6, 0x01, 0x00, 0x00, + 0x32, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x7d, 0x51, 0x1e, 0xd6, 0x01, 0x00, 0x00, } func (m *PepPacketData) Marshal() (dAtA []byte, err error) { @@ -413,7 +413,7 @@ func (m *CurrentKeysPacketAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPacket(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x12 } if m.ActiveKey != nil { { @@ -425,7 +425,7 @@ func (m *CurrentKeysPacketAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintPacket(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -767,7 +767,7 @@ func (m *CurrentKeysPacketAck) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: CurrentKeysPacketAck: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 2: + case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ActiveKey", wireType) } @@ -803,7 +803,7 @@ func (m *CurrentKeysPacketAck) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field QueuedKey", wireType) }