From 58f13c601a1c5efabecea1e166a0f6a5640090fa Mon Sep 17 00:00:00 2001 From: yuandu Date: Thu, 12 Oct 2023 10:18:32 +0800 Subject: [PATCH 1/2] chore: group reject msgs ante handler --- ante/handler_options.go | 1 - ante/reject_msgs.go | 15 +++++++++++++-- ante/vesting.go | 31 ------------------------------- 3 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 ante/vesting.go diff --git a/ante/handler_options.go b/ante/handler_options.go index fdd1ba244..1b02f7481 100644 --- a/ante/handler_options.go +++ b/ante/handler_options.go @@ -64,7 +64,6 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler { func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler { return sdk.ChainAnteDecorators( RejectMessagesDecorator{}, - NewRejectVestingDecorator(), ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), ante.NewValidateBasicDecorator(), diff --git a/ante/reject_msgs.go b/ante/reject_msgs.go index f2728895c..3b5b448f6 100644 --- a/ante/reject_msgs.go +++ b/ante/reject_msgs.go @@ -4,22 +4,33 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" errortypes "github.com/cosmos/cosmos-sdk/types/errors" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" evmtypes "github.com/evmos/ethermint/x/evm/types" ) // RejectMessagesDecorator prevents invalid msg types from being executed type RejectMessagesDecorator struct{} -// AnteHandle rejects messages that requires ethereum-specific authentication. +// AnteHandle rejects the following messages: +// 1. Messages that requires ethereum-specific authentication. // For example `MsgEthereumTx` requires fee to be deducted in the antehandler in // order to perform the refund. +// 2. Messages that creates vesting accounts. func (rmd RejectMessagesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { for _, msg := range tx.GetMsgs() { - if _, ok := msg.(*evmtypes.MsgEthereumTx); ok { + switch msg.(type) { + case *evmtypes.MsgEthereumTx: return ctx, errorsmod.Wrapf( errortypes.ErrInvalidType, "MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option", ) + + case *vestingtypes.MsgCreateVestingAccount, + *vestingtypes.MsgCreatePermanentLockedAccount, + *vestingtypes.MsgCreatePeriodicVestingAccount: + return ctx, errortypes.Wrap( + errortypes.ErrInvalidType, + "currently doesn't support creating vesting account") } } return next(ctx, tx, simulate) diff --git a/ante/vesting.go b/ante/vesting.go deleted file mode 100644 index 87861df30..000000000 --- a/ante/vesting.go +++ /dev/null @@ -1,31 +0,0 @@ -package ante - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" -) - -// RejectVestingDecorator is responsible for rejecting the vesting msg -type RejectVestingDecorator struct{} - -// NewRejectVestingDecorator returns an instance of ValidateVestingDecorator -func NewRejectVestingDecorator() RejectVestingDecorator { - return RejectVestingDecorator{} -} - -// AnteHandle checks the transaction -func (vvd RejectVestingDecorator) AnteHandle(ctx sdk.Context, - tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { - for _, msg := range tx.GetMsgs() { - switch msg.(type) { - case *vestingtypes.MsgCreateVestingAccount, - *vestingtypes.MsgCreatePermanentLockedAccount, - *vestingtypes.MsgCreatePeriodicVestingAccount: - return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, - "currently doesn't support creating vesting account") - } - } - return next(ctx, tx, simulate) -} From 065b1ded184938af27654a296ecef05f4ce51502 Mon Sep 17 00:00:00 2001 From: yuandu Date: Thu, 12 Oct 2023 10:21:08 +0800 Subject: [PATCH 2/2] chore: rm legacy upgrade plans --- app/upgrade.go | 8 - app/upgrades/v110/htlc/htlc.pb.go | 647 --------------------------- app/upgrades/v110/htlc/keys.go | 42 -- app/upgrades/v110/htlc/migrate.go | 137 ------ app/upgrades/v110/service/migrate.go | 42 -- app/upgrades/v110/upgrades.go | 34 -- app/upgrades/v120/tibc/client.go | 8 - app/upgrades/v120/tibc/client.json | 125 ------ app/upgrades/v120/upgrades.go | 123 ----- app/upgrades/v130/tibc/client.go | 8 - app/upgrades/v130/tibc/client.json | 69 --- app/upgrades/v130/upgrades.go | 36 -- app/upgrades/v140/msgs.go | 46 -- app/upgrades/v140/upgrades.go | 62 --- 14 files changed, 1387 deletions(-) delete mode 100644 app/upgrades/v110/htlc/htlc.pb.go delete mode 100644 app/upgrades/v110/htlc/keys.go delete mode 100644 app/upgrades/v110/htlc/migrate.go delete mode 100644 app/upgrades/v110/service/migrate.go delete mode 100644 app/upgrades/v110/upgrades.go delete mode 100644 app/upgrades/v120/tibc/client.go delete mode 100644 app/upgrades/v120/tibc/client.json delete mode 100644 app/upgrades/v120/upgrades.go delete mode 100644 app/upgrades/v130/tibc/client.go delete mode 100644 app/upgrades/v130/tibc/client.json delete mode 100644 app/upgrades/v130/upgrades.go delete mode 100644 app/upgrades/v140/msgs.go delete mode 100644 app/upgrades/v140/upgrades.go diff --git a/app/upgrade.go b/app/upgrade.go index d050e5bf0..3a1e52832 100644 --- a/app/upgrade.go +++ b/app/upgrade.go @@ -6,20 +6,12 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/irisnet/irishub/v2/app/upgrades" - v110 "github.com/irisnet/irishub/v2/app/upgrades/v110" - v120 "github.com/irisnet/irishub/v2/app/upgrades/v120" - v130 "github.com/irisnet/irishub/v2/app/upgrades/v130" - v140 "github.com/irisnet/irishub/v2/app/upgrades/v140" v200 "github.com/irisnet/irishub/v2/app/upgrades/v200" v210 "github.com/irisnet/irishub/v2/app/upgrades/v210" ) var ( router = upgrades.NewUpgradeRouter(). - Register(v110.Upgrade). - Register(v120.Upgrade). - Register(v130.Upgrade). - Register(v140.Upgrade). Register(v200.Upgrade). Register(v210.Upgrade) ) diff --git a/app/upgrades/v110/htlc/htlc.pb.go b/app/upgrades/v110/htlc/htlc.pb.go deleted file mode 100644 index a5df15ee3..000000000 --- a/app/upgrades/v110/htlc/htlc.pb.go +++ /dev/null @@ -1,647 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: htlc/htlc.proto - -package htlc - -import ( - fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// HTLCStatus defines the state of an OldHTLC -type HTLCStatus int32 - -const ( - // HTLC_STATE_OPEN defines an open state. - Open HTLCStatus = 0 - // HTLC_STATE_COMPLETED defines a completed state. - Completed HTLCStatus = 1 - // HTLC_STATE_EXPIRED defines an expired state. - Expired HTLCStatus = 2 - // HTLC_STATE_REFUNDED defines a refunded state. - Refunded HTLCStatus = 3 -) - -var HTLCStatus_name = map[int32]string{ - 0: "HTLC_STATE_OPEN", - 1: "HTLC_STATE_COMPLETED", - 2: "HTLC_STATE_EXPIRED", - 3: "HTLC_STATE_REFUNDED", -} - -var HTLCStatus_value = map[string]int32{ - "HTLC_STATE_OPEN": 0, - "HTLC_STATE_COMPLETED": 1, - "HTLC_STATE_EXPIRED": 2, - "HTLC_STATE_REFUNDED": 3, -} - -func (x HTLCStatus) String() string { - return proto.EnumName(HTLCStatus_name, int32(x)) -} - -// OldHTLC defines the struct of an OldHTLC -type OldHTLC struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` - ReceiverOnOtherChain string `protobuf:"bytes,3,opt,name=receiver_on_other_chain,json=receiverOnOtherChain,proto3" json:"receiver_on_other_chain,omitempty" yaml:"receiver_on_other_chain"` - Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` - Secret string `protobuf:"bytes,5,opt,name=secret,proto3" json:"secret,omitempty"` - Timestamp uint64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - ExpirationHeight uint64 `protobuf:"varint,7,opt,name=expiration_height,json=expirationHeight,proto3" json:"expiration_height,omitempty" yaml:"expiration_height"` - State HTLCStatus `protobuf:"varint,8,opt,name=state,proto3,enum=irismod.htlc.HTLCStatus" json:"state,omitempty"` -} - -func (m *OldHTLC) Reset() { *m = OldHTLC{} } -func (m *OldHTLC) String() string { return proto.CompactTextString(m) } -func (*OldHTLC) ProtoMessage() {} - -func (m *OldHTLC) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *OldHTLC) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HTLC.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *OldHTLC) XXX_Merge(src proto.Message) { - xxx_messageInfo_HTLC.Merge(m, src) -} -func (m *OldHTLC) XXX_Size() int { - return m.Size() -} -func (m *OldHTLC) XXX_DiscardUnknown() { - xxx_messageInfo_HTLC.DiscardUnknown(m) -} - -var xxx_messageInfo_HTLC proto.InternalMessageInfo - -func init() { - proto.RegisterEnum("irismod.htlc.HTLCStatus", HTLCStatus_name, HTLCStatus_value) - proto.RegisterType((*OldHTLC)(nil), "irismod.htlc.OldHTLC") -} - -func (this *OldHTLC) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*OldHTLC) - if !ok { - that2, ok := that.(OldHTLC) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Sender != that1.Sender { - return false - } - if this.To != that1.To { - return false - } - if this.ReceiverOnOtherChain != that1.ReceiverOnOtherChain { - return false - } - if len(this.Amount) != len(that1.Amount) { - return false - } - for i := range this.Amount { - if !this.Amount[i].Equal(&that1.Amount[i]) { - return false - } - } - if this.Secret != that1.Secret { - return false - } - if this.Timestamp != that1.Timestamp { - return false - } - if this.ExpirationHeight != that1.ExpirationHeight { - return false - } - if this.State != that1.State { - return false - } - return true -} -func (m *OldHTLC) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *OldHTLC) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *OldHTLC) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.State != 0 { - i = encodeVarintHtlc(dAtA, i, uint64(m.State)) - i-- - dAtA[i] = 0x40 - } - if m.ExpirationHeight != 0 { - i = encodeVarintHtlc(dAtA, i, uint64(m.ExpirationHeight)) - i-- - dAtA[i] = 0x38 - } - if m.Timestamp != 0 { - i = encodeVarintHtlc(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x30 - } - if len(m.Secret) > 0 { - i -= len(m.Secret) - copy(dAtA[i:], m.Secret) - i = encodeVarintHtlc(dAtA, i, uint64(len(m.Secret))) - i-- - dAtA[i] = 0x2a - } - if len(m.Amount) > 0 { - for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintHtlc(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.ReceiverOnOtherChain) > 0 { - i -= len(m.ReceiverOnOtherChain) - copy(dAtA[i:], m.ReceiverOnOtherChain) - i = encodeVarintHtlc(dAtA, i, uint64(len(m.ReceiverOnOtherChain))) - i-- - dAtA[i] = 0x1a - } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintHtlc(dAtA, i, uint64(len(m.To))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintHtlc(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintHtlc(dAtA []byte, offset int, v uint64) int { - offset -= sovHtlc(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *OldHTLC) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovHtlc(uint64(l)) - } - l = len(m.To) - if l > 0 { - n += 1 + l + sovHtlc(uint64(l)) - } - l = len(m.ReceiverOnOtherChain) - if l > 0 { - n += 1 + l + sovHtlc(uint64(l)) - } - if len(m.Amount) > 0 { - for _, e := range m.Amount { - l = e.Size() - n += 1 + l + sovHtlc(uint64(l)) - } - } - l = len(m.Secret) - if l > 0 { - n += 1 + l + sovHtlc(uint64(l)) - } - if m.Timestamp != 0 { - n += 1 + sovHtlc(uint64(m.Timestamp)) - } - if m.ExpirationHeight != 0 { - n += 1 + sovHtlc(uint64(m.ExpirationHeight)) - } - if m.State != 0 { - n += 1 + sovHtlc(uint64(m.State)) - } - return n -} - -func sovHtlc(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozHtlc(x uint64) (n int) { - return sovHtlc(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *OldHTLC) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: OldHTLC: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: OldHTLC: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthHtlc - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthHtlc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthHtlc - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthHtlc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.To = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReceiverOnOtherChain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthHtlc - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthHtlc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ReceiverOnOtherChain = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthHtlc - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthHtlc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Amount = append(m.Amount, types.Coin{}) - if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Secret", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthHtlc - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthHtlc - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Secret = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - m.Timestamp = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Timestamp |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ExpirationHeight", wireType) - } - m.ExpirationHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ExpirationHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) - } - m.State = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowHtlc - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.State |= HTLCStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipHtlc(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthHtlc - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipHtlc(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHtlc - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHtlc - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowHtlc - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthHtlc - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupHtlc - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthHtlc - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthHtlc = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowHtlc = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupHtlc = fmt.Errorf("proto: unexpected end of group") -) diff --git a/app/upgrades/v110/htlc/keys.go b/app/upgrades/v110/htlc/keys.go deleted file mode 100644 index 265310d77..000000000 --- a/app/upgrades/v110/htlc/keys.go +++ /dev/null @@ -1,42 +0,0 @@ -package htlc - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - // ModuleName is the name of the HTLC module - ModuleName = "htlc" - - // StoreKey is the string store representation - StoreKey string = ModuleName - - // QuerierRoute is the querier route for the HTLC module - QuerierRoute string = ModuleName - - // RouterKey is the msg router key for the HTLC module - RouterKey string = ModuleName -) - -var ( - // Keys for store prefixes - HTLCKey = []byte{0x01} // prefix for HTLC - HTLCExpiredQueueKey = []byte{0x02} // prefix for the HTLC expiration queue -) - -// GetHTLCKey returns the key for the HTLC with the specified hash lock -// VALUE: htlc/HTLC -func GetHTLCKey(hashLock []byte) []byte { - return append(HTLCKey, hashLock...) -} - -// GetHTLCExpiredQueueKey returns the key for the HTLC expiration queue by the specified height and hash lock -// VALUE: []byte{} -func GetHTLCExpiredQueueKey(expirationHeight uint64, hashLock []byte) []byte { - return append(append(HTLCExpiredQueueKey, sdk.Uint64ToBigEndian(expirationHeight)...), hashLock...) -} - -// GetHTLCExpiredQueueSubspace returns the key prefix for the HTLC expiration queue by the given height -func GetHTLCExpiredQueueSubspace(expirationHeight uint64) []byte { - return append(HTLCExpiredQueueKey, sdk.Uint64ToBigEndian(expirationHeight)...) -} diff --git a/app/upgrades/v110/htlc/migrate.go b/app/upgrades/v110/htlc/migrate.go deleted file mode 100644 index 676ef4979..000000000 --- a/app/upgrades/v110/htlc/migrate.go +++ /dev/null @@ -1,137 +0,0 @@ -package htlc - -import ( - "time" - - tmbytes "github.com/cometbft/cometbft/libs/bytes" - - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - - htlckeeper "github.com/irisnet/irismod/modules/htlc/keeper" - htlctypes "github.com/irisnet/irismod/modules/htlc/types" -) - -func Migrate( - ctx sdk.Context, - cdc codec.Codec, - k htlckeeper.Keeper, - bk bankkeeper.Keeper, - key *storetypes.KVStoreKey, -) error { - if err := k.EnsureModuleAccountPermissions(ctx); err != nil { - return err - } - - store := ctx.KVStore(key) - - // Delete expired queue - store.Delete(HTLCExpiredQueueKey) - - iterator := sdk.KVStorePrefixIterator(store, HTLCKey) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - hashLock := tmbytes.HexBytes(iterator.Key()[1:]) - - var htlc OldHTLC - cdc.MustUnmarshal(iterator.Value(), &htlc) - - sender, err := sdk.AccAddressFromBech32(htlc.Sender) - if err != nil { - return err - } - receiver, err := sdk.AccAddressFromBech32(htlc.To) - if err != nil { - return err - } - id := htlctypes.GetID(sender, receiver, htlc.Amount, hashLock) - expirationHeight := htlc.ExpirationHeight - closedBlock := uint64(0) - - var state htlctypes.HTLCState - switch htlc.State { - case Open: - state = htlctypes.Open - // Add to expired queue - k.AddHTLCToExpiredQueue(ctx, expirationHeight, id) - case Completed: - state = htlctypes.Completed - case Expired: - // Refund expired htlc - state = htlctypes.Refunded - if err := bk.SendCoinsFromModuleToAccount(ctx, htlctypes.ModuleName, sender, htlc.Amount); err != nil { - return err - } - closedBlock = uint64(ctx.BlockHeight()) - case Refunded: - state = htlctypes.Refunded - } - - // Delete origin htlc - store.Delete(GetHTLCKey(hashLock)) - - newHTLC := htlctypes.HTLC{ - Id: id.String(), - Sender: htlc.Sender, - To: htlc.To, - ReceiverOnOtherChain: htlc.ReceiverOnOtherChain, - SenderOnOtherChain: "", - Amount: htlc.Amount, - HashLock: hashLock.String(), - Secret: htlc.Secret, - Timestamp: htlc.Timestamp, - ExpirationHeight: expirationHeight, - State: state, - ClosedBlock: closedBlock, - Transfer: false, - Direction: htlctypes.None, - } - // Set new htlc - k.SetHTLC(ctx, newHTLC, id) - } - - // Set default params - return k.SetParams(ctx, PresetHTLTParams()) -} - -func PresetHTLTParams() htlctypes.Params { - return htlctypes.Params{ - AssetParams: []htlctypes.AssetParam{ - { - Denom: "htltbcbnb", - SupplyLimit: htlctypes.SupplyLimit{ - Limit: sdk.NewInt(100000000000000), - TimeLimited: false, - TimeBasedLimit: sdk.ZeroInt(), - TimePeriod: time.Duration(0), - }, - Active: true, - DeputyAddress: "iaa1junhkdhuamtdz3ah6d5mfp6w9sxmlwera7mruz", - FixedFee: sdk.NewInt(1000), - MinSwapAmount: sdk.NewInt(1001), - MaxSwapAmount: sdk.NewInt(1000000000000), - MinBlockLock: 50, - MaxBlockLock: 34560, - }, - { - Denom: "htltbcbusd", - SupplyLimit: htlctypes.SupplyLimit{ - Limit: sdk.NewInt(2000000000000000), - TimeLimited: false, - TimeBasedLimit: sdk.ZeroInt(), - TimePeriod: time.Duration(0), - }, - Active: true, - DeputyAddress: "iaa1z2sdef0ypat9lq7wsxrt7ue3uzdnzcsd34wsl4", - FixedFee: sdk.NewInt(20000), - MinSwapAmount: sdk.NewInt(20001), - MaxSwapAmount: sdk.NewInt(15000000000000), - MinBlockLock: 50, - MaxBlockLock: 34560, - }, - }, - } -} diff --git a/app/upgrades/v110/service/migrate.go b/app/upgrades/v110/service/migrate.go deleted file mode 100644 index 492967572..000000000 --- a/app/upgrades/v110/service/migrate.go +++ /dev/null @@ -1,42 +0,0 @@ -package service - -import ( - "github.com/cometbft/cometbft/crypto" - - sdk "github.com/cosmos/cosmos-sdk/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - - servicekeeper "github.com/irisnet/irismod/modules/service/keeper" - servicetypes "github.com/irisnet/irismod/modules/service/types" -) - -const ( - // TaxAccName is the root string for the service tax account address - TaxAccName = "service_tax_account" -) - -func Migrate(ctx sdk.Context, k servicekeeper.Keeper, bk bankkeeper.Keeper) error { - oldAcc := sdk.AccAddress(crypto.AddressHash([]byte(TaxAccName))) - params := servicetypes.NewParams( - k.MaxRequestTimeout(ctx), - k.MinDepositMultiple(ctx), - k.MinDeposit(ctx), - k.ServiceFeeTax(ctx), - k.SlashFraction(ctx), - k.ComplaintRetrospect(ctx), - k.ArbitrationTimeLimit(ctx), - k.TxSizeLimit(ctx), - k.BaseDenom(ctx), - false, - ) - - if err := k.SetParams(ctx, params); err != nil { - return err - } - return bk.SendCoinsFromAccountToModule( - ctx, - oldAcc, - servicetypes.FeeCollectorName, - bk.GetAllBalances(ctx, oldAcc), - ) -} diff --git a/app/upgrades/v110/upgrades.go b/app/upgrades/v110/upgrades.go deleted file mode 100644 index 77a1ff7e9..000000000 --- a/app/upgrades/v110/upgrades.go +++ /dev/null @@ -1,34 +0,0 @@ -package v110 - -import ( - store "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - "github.com/irisnet/irishub/v2/app/upgrades" - "github.com/irisnet/irishub/v2/app/upgrades/v110/htlc" - "github.com/irisnet/irishub/v2/app/upgrades/v110/service" - htlctypes "github.com/irisnet/irismod/modules/htlc/types" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: "v1.1", - UpgradeHandlerConstructor: upgradeHandlerConstructor, - StoreUpgrades: &store.StoreUpgrades{}, -} - -func upgradeHandlerConstructor(m *module.Manager, c module.Configurator, app upgrades.AppKeepers) types.UpgradeHandler { - return func(ctx sdk.Context, plan types.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // migrate htlc - if err := htlc.Migrate(ctx, app.AppCodec, app.HTLCKeeper, app.BankKeeper, app.GetKey(htlctypes.StoreKey)); err != nil { - panic(err) - } - // migrate service - if err := service.Migrate(ctx, app.ServiceKeeper, app.BankKeeper); err != nil { - panic(err) - } - - return fromVM, nil - } -} diff --git a/app/upgrades/v120/tibc/client.go b/app/upgrades/v120/tibc/client.go deleted file mode 100644 index fc95691c8..000000000 --- a/app/upgrades/v120/tibc/client.go +++ /dev/null @@ -1,8 +0,0 @@ -package tibc - -import ( - _ "embed" -) - -//go:embed client.json -var ClientData []byte diff --git a/app/upgrades/v120/tibc/client.json b/app/upgrades/v120/tibc/client.json deleted file mode 100644 index 733b920b2..000000000 --- a/app/upgrades/v120/tibc/client.json +++ /dev/null @@ -1,125 +0,0 @@ -[ - { - "chain_name": "bsnhub-mainnet", - "consensus_state": { - "@type": "/tibc.lightclients.tendermint.v1.ConsensusState", - "timestamp": "2021-11-03T11:09:19.838000955Z", - "root": { - "hash": "YXBwX2hhc2g=" - }, - "next_validators_hash": "9DA3EB65E16CC577BFDFDB69E039D074E4FF593DC1E4053151B902F8D94FF5F2" - }, - "client_state": { - "@type": "/tibc.lightclients.tendermint.v1.ClientState", - "chain_id": "BSN-net", - "trust_level": { - "numerator": "1", - "denominator": "3" - }, - "trusting_period": "8640000s", - "unbonding_period": "8640000s", - "max_clock_drift": "10s", - "latest_height": { - "revision_number": "0", - "revision_height": "4945409" - }, - "proof_specs": [ - { - "leaf_spec": { - "hash": "SHA256", - "prehash_key": "NO_HASH", - "prehash_value": "SHA256", - "length": "VAR_PROTO", - "prefix": "AA==" - }, - "inner_spec": { - "child_order": [ - 0, - 1 - ], - "child_size": 33, - "min_prefix_length": 4, - "max_prefix_length": 12, - "empty_child": null, - "hash": "SHA256" - }, - "max_depth": 0, - "min_depth": 0 - }, - { - "leaf_spec": { - "hash": "SHA256", - "prehash_key": "NO_HASH", - "prehash_value": "SHA256", - "length": "VAR_PROTO", - "prefix": "AA==" - }, - "inner_spec": { - "child_order": [ - 0, - 1 - ], - "child_size": 32, - "min_prefix_length": 1, - "max_prefix_length": 1, - "empty_child": null, - "hash": "SHA256" - }, - "max_depth": 0, - "min_depth": 0 - } - ], - "MerklePrefix": { - "key_prefix": "dGliYw==" - }, - "timeDelay": "0" - }, - "relayers": [ - "iaa1vcghfru68sxgpxcd0yfeqt50h8wunf0w574plw" - ] - }, - { - "chain_name": "eth-mainnet", - "consensus_state": { - "@type": "/tibc.lightclients.eth.v1.ConsensusState", - "timestamp": "1635938396", - "number": { - "revision_number": "0", - "revision_height": "13543580" - }, - "root": "DMSfdPZ995A7UVNVo0ppGInY5BTPtdBL7u71AG5LGqU=" - }, - "client_state": { - "@type": "/tibc.lightclients.eth.v1.ClientState", - "header": { - "parent_hash": "OG3Zhdj4dQfq1tUXMCuJJyk7QHgN2Qc58aRPdhSJF4g=", - "uncle_hash": "HcxN6N7HXXqrhbVntszUGtMSRRuUinQT8KFC/UDUk0c=", - "coinbase": "gpvYJLAWMmpAHQg7M9CSKTMzqDA=", - "root": "DMSfdPZ995A7UVNVo0ppGInY5BTPtdBL7u71AG5LGqU=", - "tx_hash": "gMEAlQBXfq+ZnU1jJCDTxpopY5pNr3HnRCNzJ9HDn14=", - "receipt_hash": "Bb065SFKYFj9vYEq4khZkmPzGBrKhQymDAAIvQclM3w=", - "bloom": "3O0c/1X/3tr3/u//h7H/N1ojN2n+HqMt87X9Gv/r9/3b2//zkP+/19v7X4T+G/m/f//qO3+naeU/cr7/p/3/9B/z1yd8/af57z+enZv2Z++P7/svS+dw+yd+///+/Xu3f4TP0d+nv9a/f35/59vf2vMPm23vbq9+7u3+X3bs9SnZ7/P87Pf/v39L2furP/333fH7Re/51Nr5p/r///oe86felR7w+emn/nVb39kxnVn+73af/+PTffH71x/3r91dTZ22vt32LE97V/m6uc8dTz/qGl8/a7087v/N9t3bfd799Dx7jL0/fbrltuqJ5zeFneu6/+v7Z85La/um8x6/tQ==", - "difficulty": "10395717367917827", - "height": { - "revision_number": "0", - "revision_height": "13543580" - }, - "gas_limit": "30000000", - "gas_used": "29124537", - "time": "1635938396", - "extra": "5LiD5b2p56We5LuZ6bG8GwMh", - "mix_digest": "Q6yN8uV4+TvlYHBqxA3LQ8oXEpQlyFLZi4ag14itxLQ=", - "nonce": "1646353019550373542", - "baseFee": "94385040994" - }, - "chain_id": "1", - "contract_address": "LOsf8dSJPLoIQJpwnFpaTPkie6k=", - "trusting_period": "8640000", - "timeDelay": "0", - "blockDelay": "7" - }, - "relayers": [ - "iaa17yh4zxe8t3cmqj2exh6g2ncr8kqvh997yuyu8l" - ] - } -] \ No newline at end of file diff --git a/app/upgrades/v120/upgrades.go b/app/upgrades/v120/upgrades.go deleted file mode 100644 index 1bd944b3c..000000000 --- a/app/upgrades/v120/upgrades.go +++ /dev/null @@ -1,123 +0,0 @@ -package v120 - -import ( - sdkmath "cosmossdk.io/math" - store "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/cosmos-sdk/x/crisis" - crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" - evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/cosmos/cosmos-sdk/x/feegrant" - feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" - "github.com/cosmos/cosmos-sdk/x/genutil" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/x/params" - paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" - - coinswaptypes "github.com/irisnet/irismod/modules/coinswap/types" - farmtypes "github.com/irisnet/irismod/modules/farm/types" - "github.com/irisnet/irismod/modules/htlc" - htlctypes "github.com/irisnet/irismod/modules/htlc/types" - nftmodule "github.com/irisnet/irismod/modules/nft/module" - nfttypes "github.com/irisnet/irismod/modules/nft/types" - "github.com/irisnet/irismod/modules/oracle" - oracletypes "github.com/irisnet/irismod/modules/oracle/types" - "github.com/irisnet/irismod/modules/random" - randomtypes "github.com/irisnet/irismod/modules/random/types" - "github.com/irisnet/irismod/modules/record" - recordtypes "github.com/irisnet/irismod/modules/record/types" - "github.com/irisnet/irismod/modules/service" - servicetypes "github.com/irisnet/irismod/modules/service/types" - "github.com/irisnet/irismod/modules/token" - tokentypes "github.com/irisnet/irismod/modules/token/types" - - tibcnfttypes "github.com/bianjieai/tibc-go/modules/tibc/apps/nft_transfer/types" - tibcclienttypes "github.com/bianjieai/tibc-go/modules/tibc/core/02-client/types" - tibchost "github.com/bianjieai/tibc-go/modules/tibc/core/24-host" - - "github.com/irisnet/irishub/v2/app/upgrades" - "github.com/irisnet/irishub/v2/app/upgrades/v120/tibc" - "github.com/irisnet/irishub/v2/modules/guardian" - guardiantypes "github.com/irisnet/irishub/v2/modules/guardian/types" - "github.com/irisnet/irishub/v2/modules/mint" - minttypes "github.com/irisnet/irishub/v2/modules/mint/types" - "github.com/irisnet/irishub/v2/types" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: "v1.2", - UpgradeHandlerConstructor: upgradeHandlerConstructor, - StoreUpgrades: &store.StoreUpgrades{ - Added: []string{ - farmtypes.StoreKey, - feegrant.StoreKey, - tibchost.StoreKey, - tibcnfttypes.StoreKey, - }, - }, -} - -func upgradeHandlerConstructor( - m *module.Manager, - c module.Configurator, - app upgrades.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // init farm params - amount := sdkmath.NewIntWithDecimal(1000, int(types.NativeToken.Scale)) - farmtypes.SetDefaultGenesisState(farmtypes.GenesisState{ - Params: farmtypes.Params{ - PoolCreationFee: sdk.NewCoin(types.NativeToken.MinUnit, amount), - MaxRewardCategories: 2, - }}, - ) - tibcclienttypes.SetDefaultGenesisState(tibcclienttypes.GenesisState{ - NativeChainName: "irishub-mainnet", - }) - - if err := upgrades.CreateClient(ctx, - app.AppCodec, - tibc.ClientData, - app.TIBCkeeper.ClientKeeper, - ); err != nil { - return nil, err - } - fromVM[authtypes.ModuleName] = 1 - fromVM[banktypes.ModuleName] = 1 - fromVM[stakingtypes.ModuleName] = 1 - fromVM[govtypes.ModuleName] = 1 - fromVM[distrtypes.ModuleName] = 1 - fromVM[slashingtypes.ModuleName] = 1 - fromVM[coinswaptypes.ModuleName] = 1 - fromVM[ibcexported.ModuleName] = 1 - fromVM[capabilitytypes.ModuleName] = capability.AppModule{}.ConsensusVersion() - fromVM[genutiltypes.ModuleName] = genutil.AppModule{}.ConsensusVersion() - fromVM[minttypes.ModuleName] = mint.AppModule{}.ConsensusVersion() - fromVM[paramstypes.ModuleName] = params.AppModule{}.ConsensusVersion() - fromVM[crisistypes.ModuleName] = crisis.AppModule{}.ConsensusVersion() - fromVM[upgradetypes.ModuleName] = crisis.AppModule{}.ConsensusVersion() - fromVM[evidencetypes.ModuleName] = evidence.AppModule{}.ConsensusVersion() - fromVM[feegrant.ModuleName] = feegrantmodule.AppModule{}.ConsensusVersion() - fromVM[guardiantypes.ModuleName] = guardian.AppModule{}.ConsensusVersion() - fromVM[tokentypes.ModuleName] = token.AppModule{}.ConsensusVersion() - fromVM[recordtypes.ModuleName] = record.AppModule{}.ConsensusVersion() - fromVM[nfttypes.ModuleName] = nftmodule.AppModule{}.ConsensusVersion() - fromVM[htlctypes.ModuleName] = htlc.AppModule{}.ConsensusVersion() - fromVM[servicetypes.ModuleName] = service.AppModule{}.ConsensusVersion() - fromVM[oracletypes.ModuleName] = oracle.AppModule{}.ConsensusVersion() - fromVM[randomtypes.ModuleName] = random.AppModule{}.ConsensusVersion() - return app.ModuleManager.RunMigrations(ctx, c, fromVM) - } -} diff --git a/app/upgrades/v130/tibc/client.go b/app/upgrades/v130/tibc/client.go deleted file mode 100644 index fc95691c8..000000000 --- a/app/upgrades/v130/tibc/client.go +++ /dev/null @@ -1,8 +0,0 @@ -package tibc - -import ( - _ "embed" -) - -//go:embed client.json -var ClientData []byte diff --git a/app/upgrades/v130/tibc/client.json b/app/upgrades/v130/tibc/client.json deleted file mode 100644 index c53daa562..000000000 --- a/app/upgrades/v130/tibc/client.json +++ /dev/null @@ -1,69 +0,0 @@ -[ - { - "chain_name": "bsc-mainnet", - "consensus_state": { - "@type": "/tibc.lightclients.bsc.v1.ConsensusState", - "timestamp": "1647611347", - "number": { - "revision_number": "0", - "revision_height": "16168200" - }, - "root": "abWdstvDFDWcCzMbZoTBxpy8JQ00Y4m8vwXIJ5UJfpA=" - }, - "client_state": { - "@type": "/tibc.lightclients.bsc.v1.ClientState", - "header": { - "parent_hash": "gK4N93vKrdBItCFYHG39MkpYQ9MbmCGD1WkRYqGZSM0=", - "uncle_hash": "HcxN6N7HXXqrhbVntszUGtMSRRuUinQT8KFC/UDUk0c=", - "coinbase": "cPZXFk5bdWibZLf9H6J18zTyjhg=", - "root": "abWdstvDFDWcCzMbZoTBxpy8JQ00Y4m8vwXIJ5UJfpA=", - "tx_hash": "xjlDWj3Ix+27DA3y1rzuiAED2vu/WbsFfddHXJ4aX4U=", - "receipt_hash": "/WBV/Qcj6Hvv6+150nb/HlVd9KHQ55cRabyGfoTmiZw=", - "bloom": "e2vb3ud+f/9qac/35S0+f/7n7D/387/z9/a0/avvL/Tf7x3dt3S+93+j/P/lb73kX9r73ffOfr///96N6//e3Xv3/T/9/PX///z22F1b/7//3Zu+/cf/lnvnLy+L+Pv7/8t97l9fndtf5+z7//nPc/z8v/+//P7ev1+3d8+v//W2fXb7/f//+r3//83fm3+9/77+/99v/f/p7tn//3v1/3/9f9/9+7Pdvb/+fzv+n/l9v7/U16N97O/me82/3/9f99v////Hnst9+Z9/3Qf73r9/P9/d3/z//f+/29/p6+///39T//3b7s/v+p7v//u+cpzHX099/v/37rdu7e/fqw==", - "difficulty": "2", - "height": { - "revision_number": "0", - "revision_height": "16168200" - }, - "gas_limit": "80000000", - "gas_used": "20949743", - "time": "1647611347", - "extra": "2IMBAQeEZ2V0aIhnbzEuMTMuNIVsaW51eAAAAMMWe98kZRdsRhr7MW68dzxh+u6FplFdqileJklc729p36aZEdnY5PO7rbibKal8bv+4pBHavGre76qE9QZ8i74tTEB7vklDjthZ/pZbFA3PGqtxqT80m7r+wVUYGbi+Hv6i/EbKdJqhaFsd7YATeF1mI8wY0hQyC2u2R1lw9lcWTlt1aJtkt/0fonXzNPKOGHK2HGAUNC2RRHDsesKXW+NFeWwreuL1ueOGzRtQpFUGltlXy0kA8DqLbI/ZPW9M6kK7s0XbxvDf21vsc5+Mza/MOfPH1uv2N8kVFnPLw2uIpvebYDWfFB35Cgx0USWxMcqv/RKqz2qBGffhFiO1pD2mOOkfZpoTD6wOFaA47t/Gi6PDXHP+1b5KB6+1voB93bB0Y5zZ+mG0dnbAZPxQ1izOL9dUTgssyUaS1KcE3r73vLYTKOLTpznv/NOpk4fQFeJg7vrHLr6h6a4yYaR1onuxAo8UC8KnyEMxiv3qCm48URu9EPRRns433CSIfhG1Xe4iY3nbg8/8aBSVcwwR/d55ukwM7wJ04xgQyd8C+Y+v3g+EH05moc3eJQAhHG2KFCGP08YBM7LybgwbiESjUtuQZz3bCi7/lEqOP2l/BGvLl89+LdDYPXITOImJINIWbksUfftitOOuAA==", - "mix_digest": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", - "nonce": "AAAAAAAAAAA=" - }, - "chain_id": "56", - "epoch": "200", - "block_inteval": "3", - "validators": [ - "JGUXbEYa+zFuvHc8YfruhaZRXao=", - "KV4mSVzvb2nfppkR2djk87utuJs=", - "Kal8bv+4pBHavGre76qE9QZ8i74=", - "LUxAe75JQ47YWf6WWxQNzxqrcak=", - "PzSbuv7BVRgZuL4e/qL8Rsp0mqE=", - "aFsd7YATeF1mI8wY0hQyC2u2R1k=", - "cPZXFk5bdWibZLf9H6J18zTyjhg=", - "crYcYBQ0LZFEcOx6wpdb40V5bCs=", - "euL1ueOGzRtQpFUGltlXy0kA8Do=", - "i2yP2T1vTOpCu7NF28bw39tb7HM=", - "n4zNr8w588fW6/Y3yRUWc8vDa4g=", - "pvebYDWfFB35Cgx0USWxMcqv/RI=", - "qs9qgRn34RYjtaQ9pjjpH2aaEw8=", - "rA4VoDju38aLo8Ncc/7VvkoHr7U=", - "voB93bB0Y5zZ+mG0dnbAZPxQ1iw=", - "zi/XVE4LLMlGktSnBN6+97y2Eyg=", - "4tOnOe/806mTh9AV4mDu+scuvqE=", - "6a4yYaR1onuxAo8UC8KnyEMxiv0=", - "6gpuPFEbvRD0UZ7ON9wkiH4RtV0=", - "7iJjeduDz/xoFJVzDBH93nm6TAw=", - "7wJ04xgQyd8C+Y+v3g+EH05moc0=" - ], - "recent_signers": [], - "contract_address": "HDR5yh3zyWLTFeeVyvB7kN/aKTY=", - "trusting_period": "8640000" - }, - "relayers": [ - "iaa1f4wqy64z33mhu5lwxqwcsmxy4kqpsntvfzdv9s" - ] - } -] \ No newline at end of file diff --git a/app/upgrades/v130/upgrades.go b/app/upgrades/v130/upgrades.go deleted file mode 100644 index f1bd2d059..000000000 --- a/app/upgrades/v130/upgrades.go +++ /dev/null @@ -1,36 +0,0 @@ -package v130 - -import ( - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - tibcmttypes "github.com/bianjieai/tibc-go/modules/tibc/apps/mt_transfer/types" - - mttypes "github.com/irisnet/irismod/modules/mt/types" - - "github.com/irisnet/irishub/v2/app/upgrades" - "github.com/irisnet/irishub/v2/app/upgrades/v130/tibc" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: "v1.3", - UpgradeHandlerConstructor: upgradeHandlerConstructor, - StoreUpgrades: &storetypes.StoreUpgrades{ - Added: []string{tibcmttypes.StoreKey, mttypes.StoreKey}, - }, -} - -func upgradeHandlerConstructor(m *module.Manager, c module.Configurator, app upgrades.AppKeepers) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - if err := upgrades.CreateClient(ctx, - app.AppCodec, - tibc.ClientData, - app.TIBCkeeper.ClientKeeper, - ); err != nil { - return nil, err - } - return app.ModuleManager.RunMigrations(ctx, c, fromVM) - } -} diff --git a/app/upgrades/v140/msgs.go b/app/upgrades/v140/msgs.go deleted file mode 100644 index b525e47cf..000000000 --- a/app/upgrades/v140/msgs.go +++ /dev/null @@ -1,46 +0,0 @@ -package v140 - -var ( - msgTypes = []string{ - "/cosmos.authz.v1beta1.MsgExec", - "/cosmos.authz.v1beta1.MsgGrant", - "/cosmos.authz.v1beta1.MsgRevoke", - "/cosmos.bank.v1beta1.MsgSend", - "/cosmos.bank.v1beta1.MsgMultiSend", - "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", - "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", - "/cosmos.distribution.v1beta1.MsgFundCommunityPool", - "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", - "/cosmos.feegrant.v1beta1.MsgGrantAllowance", - "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", - "/cosmos.gov.v1beta1.MsgVoteWeighted", - "/cosmos.gov.v1beta1.MsgSubmitProposal", - "/cosmos.gov.v1beta1.MsgDeposit", - "/cosmos.gov.v1beta1.MsgVote", - "/cosmos.gov.v1.MsgVoteWeighted", - "/cosmos.gov.v1.MsgSubmitProposal", - "/cosmos.gov.v1.MsgDeposit", - "/cosmos.gov.v1.MsgVote", - "/cosmos.staking.v1beta1.MsgEditValidator", - "/cosmos.staking.v1beta1.MsgDelegate", - "/cosmos.staking.v1beta1.MsgUndelegate", - "/cosmos.staking.v1beta1.MsgBeginRedelegate", - "/cosmos.staking.v1beta1.MsgCreateValidator", - "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", - "/ibc.applications.transfer.v1.MsgTransfer", - - "/irismod.nft.MsgIssueDenom", - "/irismod.nft.MsgTransferDenom", - "/irismod.nft.MsgMintNFT", - "/irismod.nft.MsgEditNFT", - "/irismod.nft.MsgTransferNFT", - "/irismod.nft.MsgBurnNFT", - - "/irismod.mt.MsgIssueDenom", - "/irismod.mt.MsgTransferDenom", - "/irismod.mt.MsgMintMT", - "/irismod.mt.MsgEditMT", - "/irismod.mt.MsgTransferMT", - "/irismod.mt.MsgBurnMT", - } -) diff --git a/app/upgrades/v140/upgrades.go b/app/upgrades/v140/upgrades.go deleted file mode 100644 index b5859ef15..000000000 --- a/app/upgrades/v140/upgrades.go +++ /dev/null @@ -1,62 +0,0 @@ -package v140 - -import ( - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" - icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" - - "github.com/irisnet/irishub/v2/app/upgrades" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: "v1.4", - UpgradeHandlerConstructor: upgradeHandlerConstructor, - StoreUpgrades: &storetypes.StoreUpgrades{ - Added: []string{authzkeeper.StoreKey}, - }, -} - -func upgradeHandlerConstructor( - m *module.Manager, - c module.Configurator, - app upgrades.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // version upgrade: - // nft : 1 -> 2 - // auth: 2 -> 3 - // bank: 2 -> 3 - // coinswap 3 -> 4 - // feegrant 1 -> 2 - // gov 2 -> 3 - // staking 2 -> 3 - // upgrade 2 -> 3 - - // added module: - // authz - - // ibc application: - // 27-interchain-accounts - icaModule := app.ModuleManager.Modules[icatypes.ModuleName].(ica.AppModule) - fromVM[icatypes.ModuleName] = icaModule.ConsensusVersion() - // create ICS27 Controller submodule params - controllerParams := icacontrollertypes.Params{} - // create ICS27 Host submodule params - hostParams := icahosttypes.Params{ - HostEnabled: true, - AllowMessages: msgTypes, - } - - ctx.Logger().Info("start to init interchainaccount module...") - // initialize ICS27 module - icaModule.InitModule(ctx, controllerParams, hostParams) - ctx.Logger().Info("start to run module migrations...") - return app.ModuleManager.RunMigrations(ctx, c, fromVM) - } -}