From bd351aaf17c0f471088a94c66c1ceb1a14278ba1 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Mon, 26 Sep 2022 02:30:45 -0700 Subject: [PATCH 1/9] Add Tx channels to context --- types/context.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/types/context.go b/types/context.go index 60d3ca267..4a8f57980 100644 --- a/types/context.go +++ b/types/context.go @@ -39,6 +39,8 @@ type Context struct { consParams *tmproto.ConsensusParams eventManager *EventManager priority int64 // The tx priority, only relevant in CheckTx + txCompletionChannels [][]chan interface{} + txBlockingChannels [][]chan interface{} } // Proposed rename, not done to avoid API breakage @@ -60,6 +62,8 @@ func (c Context) IsReCheckTx() bool { return c.recheckTx } func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } func (c Context) Priority() int64 { return c.priority } +func (c Context) TxCompletionChannels() [][]chan interface{} { return c.txCompletionChannels } +func (c Context) TxBlockingChannels() [][]chan interface{} { return c.txBlockingChannels } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { @@ -222,6 +226,18 @@ func (c Context) WithEventManager(em *EventManager) Context { return c } +// WithEventManager returns a Context with an updated list of completion channel +func (c Context) WithTxCompletionChannels(completionChannels [][](chan interface{})) Context { + c.txCompletionChannels = completionChannels + return c +} + +// WithEventManager returns a Context with an updated list of blocking channels for completion signals +func (c Context) WithTxBlockingChannels(blockingChannels [][](chan interface{})) Context { + c.txBlockingChannels = blockingChannels + return c +} + // TODO: remove??? func (c Context) IsZero() bool { return c.ms == nil From 2c5ca0f3593375ec7a8fc70aa0190430ea4bd690 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Mon, 26 Sep 2022 02:31:33 -0700 Subject: [PATCH 2/9] comment --- types/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/context.go b/types/context.go index 4a8f57980..8d4ca100d 100644 --- a/types/context.go +++ b/types/context.go @@ -226,13 +226,13 @@ func (c Context) WithEventManager(em *EventManager) Context { return c } -// WithEventManager returns a Context with an updated list of completion channel +// WithTxCompletionChannels returns a Context with an updated list of completion channel func (c Context) WithTxCompletionChannels(completionChannels [][](chan interface{})) Context { c.txCompletionChannels = completionChannels return c } -// WithEventManager returns a Context with an updated list of blocking channels for completion signals +// WithTxBlockingChannels returns a Context with an updated list of blocking channels for completion signals func (c Context) WithTxBlockingChannels(blockingChannels [][](chan interface{})) Context { c.txBlockingChannels = blockingChannels return c From dd77eedb30fba48023eb79f7ee20c5fea05b600a Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Mon, 26 Sep 2022 23:18:43 -0700 Subject: [PATCH 3/9] use access operations instead --- .../cosmos/accesscontrol/accesscontrol.proto | 2 +- proto/cosmos/accesscontrol/constants.proto | 2 +- proto/cosmos/accesscontrol/genesis.proto | 2 +- .../accesscontrol}/access_operation.go | 2 +- .../accesscontrol}/accesscontrol.pb.go | 26 +++++++++--------- .../accesscontrol}/constants.pb.go | 12 ++++----- .../accesscontrol}/genesis.pb.go | 14 +++++----- .../types => types/accesscontrol}/params.go | 2 +- types/context.go | 7 +++-- x/accesscontrol/keeper/genesis.go | 13 +++++---- x/accesscontrol/keeper/keeper.go | 14 +++++----- x/accesscontrol/keeper/params.go | 6 ++--- x/accesscontrol/module.go | 5 ++-- x/accesscontrol/types/genesis.go | 27 ++++++++++--------- 14 files changed, 69 insertions(+), 65 deletions(-) rename {x/accesscontrol/types => types/accesscontrol}/access_operation.go (87%) rename {x/accesscontrol/types => types/accesscontrol}/accesscontrol.pb.go (95%) rename {x/accesscontrol/types => types/accesscontrol}/constants.pb.go (89%) rename {x/accesscontrol/types => types/accesscontrol}/genesis.pb.go (96%) rename {x/accesscontrol/types => types/accesscontrol}/params.go (96%) diff --git a/proto/cosmos/accesscontrol/accesscontrol.proto b/proto/cosmos/accesscontrol/accesscontrol.proto index a54d910d3..42ed26d54 100644 --- a/proto/cosmos/accesscontrol/accesscontrol.proto +++ b/proto/cosmos/accesscontrol/accesscontrol.proto @@ -4,7 +4,7 @@ package cosmos.accesscontrol.v1beta1; import "gogoproto/gogo.proto"; import "cosmos/accesscontrol/constants.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"; +option go_package = "github.com/cosmos/cosmos-sdk/types/accesscontrol"; message AccessOperation { diff --git a/proto/cosmos/accesscontrol/constants.proto b/proto/cosmos/accesscontrol/constants.proto index 8209546c0..8c7a2e07d 100644 --- a/proto/cosmos/accesscontrol/constants.proto +++ b/proto/cosmos/accesscontrol/constants.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package cosmos.accesscontrol.v1beta1; -option go_package = "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"; +option go_package = "github.com/cosmos/cosmos-sdk/types/accesscontrol"; enum AccessType { UNKNOWN = 0; diff --git a/proto/cosmos/accesscontrol/genesis.proto b/proto/cosmos/accesscontrol/genesis.proto index 8ebf7a06b..d5a7ff916 100644 --- a/proto/cosmos/accesscontrol/genesis.proto +++ b/proto/cosmos/accesscontrol/genesis.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "cosmos/accesscontrol/constants.proto"; import "cosmos/accesscontrol/accesscontrol.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"; +option go_package = "github.com/cosmos/cosmos-sdk/types/accesscontrol"; message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; diff --git a/x/accesscontrol/types/access_operation.go b/types/accesscontrol/access_operation.go similarity index 87% rename from x/accesscontrol/types/access_operation.go rename to types/accesscontrol/access_operation.go index da43f9a2a..452faec10 100644 --- a/x/accesscontrol/types/access_operation.go +++ b/types/accesscontrol/access_operation.go @@ -1,4 +1,4 @@ -package types +package accesscontrol import ( fmt "fmt" diff --git a/x/accesscontrol/types/accesscontrol.pb.go b/types/accesscontrol/accesscontrol.pb.go similarity index 95% rename from x/accesscontrol/types/accesscontrol.pb.go rename to types/accesscontrol/accesscontrol.pb.go index 71c00858e..48d4a5362 100644 --- a/x/accesscontrol/types/accesscontrol.pb.go +++ b/types/accesscontrol/accesscontrol.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: cosmos/accesscontrol/accesscontrol.proto -package types +package accesscontrol import ( fmt "fmt" @@ -145,29 +145,29 @@ func init() { } var fileDescriptor_d636a082612ba091 = []byte{ - // 348 bytes of a gzipped FileDescriptorProto + // 347 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x6a, 0xf2, 0x40, 0x10, 0xc7, 0xb3, 0xfa, 0xf1, 0x81, 0xeb, 0xf7, 0xb5, 0xb0, 0xed, 0x21, 0x48, 0x89, 0x22, 0x3d, - 0x84, 0x82, 0x09, 0xda, 0x27, 0xa8, 0xf4, 0x52, 0x5a, 0x11, 0x82, 0xa7, 0x5e, 0xc2, 0xba, 0x4e, - 0xd3, 0xa0, 0xd9, 0x5d, 0x76, 0xd7, 0xd2, 0x3c, 0x45, 0xfb, 0x58, 0x1e, 0x3d, 0xf6, 0x24, 0x45, + 0x84, 0x82, 0x49, 0xb5, 0x4f, 0x50, 0xe9, 0xa5, 0x2d, 0x22, 0x04, 0x4f, 0xbd, 0x84, 0x75, 0x9d, + 0xa6, 0x41, 0xb3, 0xbb, 0xec, 0xae, 0x85, 0x3c, 0x45, 0xfb, 0x58, 0x1e, 0x3d, 0xf6, 0x24, 0x45, 0x5f, 0xa4, 0x98, 0x0d, 0xb6, 0x96, 0x22, 0x3d, 0xed, 0xcc, 0xfc, 0xff, 0xf3, 0x63, 0x67, 0x06, 0xfb, 0x4c, 0xe8, 0x4c, 0xe8, 0x90, 0x32, 0x06, 0x5a, 0x33, 0xc1, 0x8d, 0x12, 0xb3, 0xfd, 0x2c, - 0x90, 0x4a, 0x18, 0x41, 0xce, 0xac, 0x33, 0xd8, 0xd7, 0x9e, 0xba, 0x63, 0x30, 0xb4, 0xdb, 0x38, + 0x90, 0x4a, 0x18, 0x41, 0xce, 0xac, 0x33, 0xd8, 0xd7, 0x9e, 0xbb, 0x63, 0x30, 0xb4, 0xdb, 0x38, 0x4d, 0x44, 0x22, 0x0a, 0x63, 0xb8, 0x8d, 0x6c, 0x4f, 0xe3, 0xfc, 0x47, 0x3a, 0x13, 0x5c, 0x1b, - 0xca, 0x8d, 0xb6, 0xae, 0xf6, 0x0a, 0xe1, 0xe3, 0xab, 0xc2, 0x31, 0x94, 0xa0, 0xa8, 0x49, 0x05, - 0x27, 0x37, 0xb8, 0x6e, 0x9b, 0x62, 0x93, 0x4b, 0x70, 0x51, 0x0b, 0xf9, 0x47, 0x3d, 0x3f, 0x38, + 0xca, 0x8d, 0xb6, 0xae, 0xf6, 0x0a, 0xe1, 0xe3, 0xeb, 0xc2, 0x31, 0x94, 0xa0, 0xa8, 0x49, 0x05, + 0x27, 0xb7, 0xb8, 0x6e, 0x9b, 0x62, 0x93, 0x4b, 0x70, 0x51, 0x0b, 0xf9, 0x47, 0x3d, 0x3f, 0x38, 0xf4, 0x87, 0xc0, 0x32, 0x46, 0xb9, 0x84, 0x08, 0xd3, 0x5d, 0x4c, 0x86, 0xf8, 0xbf, 0x02, 0x2d, 0xe6, 0x8a, 0x81, 0x85, 0x55, 0x0a, 0xd8, 0xc5, 0x61, 0x58, 0x54, 0xb6, 0x14, 0xb8, 0x7f, 0xea, - 0x4b, 0x46, 0x42, 0x7c, 0x92, 0x4e, 0x80, 0x9b, 0xf4, 0x21, 0x05, 0x15, 0x1b, 0xc8, 0xe4, 0x8c, + 0x4b, 0x46, 0x42, 0x7c, 0x92, 0x4e, 0x80, 0x9b, 0xf4, 0x31, 0x05, 0x15, 0x1b, 0xc8, 0xe4, 0x8c, 0x1a, 0x70, 0xab, 0x2d, 0xe4, 0xd7, 0x22, 0xf2, 0x29, 0x8d, 0x4a, 0xa5, 0xfd, 0x82, 0xb0, 0x3b, - 0x00, 0xad, 0x69, 0x02, 0xd7, 0x20, 0x81, 0x4f, 0x80, 0xb3, 0x7c, 0x40, 0xa5, 0x4c, 0x79, 0x42, - 0x9a, 0xb8, 0x9e, 0x59, 0x2d, 0x9e, 0x42, 0x5e, 0x4c, 0x5a, 0x8b, 0x70, 0x59, 0xba, 0x85, 0x9c, + 0x00, 0xad, 0x69, 0x02, 0x37, 0x20, 0x81, 0x4f, 0x80, 0xb3, 0x7c, 0x40, 0xa5, 0x4c, 0x79, 0x42, + 0x9a, 0xb8, 0x9e, 0x59, 0x2d, 0x9e, 0x42, 0x5e, 0x4c, 0x5a, 0x8b, 0x70, 0x59, 0xba, 0x87, 0x9c, 0x44, 0xb8, 0x9c, 0x26, 0x16, 0x52, 0xbb, 0x95, 0x56, 0xd5, 0xaf, 0xf7, 0x3a, 0xbf, 0xd9, 0xc4, 0x6e, 0x9b, 0xfd, 0x3f, 0x8b, 0x55, 0xd3, 0x89, 0x6a, 0xb4, 0x2c, 0xeb, 0xfe, 0xdd, 0x62, 0xed, 0xa1, 0xe5, 0xda, 0x43, 0xef, 0x6b, 0x0f, 0xbd, 0x6e, 0x3c, 0x67, 0xb9, 0xf1, 0x9c, 0xb7, 0x8d, - 0xe7, 0xdc, 0xf7, 0x92, 0xd4, 0x3c, 0xce, 0xc7, 0x01, 0x13, 0x59, 0x58, 0x5e, 0xcf, 0x3e, 0x1d, - 0x3d, 0x99, 0x86, 0xcf, 0xdf, 0x4e, 0xb9, 0xdd, 0xa7, 0x1e, 0xff, 0x2d, 0xee, 0x78, 0xf9, 0x11, - 0x00, 0x00, 0xff, 0xff, 0x6d, 0x7a, 0x65, 0x41, 0x4d, 0x02, 0x00, 0x00, + 0xe7, 0x3c, 0x5c, 0x26, 0xa9, 0x79, 0x9a, 0x8f, 0x03, 0x26, 0xb2, 0xb0, 0xbc, 0x9e, 0x7d, 0x3a, + 0x7a, 0x32, 0x0d, 0xb7, 0xfb, 0xfb, 0x76, 0xce, 0xf1, 0xdf, 0xe2, 0x8a, 0x57, 0x1f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x08, 0x42, 0x61, 0x26, 0x4b, 0x02, 0x00, 0x00, } func (m *AccessOperation) Marshal() (dAtA []byte, err error) { diff --git a/x/accesscontrol/types/constants.pb.go b/types/accesscontrol/constants.pb.go similarity index 89% rename from x/accesscontrol/types/constants.pb.go rename to types/accesscontrol/constants.pb.go index 4be83860f..1c0073a25 100644 --- a/x/accesscontrol/types/constants.pb.go +++ b/types/accesscontrol/constants.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: cosmos/accesscontrol/constants.proto -package types +package accesscontrol import ( fmt "fmt" @@ -92,7 +92,7 @@ func init() { } var fileDescriptor_36568f7561081112 = []byte{ - // 240 bytes of a gzipped FileDescriptorProto + // 238 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x4e, 0x2d, 0x2e, 0x4e, 0xce, 0xcf, 0x2b, 0x29, 0xca, 0xcf, 0xd1, 0x4f, 0xce, 0xcf, 0x2b, 0x2e, 0x49, 0xcc, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, @@ -103,9 +103,9 @@ var fileDescriptor_36568f7561081112 = []byte{ 0x73, 0xf6, 0xf7, 0xf5, 0xf5, 0x0c, 0x11, 0x60, 0xd6, 0x32, 0xe1, 0xe2, 0x09, 0x4a, 0x2d, 0xce, 0x2f, 0x2d, 0x4a, 0x4e, 0x05, 0xeb, 0x66, 0xe7, 0x62, 0x76, 0xf4, 0x8b, 0x14, 0x60, 0x10, 0x62, 0xe3, 0x62, 0xf2, 0x0e, 0x13, 0x60, 0x04, 0x09, 0xf8, 0xa6, 0xe6, 0x42, 0x74, 0xb9, 0xa4, 0x56, - 0x80, 0xd8, 0xcc, 0x4e, 0x3e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, + 0x80, 0xd8, 0xcc, 0x4e, 0x5e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, - 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xf5, 0x1a, 0x84, 0xd2, - 0x2d, 0x4e, 0xc9, 0xd6, 0xaf, 0x40, 0xf3, 0x67, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, - 0x93, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x1e, 0xf7, 0xf6, 0x0c, 0x01, 0x00, 0x00, + 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xf5, 0x1a, 0x84, 0xd2, + 0x2d, 0x4e, 0xc9, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x45, 0xf3, 0x6b, 0x12, 0x1b, 0xd8, 0x8b, 0xc6, + 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x34, 0xbb, 0x25, 0x71, 0x0a, 0x01, 0x00, 0x00, } diff --git a/x/accesscontrol/types/genesis.pb.go b/types/accesscontrol/genesis.pb.go similarity index 96% rename from x/accesscontrol/types/genesis.pb.go rename to types/accesscontrol/genesis.pb.go index 36ab7cd0a..206af41f9 100644 --- a/x/accesscontrol/types/genesis.pb.go +++ b/types/accesscontrol/genesis.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: cosmos/accesscontrol/genesis.proto -package types +package accesscontrol import ( fmt "fmt" @@ -121,7 +121,7 @@ func init() { } var fileDescriptor_70bf81890cee44c6 = []byte{ - // 309 bytes of a gzipped FileDescriptorProto + // 307 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x4e, 0x2d, 0x2e, 0x4e, 0xce, 0xcf, 0x2b, 0x29, 0xca, 0xcf, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, @@ -136,12 +136,12 @@ var fileDescriptor_70bf81890cee44c6 = []byte{ 0x2e, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0x64, 0x86, 0xdf, 0x60, 0x5f, 0x88, 0x7e, 0x17, 0xb8, 0x76, 0x5f, 0x88, 0x6e, 0x27, 0x4d, 0x90, 0x55, 0x9f, 0xee, 0xc9, 0x2b, 0x56, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0xe1, 0xb6, 0x47, 0x29, 0x48, 0x22, 0x17, 0x87, 0x21, 0x4a, 0x7c, 0x5c, 0x6c, 0x10, - 0x97, 0x5b, 0xb1, 0xcc, 0x58, 0x20, 0xcf, 0xe0, 0xe4, 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, + 0x97, 0x5b, 0xb1, 0xcc, 0x58, 0x20, 0xcf, 0xe0, 0xe4, 0x75, 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, 0x46, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, - 0xd0, 0x50, 0x85, 0x50, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x15, 0x68, 0x41, 0x5c, 0x52, 0x59, 0x90, - 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x5b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x7e, 0x82, - 0xdb, 0x05, 0x02, 0x00, 0x00, + 0xc7, 0x72, 0x0c, 0x51, 0x06, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, + 0xd0, 0x50, 0x85, 0x50, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x25, 0x95, 0x05, 0xa9, 0x68, 0xc1, 0x9c, + 0xc4, 0x06, 0x0e, 0x59, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0xd2, 0x79, 0xf9, 0x03, + 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/accesscontrol/types/params.go b/types/accesscontrol/params.go similarity index 96% rename from x/accesscontrol/types/params.go rename to types/accesscontrol/params.go index 0566aa8b4..c3a061b91 100644 --- a/x/accesscontrol/types/params.go +++ b/types/accesscontrol/params.go @@ -1,4 +1,4 @@ -package types +package accesscontrol import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" diff --git a/types/context.go b/types/context.go index 8d4ca100d..32a43798c 100644 --- a/types/context.go +++ b/types/context.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/gaskv" stypes "github.com/cosmos/cosmos-sdk/store/types" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" ) /* @@ -39,8 +40,10 @@ type Context struct { consParams *tmproto.ConsensusParams eventManager *EventManager priority int64 // The tx priority, only relevant in CheckTx - txCompletionChannels [][]chan interface{} - txBlockingChannels [][]chan interface{} + + // Map of AccessOperatin + txBlockingChannels map[*acltypes.AccessOperation][]chan interface{} + txCompletionChannels map[*acltypes.AccessOperation][]chan interface{} } // Proposed rename, not done to avoid API breakage diff --git a/x/accesscontrol/keeper/genesis.go b/x/accesscontrol/keeper/genesis.go index 0ca282093..5207ab9dd 100644 --- a/x/accesscontrol/keeper/genesis.go +++ b/x/accesscontrol/keeper/genesis.go @@ -2,24 +2,23 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" ) -func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { +func (k Keeper) InitGenesis(ctx sdk.Context, genState acltypes.GenesisState) { k.SetParams(ctx, genState.Params) for _, resourceDepedencyMapping := range genState.GetMessageDependencyMapping() { k.SetResourceDependencyMapping(ctx, resourceDepedencyMapping) } } -func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - resourceDepedencyMappings := []types.MessageDependencyMapping{} - k.IterateResourceKeys(ctx, func(dependencyMapping types.MessageDependencyMapping) (stop bool) { +func (k Keeper) ExportGenesis(ctx sdk.Context) *acltypes.GenesisState { + resourceDepedencyMappings := []acltypes.MessageDependencyMapping{} + k.IterateResourceKeys(ctx, func(dependencyMapping acltypes.MessageDependencyMapping) (stop bool) { resourceDepedencyMappings = append(resourceDepedencyMappings, dependencyMapping) return false }) - return &types.GenesisState{ + return &acltypes.GenesisState{ Params: k.GetParams(ctx), MessageDependencyMapping: resourceDepedencyMappings, } diff --git a/x/accesscontrol/keeper/keeper.go b/x/accesscontrol/keeper/keeper.go index 97b651c3d..247e3a5a0 100644 --- a/x/accesscontrol/keeper/keeper.go +++ b/x/accesscontrol/keeper/keeper.go @@ -8,8 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -27,7 +27,7 @@ func NewKeeper( paramSpace paramtypes.Subspace, ) Keeper { if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + paramSpace = paramSpace.WithKeyTable(acltypes.ParamKeyTable()) } return Keeper{ @@ -41,17 +41,17 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -func (k Keeper) GetResourceDependencyMapping(ctx sdk.Context, messageKey string) types.MessageDependencyMapping { +func (k Keeper) GetResourceDependencyMapping(ctx sdk.Context, messageKey string) acltypes.MessageDependencyMapping { store := ctx.KVStore(k.storeKey) b := store.Get(types.GetResourceDependencyKey(messageKey)) - dependencyMapping := types.MessageDependencyMapping{} + dependencyMapping := acltypes.MessageDependencyMapping{} k.cdc.MustUnmarshal(b, &dependencyMapping) return dependencyMapping } func (k Keeper) SetResourceDependencyMapping( ctx sdk.Context, - dependencyMapping types.MessageDependencyMapping, + dependencyMapping acltypes.MessageDependencyMapping, ) error { err := types.ValidateMessageDependencyMapping(dependencyMapping) if err != nil { @@ -64,12 +64,12 @@ func (k Keeper) SetResourceDependencyMapping( return nil } -func (k Keeper) IterateResourceKeys(ctx sdk.Context, handler func(dependencyMapping types.MessageDependencyMapping) (stop bool)) { +func (k Keeper) IterateResourceKeys(ctx sdk.Context, handler func(dependencyMapping acltypes.MessageDependencyMapping) (stop bool)) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.GetResourceDependencyMappingKey()) defer iter.Close() for ; iter.Valid(); iter.Next() { - dependencyMapping := types.MessageDependencyMapping{} + dependencyMapping := acltypes.MessageDependencyMapping{} k.cdc.MustUnmarshal(iter.Value(), &dependencyMapping) if handler(dependencyMapping) { break diff --git a/x/accesscontrol/keeper/params.go b/x/accesscontrol/keeper/params.go index 3b29ee675..082c5bfc0 100644 --- a/x/accesscontrol/keeper/params.go +++ b/x/accesscontrol/keeper/params.go @@ -1,18 +1,18 @@ package keeper import ( - "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" sdk "github.com/cosmos/cosmos-sdk/types" ) // GetParams returns the total set params. -func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { +func (k Keeper) GetParams(ctx sdk.Context) (params acltypes.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) return params } // SetParams sets the total set of params. -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +func (k Keeper) SetParams(ctx sdk.Context, params acltypes.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } diff --git a/x/accesscontrol/module.go b/x/accesscontrol/module.go index 0c1d7afe3..282ace3ea 100644 --- a/x/accesscontrol/module.go +++ b/x/accesscontrol/module.go @@ -14,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper" @@ -52,7 +53,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { // ValidateGenesis performs genesis state validation for the accesscontrol module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var data types.GenesisState + var data acltypes.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { println("Validate Failed", bz) return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) @@ -118,7 +119,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis performs genesis initialization for the accesscontrol module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - var genState types.GenesisState + var genState acltypes.GenesisState cdc.MustUnmarshalJSON(data, &genState) am.keeper.InitGenesis(ctx, genState) diff --git a/x/accesscontrol/types/genesis.go b/x/accesscontrol/types/genesis.go index e45d81886..43c86bfbc 100644 --- a/x/accesscontrol/types/genesis.go +++ b/x/accesscontrol/types/genesis.go @@ -4,38 +4,39 @@ import ( "encoding/json" "github.com/cosmos/cosmos-sdk/codec" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" ) -func DefaultMessageDependencyMapping() []MessageDependencyMapping { - return []MessageDependencyMapping{ +func DefaultMessageDependencyMapping() []acltypes.MessageDependencyMapping { + return []acltypes.MessageDependencyMapping{ { MessageKey: "", - AccessOps: []AccessOperation{ - {AccessType: AccessType_UNKNOWN, ResourceType: ResourceType_ANY, IdentifierTemplate: "*"}, - {AccessType: AccessType_COMMIT, ResourceType: ResourceType_ANY, IdentifierTemplate: "*"}, + AccessOps: []acltypes.AccessOperation{ + {AccessType: acltypes.AccessType_UNKNOWN, ResourceType: acltypes.ResourceType_ANY, IdentifierTemplate: "*"}, + {AccessType: acltypes.AccessType_COMMIT, ResourceType: acltypes.ResourceType_ANY, IdentifierTemplate: "*"}, }, }, } } // NewGenesisState creates a new GenesisState object -func NewGenesisState(params Params, messageDependencyMapping []MessageDependencyMapping) *GenesisState { - return &GenesisState{ +func NewGenesisState(params acltypes.Params, messageDependencyMapping []acltypes.MessageDependencyMapping) *acltypes.GenesisState { + return &acltypes.GenesisState{ Params: params, MessageDependencyMapping: messageDependencyMapping, } } // DefaultGenesisState - default GenesisState used by columbus-2 -func DefaultGenesisState() *GenesisState { - return &GenesisState{ - Params: DefaultParams(), +func DefaultGenesisState() *acltypes.GenesisState { + return &acltypes.GenesisState{ + Params: acltypes.DefaultParams(), MessageDependencyMapping: DefaultMessageDependencyMapping(), } } // ValidateGenesis validates the oracle genesis state -func ValidateGenesis(data GenesisState) error { +func ValidateGenesis(data acltypes.GenesisState) error { for _, mapping := range data.MessageDependencyMapping { err := ValidateMessageDependencyMapping(mapping) if err != nil { @@ -47,8 +48,8 @@ func ValidateGenesis(data GenesisState) error { // GetGenesisStateFromAppState returns x/oracle GenesisState given raw application // genesis state. -func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState { - var genesisState GenesisState +func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *acltypes.GenesisState { + var genesisState acltypes.GenesisState if appState[ModuleName] != nil { cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) From fbd9edf9bf3277e55ec64aa018dfad474a681268 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Mon, 26 Sep 2022 23:31:05 -0700 Subject: [PATCH 4/9] fix with handlers --- types/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/context.go b/types/context.go index 32a43798c..d7602e9a5 100644 --- a/types/context.go +++ b/types/context.go @@ -230,13 +230,13 @@ func (c Context) WithEventManager(em *EventManager) Context { } // WithTxCompletionChannels returns a Context with an updated list of completion channel -func (c Context) WithTxCompletionChannels(completionChannels [][](chan interface{})) Context { +func (c Context) WithTxCompletionChannels(completionChannels map[*acltypes.AccessOperation][]chan interface{}) Context { c.txCompletionChannels = completionChannels return c } // WithTxBlockingChannels returns a Context with an updated list of blocking channels for completion signals -func (c Context) WithTxBlockingChannels(blockingChannels [][](chan interface{})) Context { +func (c Context) WithTxBlockingChannels(blockingChannels map[*acltypes.AccessOperation][]chan interface{}) Context { c.txBlockingChannels = blockingChannels return c } From 74da2b4130d4b023494d979c50bbf920d7184982 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Tue, 27 Sep 2022 00:11:41 -0700 Subject: [PATCH 5/9] Fixed dependency --- .../cosmos/accesscontrol/accesscontrol.proto | 1 - .../genesis.proto | 7 +-- types/context.go | 8 +-- x/accesscontrol/keeper/genesis.go | 7 ++- x/accesscontrol/keeper/keeper.go | 2 +- x/accesscontrol/keeper/params.go | 6 +- x/accesscontrol/module.go | 5 +- x/accesscontrol/types/genesis.go | 16 ++--- .../accesscontrol/types}/genesis.pb.go | 62 +++++++++---------- .../types/message_dependency_mapping.go | 5 +- .../accesscontrol/types}/params.go | 2 +- 11 files changed, 60 insertions(+), 61 deletions(-) rename proto/cosmos/{accesscontrol => accesscontrol_genesis}/genesis.proto (67%) rename {types/accesscontrol => x/accesscontrol/types}/genesis.pb.go (80%) rename {types/accesscontrol => x/accesscontrol/types}/params.go (96%) diff --git a/proto/cosmos/accesscontrol/accesscontrol.proto b/proto/cosmos/accesscontrol/accesscontrol.proto index 42ed26d54..fc2f6b19d 100644 --- a/proto/cosmos/accesscontrol/accesscontrol.proto +++ b/proto/cosmos/accesscontrol/accesscontrol.proto @@ -6,7 +6,6 @@ import "cosmos/accesscontrol/constants.proto"; option go_package = "github.com/cosmos/cosmos-sdk/types/accesscontrol"; - message AccessOperation { AccessType access_type = 1; ResourceType resource_type = 2; diff --git a/proto/cosmos/accesscontrol/genesis.proto b/proto/cosmos/accesscontrol_genesis/genesis.proto similarity index 67% rename from proto/cosmos/accesscontrol/genesis.proto rename to proto/cosmos/accesscontrol_genesis/genesis.proto index d5a7ff916..52341abdb 100644 --- a/proto/cosmos/accesscontrol/genesis.proto +++ b/proto/cosmos/accesscontrol_genesis/genesis.proto @@ -1,17 +1,16 @@ syntax = "proto3"; -package cosmos.accesscontrol.v1beta1; +package cosmos.accesscontrol_genesis.v1beta1; import "gogoproto/gogo.proto"; -import "cosmos/accesscontrol/constants.proto"; import "cosmos/accesscontrol/accesscontrol.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/types/accesscontrol"; +option go_package = "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"; message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; // mapping between every message type and its predetermined resource read/write sequence - repeated MessageDependencyMapping message_dependency_mapping = 2 [ + repeated cosmos.accesscontrol.v1beta1.MessageDependencyMapping message_dependency_mapping = 2 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"message_dependency_mapping\"" ]; diff --git a/types/context.go b/types/context.go index d7602e9a5..4f029d063 100644 --- a/types/context.go +++ b/types/context.go @@ -42,8 +42,8 @@ type Context struct { priority int64 // The tx priority, only relevant in CheckTx // Map of AccessOperatin - txBlockingChannels map[*acltypes.AccessOperation][]chan interface{} - txCompletionChannels map[*acltypes.AccessOperation][]chan interface{} + txBlockingChannels map[*acltypes.AccessOperation][]chan interface{} + txCompletionChannels map[*acltypes.AccessOperation][]chan interface{} } // Proposed rename, not done to avoid API breakage @@ -65,8 +65,8 @@ func (c Context) IsReCheckTx() bool { return c.recheckTx } func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } func (c Context) Priority() int64 { return c.priority } -func (c Context) TxCompletionChannels() [][]chan interface{} { return c.txCompletionChannels } -func (c Context) TxBlockingChannels() [][]chan interface{} { return c.txBlockingChannels } +func (c Context) TxCompletionChannels() map[*acltypes.AccessOperation][]chan interface{} { return c.txCompletionChannels } +func (c Context) TxBlockingChannels() map[*acltypes.AccessOperation][]chan interface{} { return c.txBlockingChannels } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { diff --git a/x/accesscontrol/keeper/genesis.go b/x/accesscontrol/keeper/genesis.go index 5207ab9dd..85f01ecf2 100644 --- a/x/accesscontrol/keeper/genesis.go +++ b/x/accesscontrol/keeper/genesis.go @@ -3,22 +3,23 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" + "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" ) -func (k Keeper) InitGenesis(ctx sdk.Context, genState acltypes.GenesisState) { +func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { k.SetParams(ctx, genState.Params) for _, resourceDepedencyMapping := range genState.GetMessageDependencyMapping() { k.SetResourceDependencyMapping(ctx, resourceDepedencyMapping) } } -func (k Keeper) ExportGenesis(ctx sdk.Context) *acltypes.GenesisState { +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { resourceDepedencyMappings := []acltypes.MessageDependencyMapping{} k.IterateResourceKeys(ctx, func(dependencyMapping acltypes.MessageDependencyMapping) (stop bool) { resourceDepedencyMappings = append(resourceDepedencyMappings, dependencyMapping) return false }) - return &acltypes.GenesisState{ + return &types.GenesisState{ Params: k.GetParams(ctx), MessageDependencyMapping: resourceDepedencyMappings, } diff --git a/x/accesscontrol/keeper/keeper.go b/x/accesscontrol/keeper/keeper.go index 247e3a5a0..3f9de3931 100644 --- a/x/accesscontrol/keeper/keeper.go +++ b/x/accesscontrol/keeper/keeper.go @@ -27,7 +27,7 @@ func NewKeeper( paramSpace paramtypes.Subspace, ) Keeper { if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(acltypes.ParamKeyTable()) + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) } return Keeper{ diff --git a/x/accesscontrol/keeper/params.go b/x/accesscontrol/keeper/params.go index 082c5bfc0..3b29ee675 100644 --- a/x/accesscontrol/keeper/params.go +++ b/x/accesscontrol/keeper/params.go @@ -1,18 +1,18 @@ package keeper import ( - acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" + "github.com/cosmos/cosmos-sdk/x/accesscontrol/types" sdk "github.com/cosmos/cosmos-sdk/types" ) // GetParams returns the total set params. -func (k Keeper) GetParams(ctx sdk.Context) (params acltypes.Params) { +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { k.paramSpace.GetParamSet(ctx, ¶ms) return params } // SetParams sets the total set of params. -func (k Keeper) SetParams(ctx sdk.Context, params acltypes.Params) { +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { k.paramSpace.SetParamSet(ctx, ¶ms) } diff --git a/x/accesscontrol/module.go b/x/accesscontrol/module.go index 282ace3ea..0c1d7afe3 100644 --- a/x/accesscontrol/module.go +++ b/x/accesscontrol/module.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper" @@ -53,7 +52,7 @@ func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { // ValidateGenesis performs genesis state validation for the accesscontrol module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var data acltypes.GenesisState + var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { println("Validate Failed", bz) return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) @@ -119,7 +118,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis performs genesis initialization for the accesscontrol module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - var genState acltypes.GenesisState + var genState types.GenesisState cdc.MustUnmarshalJSON(data, &genState) am.keeper.InitGenesis(ctx, genState) diff --git a/x/accesscontrol/types/genesis.go b/x/accesscontrol/types/genesis.go index 43c86bfbc..6282f5f1e 100644 --- a/x/accesscontrol/types/genesis.go +++ b/x/accesscontrol/types/genesis.go @@ -20,23 +20,23 @@ func DefaultMessageDependencyMapping() []acltypes.MessageDependencyMapping { } // NewGenesisState creates a new GenesisState object -func NewGenesisState(params acltypes.Params, messageDependencyMapping []acltypes.MessageDependencyMapping) *acltypes.GenesisState { - return &acltypes.GenesisState{ +func NewGenesisState(params Params, messageDependencyMapping []acltypes.MessageDependencyMapping) *GenesisState { + return &GenesisState{ Params: params, MessageDependencyMapping: messageDependencyMapping, } } // DefaultGenesisState - default GenesisState used by columbus-2 -func DefaultGenesisState() *acltypes.GenesisState { - return &acltypes.GenesisState{ - Params: acltypes.DefaultParams(), +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), MessageDependencyMapping: DefaultMessageDependencyMapping(), } } // ValidateGenesis validates the oracle genesis state -func ValidateGenesis(data acltypes.GenesisState) error { +func ValidateGenesis(data GenesisState) error { for _, mapping := range data.MessageDependencyMapping { err := ValidateMessageDependencyMapping(mapping) if err != nil { @@ -48,8 +48,8 @@ func ValidateGenesis(data acltypes.GenesisState) error { // GetGenesisStateFromAppState returns x/oracle GenesisState given raw application // genesis state. -func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *acltypes.GenesisState { - var genesisState acltypes.GenesisState +func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *GenesisState { + var genesisState GenesisState if appState[ModuleName] != nil { cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) diff --git a/types/accesscontrol/genesis.pb.go b/x/accesscontrol/types/genesis.pb.go similarity index 80% rename from types/accesscontrol/genesis.pb.go rename to x/accesscontrol/types/genesis.pb.go index 206af41f9..7b9d9a594 100644 --- a/types/accesscontrol/genesis.pb.go +++ b/x/accesscontrol/types/genesis.pb.go @@ -1,10 +1,11 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/accesscontrol/genesis.proto +// source: cosmos/accesscontrol_genesis/genesis.proto -package accesscontrol +package types import ( fmt "fmt" + accesscontrol "github.com/cosmos/cosmos-sdk/types/accesscontrol" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -26,14 +27,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` // mapping between every message type and its predetermined resource read/write sequence - MessageDependencyMapping []MessageDependencyMapping `protobuf:"bytes,2,rep,name=message_dependency_mapping,json=messageDependencyMapping,proto3" json:"message_dependency_mapping" yaml:"message_dependency_mapping"` + MessageDependencyMapping []accesscontrol.MessageDependencyMapping `protobuf:"bytes,2,rep,name=message_dependency_mapping,json=messageDependencyMapping,proto3" json:"message_dependency_mapping" yaml:"message_dependency_mapping"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_70bf81890cee44c6, []int{0} + return fileDescriptor_e8a7226192860e6d, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -69,7 +70,7 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetMessageDependencyMapping() []MessageDependencyMapping { +func (m *GenesisState) GetMessageDependencyMapping() []accesscontrol.MessageDependencyMapping { if m != nil { return m.MessageDependencyMapping } @@ -82,7 +83,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_70bf81890cee44c6, []int{1} + return fileDescriptor_e8a7226192860e6d, []int{1} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -112,36 +113,35 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo func init() { - proto.RegisterType((*GenesisState)(nil), "cosmos.accesscontrol.v1beta1.GenesisState") - proto.RegisterType((*Params)(nil), "cosmos.accesscontrol.v1beta1.Params") + proto.RegisterType((*GenesisState)(nil), "cosmos.accesscontrol_genesis.v1beta1.GenesisState") + proto.RegisterType((*Params)(nil), "cosmos.accesscontrol_genesis.v1beta1.Params") } func init() { - proto.RegisterFile("cosmos/accesscontrol/genesis.proto", fileDescriptor_70bf81890cee44c6) + proto.RegisterFile("cosmos/accesscontrol_genesis/genesis.proto", fileDescriptor_e8a7226192860e6d) } -var fileDescriptor_70bf81890cee44c6 = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, +var fileDescriptor_e8a7226192860e6d = []byte{ + // 299 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4a, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4c, 0x4e, 0x4e, 0x2d, 0x2e, 0x4e, 0xce, 0xcf, 0x2b, 0x29, 0xca, 0xcf, - 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, - 0x81, 0xa8, 0xd1, 0x43, 0x51, 0xa3, 0x57, 0x66, 0x98, 0x94, 0x5a, 0x92, 0x68, 0x28, 0x25, 0x92, - 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x48, 0xa9, 0x60, 0x35, 0x37, 0x39, - 0x3f, 0xaf, 0xb8, 0x24, 0x31, 0xaf, 0x04, 0x6a, 0xb2, 0x94, 0x06, 0x56, 0x55, 0xa8, 0xf6, 0x80, - 0x55, 0x2a, 0x7d, 0x61, 0xe4, 0xe2, 0x71, 0x87, 0xb8, 0x2a, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, - 0x89, 0x8b, 0xad, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, - 0x45, 0x0f, 0x9f, 0x2b, 0xf5, 0x02, 0xc0, 0x6a, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, - 0xea, 0x14, 0x9a, 0xcf, 0xc8, 0x25, 0x95, 0x9b, 0x5a, 0x5c, 0x9c, 0x98, 0x9e, 0x1a, 0x9f, 0x92, - 0x5a, 0x90, 0x9a, 0x97, 0x92, 0x9a, 0x97, 0x5c, 0x19, 0x9f, 0x9b, 0x58, 0x50, 0x90, 0x99, 0x97, - 0x2e, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0x64, 0x86, 0xdf, 0x60, 0x5f, 0x88, 0x7e, 0x17, 0xb8, - 0x76, 0x5f, 0x88, 0x6e, 0x27, 0x4d, 0x90, 0x55, 0x9f, 0xee, 0xc9, 0x2b, 0x56, 0x26, 0xe6, 0xe6, - 0x58, 0x29, 0xe1, 0xb6, 0x47, 0x29, 0x48, 0x22, 0x17, 0x87, 0x21, 0x4a, 0x7c, 0x5c, 0x6c, 0x10, - 0x97, 0x5b, 0xb1, 0xcc, 0x58, 0x20, 0xcf, 0xe0, 0xe4, 0x75, 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, 0x06, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, - 0xd0, 0x50, 0x85, 0x50, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x25, 0x95, 0x05, 0xa9, 0x68, 0xc1, 0x9c, - 0xc4, 0x06, 0x0e, 0x59, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x35, 0xd2, 0x79, 0xf9, 0x03, - 0x02, 0x00, 0x00, + 0x89, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x87, 0xd2, 0x7a, 0x05, 0x45, 0xf9, 0x25, + 0xf9, 0x42, 0x2a, 0x10, 0xb5, 0x7a, 0x58, 0xd5, 0xea, 0x95, 0x19, 0x26, 0xa5, 0x96, 0x24, 0x1a, + 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x35, 0xe8, 0x83, 0x58, 0x10, 0xbd, 0x52, 0x1a, 0xd8, + 0xec, 0x41, 0xe5, 0x41, 0x54, 0x2a, 0xfd, 0x61, 0xe4, 0xe2, 0x71, 0x87, 0x98, 0x19, 0x5c, 0x92, + 0x58, 0x92, 0x2a, 0xe4, 0xc5, 0xc5, 0x56, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x2c, 0xc1, 0xa8, 0xc0, + 0xa8, 0xc1, 0x6d, 0xa4, 0xa3, 0x47, 0x8c, 0x3b, 0xf4, 0x02, 0xc0, 0x7a, 0x9c, 0x58, 0x4e, 0xdc, + 0x93, 0x67, 0x08, 0x82, 0x9a, 0x20, 0x34, 0x9f, 0x91, 0x4b, 0x2a, 0x37, 0xb5, 0xb8, 0x38, 0x31, + 0x3d, 0x35, 0x3e, 0x25, 0xb5, 0x20, 0x35, 0x2f, 0x25, 0x35, 0x2f, 0xb9, 0x32, 0x3e, 0x37, 0xb1, + 0xa0, 0x20, 0x33, 0x2f, 0x5d, 0x82, 0x49, 0x81, 0x59, 0x83, 0xdb, 0xc8, 0x0c, 0xab, 0x05, 0x70, + 0x83, 0x7d, 0x21, 0xfa, 0x5d, 0xe0, 0xda, 0x7d, 0x21, 0xba, 0x9d, 0x34, 0x41, 0x56, 0x7d, 0xba, + 0x27, 0xaf, 0x58, 0x99, 0x98, 0x9b, 0x63, 0xa5, 0x84, 0xdb, 0x1e, 0xa5, 0x20, 0x89, 0x5c, 0x1c, + 0x86, 0x28, 0xf1, 0x71, 0xb1, 0x41, 0x5c, 0x6e, 0xc5, 0x32, 0x63, 0x81, 0x3c, 0x83, 0x93, 0xcf, + 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, + 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, + 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x43, 0x17, 0x42, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x57, + 0xa0, 0x05, 0x75, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0x8c, 0x8d, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xe9, 0xaa, 0xc5, 0x46, 0xf7, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -348,7 +348,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MessageDependencyMapping = append(m.MessageDependencyMapping, MessageDependencyMapping{}) + m.MessageDependencyMapping = append(m.MessageDependencyMapping, accesscontrol.MessageDependencyMapping{}) if err := m.MessageDependencyMapping[len(m.MessageDependencyMapping)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/accesscontrol/types/message_dependency_mapping.go b/x/accesscontrol/types/message_dependency_mapping.go index 82a1247d6..32feafd4c 100644 --- a/x/accesscontrol/types/message_dependency_mapping.go +++ b/x/accesscontrol/types/message_dependency_mapping.go @@ -4,6 +4,7 @@ import ( fmt "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + acltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol" "github.com/gogo/protobuf/proto" ) @@ -13,9 +14,9 @@ func GenerateMessageKey(msg sdk.Msg) string { return proto.MessageName(msg) } -func ValidateMessageDependencyMapping(mapping MessageDependencyMapping) error { +func ValidateMessageDependencyMapping(mapping acltypes.MessageDependencyMapping) error { lastAccessOp := mapping.AccessOps[len(mapping.AccessOps)-1] - if lastAccessOp.AccessType != AccessType_COMMIT { + if lastAccessOp.AccessType != acltypes.AccessType_COMMIT { return ErrNoCommitAccessOp } return nil diff --git a/types/accesscontrol/params.go b/x/accesscontrol/types/params.go similarity index 96% rename from types/accesscontrol/params.go rename to x/accesscontrol/types/params.go index c3a061b91..0566aa8b4 100644 --- a/types/accesscontrol/params.go +++ b/x/accesscontrol/types/params.go @@ -1,4 +1,4 @@ -package accesscontrol +package types import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" From 91a221e974c4c42ec56f1119c17d01a3ec6cc82c Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Tue, 27 Sep 2022 07:39:57 -0700 Subject: [PATCH 6/9] add message index --- types/context.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/types/context.go b/types/context.go index 4f029d063..39fdbc614 100644 --- a/types/context.go +++ b/types/context.go @@ -41,9 +41,9 @@ type Context struct { eventManager *EventManager priority int64 // The tx priority, only relevant in CheckTx - // Map of AccessOperatin - txBlockingChannels map[*acltypes.AccessOperation][]chan interface{} - txCompletionChannels map[*acltypes.AccessOperation][]chan interface{} + // Map of MessageIndex -> AccessOperation -> Channel + txBlockingChannels map[int]map[*acltypes.AccessOperation][]chan interface{} + txCompletionChannels map[int]map[*acltypes.AccessOperation][]chan interface{} } // Proposed rename, not done to avoid API breakage @@ -65,8 +65,8 @@ func (c Context) IsReCheckTx() bool { return c.recheckTx } func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } func (c Context) Priority() int64 { return c.priority } -func (c Context) TxCompletionChannels() map[*acltypes.AccessOperation][]chan interface{} { return c.txCompletionChannels } -func (c Context) TxBlockingChannels() map[*acltypes.AccessOperation][]chan interface{} { return c.txBlockingChannels } +func (c Context) TxCompletionChannels() map[int]map[*acltypes.AccessOperation][]chan interface{} { return c.txCompletionChannels } +func (c Context) TxBlockingChannels() map[int]map[*acltypes.AccessOperation][]chan interface{} { return c.txBlockingChannels } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { @@ -230,13 +230,13 @@ func (c Context) WithEventManager(em *EventManager) Context { } // WithTxCompletionChannels returns a Context with an updated list of completion channel -func (c Context) WithTxCompletionChannels(completionChannels map[*acltypes.AccessOperation][]chan interface{}) Context { +func (c Context) WithTxCompletionChannels(completionChannels map[int]map[*acltypes.AccessOperation][]chan interface{}) Context { c.txCompletionChannels = completionChannels return c } // WithTxBlockingChannels returns a Context with an updated list of blocking channels for completion signals -func (c Context) WithTxBlockingChannels(blockingChannels map[*acltypes.AccessOperation][]chan interface{}) Context { +func (c Context) WithTxBlockingChannels(blockingChannels map[int]map[*acltypes.AccessOperation][]chan interface{}) Context { c.txBlockingChannels = blockingChannels return c } From 46e0dfa21eb7d3446f4ffec5456b5c13b50b9c92 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Tue, 27 Sep 2022 07:46:02 -0700 Subject: [PATCH 7/9] alias --- types/context.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/types/context.go b/types/context.go index 39fdbc614..b69e48499 100644 --- a/types/context.go +++ b/types/context.go @@ -41,11 +41,13 @@ type Context struct { eventManager *EventManager priority int64 // The tx priority, only relevant in CheckTx - // Map of MessageIndex -> AccessOperation -> Channel - txBlockingChannels map[int]map[*acltypes.AccessOperation][]chan interface{} - txCompletionChannels map[int]map[*acltypes.AccessOperation][]chan interface{} + txBlockingChannels MessageAccessOpsChannelMapping + txCompletionChannels MessageAccessOpsChannelMapping } +// Alias for Map of MessageIndex -> AccessOperation -> Channel +type MessageAccessOpsChannelMapping = map[int]map[*acltypes.AccessOperation][]chan interface{} + // Proposed rename, not done to avoid API breakage type Request = Context @@ -230,13 +232,13 @@ func (c Context) WithEventManager(em *EventManager) Context { } // WithTxCompletionChannels returns a Context with an updated list of completion channel -func (c Context) WithTxCompletionChannels(completionChannels map[int]map[*acltypes.AccessOperation][]chan interface{}) Context { +func (c Context) WithTxCompletionChannels(completionChannels MessageAccessOpsChannelMapping) Context { c.txCompletionChannels = completionChannels return c } // WithTxBlockingChannels returns a Context with an updated list of blocking channels for completion signals -func (c Context) WithTxBlockingChannels(blockingChannels map[int]map[*acltypes.AccessOperation][]chan interface{}) Context { +func (c Context) WithTxBlockingChannels(blockingChannels MessageAccessOpsChannelMapping) Context { c.txBlockingChannels = blockingChannels return c } From 3d4b45b834952f27be619dfc03840cc4cbfe9742 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Tue, 27 Sep 2022 07:46:53 -0700 Subject: [PATCH 8/9] alias --- types/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/context.go b/types/context.go index b69e48499..7137f30c0 100644 --- a/types/context.go +++ b/types/context.go @@ -41,8 +41,8 @@ type Context struct { eventManager *EventManager priority int64 // The tx priority, only relevant in CheckTx - txBlockingChannels MessageAccessOpsChannelMapping - txCompletionChannels MessageAccessOpsChannelMapping + txBlockingChannels MessageAccessOpsChannelMapping + txCompletionChannels MessageAccessOpsChannelMapping } // Alias for Map of MessageIndex -> AccessOperation -> Channel From 209c2ea735f40249878e257d75c87c057bae62f3 Mon Sep 17 00:00:00 2001 From: Brandon Weng Date: Tue, 27 Sep 2022 11:32:24 -0700 Subject: [PATCH 9/9] msg index --- baseapp/baseapp.go | 1 + types/context.go | 17 ++++++++++++++--- types/tx_msg.go | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index d4ccac089..6c3e7d59a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -803,6 +803,7 @@ func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*s ) if handler := app.msgServiceRouter.Handler(msg); handler != nil { + ctx = ctx.WithMessageIndex(i) // ADR 031 request type routing msgResult, err = handler(ctx, msg) eventMsgName = sdk.MsgTypeURL(msg) diff --git a/types/context.go b/types/context.go index 7137f30c0..fa3184b81 100644 --- a/types/context.go +++ b/types/context.go @@ -43,10 +43,14 @@ type Context struct { txBlockingChannels MessageAccessOpsChannelMapping txCompletionChannels MessageAccessOpsChannelMapping + messageIndex int // Used to track current message being processed } // Alias for Map of MessageIndex -> AccessOperation -> Channel -type MessageAccessOpsChannelMapping = map[int]map[*acltypes.AccessOperation][]chan interface{} +type MessageAccessOpsChannelMapping = map[int]AccessOpsChannelMapping + +// Alias for Map of AccessOperation -> Channel +type AccessOpsChannelMapping = map[*acltypes.AccessOperation][]chan interface{} // Proposed rename, not done to avoid API breakage type Request = Context @@ -67,8 +71,9 @@ func (c Context) IsReCheckTx() bool { return c.recheckTx } func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } func (c Context) Priority() int64 { return c.priority } -func (c Context) TxCompletionChannels() map[int]map[*acltypes.AccessOperation][]chan interface{} { return c.txCompletionChannels } -func (c Context) TxBlockingChannels() map[int]map[*acltypes.AccessOperation][]chan interface{} { return c.txBlockingChannels } +func (c Context) TxCompletionChannels() MessageAccessOpsChannelMapping { return c.txCompletionChannels } +func (c Context) TxBlockingChannels() MessageAccessOpsChannelMapping { return c.txBlockingChannels } +func (c Context) MessageIndex() int { return c.messageIndex } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { @@ -243,6 +248,12 @@ func (c Context) WithTxBlockingChannels(blockingChannels MessageAccessOpsChannel return c } +// WithMessageIndex returns a Context with the current message index that's being processed +func (c Context) WithMessageIndex(messageIndex int) Context { + c.messageIndex = messageIndex + return c +} + // TODO: remove??? func (c Context) IsZero() bool { return c.ms == nil diff --git a/types/tx_msg.go b/types/tx_msg.go index 42d01fdc5..b88d4e735 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -78,4 +78,4 @@ type TxEncoder func(tx Tx) ([]byte, error) // MsgTypeURL returns the TypeURL of a `sdk.Msg`. func MsgTypeURL(msg Msg) string { return "/" + proto.MessageName(msg) -} +} \ No newline at end of file