diff --git a/event/event.pb.go b/event/event.pb.go index 0611fe17e..3aff698de 100644 --- a/event/event.pb.go +++ b/event/event.pb.go @@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Event represents a single event run in engine. type Event struct { // Hash is a unique hash to identify event. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required,hash"` // instanceHash is hash of instance that can proceed an execution. InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required,hash"` // key is the key of the event. @@ -69,25 +69,25 @@ func init() { func init() { proto.RegisterFile("event.proto", fileDescriptor_2d17a9d3f0ddf27e) } var fileDescriptor_2d17a9d3f0ddf27e = []byte{ - // 320 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0x41, 0x4b, 0xfb, 0x30, - 0x18, 0xc6, 0xd7, 0x6d, 0xff, 0x3f, 0x9a, 0xcd, 0x83, 0x05, 0xa1, 0x4c, 0xb0, 0x25, 0x07, 0x1d, - 0xb8, 0x25, 0xb2, 0x79, 0x1a, 0x82, 0x50, 0x10, 0x3c, 0x77, 0x37, 0xc1, 0x43, 0xd6, 0xbe, 0x6b, - 0x83, 0x36, 0xa9, 0x4d, 0x3a, 0xd8, 0xd1, 0x6f, 0xb7, 0xcf, 0xe0, 0xa1, 0xa0, 0x1f, 0xa1, 0x9f, - 0x40, 0x92, 0xa9, 0x4c, 0x10, 0x04, 0x6f, 0x79, 0x92, 0xe7, 0xf9, 0xbd, 0xe4, 0x7d, 0x50, 0x0f, - 0x56, 0x20, 0x34, 0x29, 0x4a, 0xa9, 0xa5, 0x8b, 0x72, 0x50, 0x29, 0xd1, 0xeb, 0x02, 0xd4, 0x00, - 0xa7, 0x32, 0x95, 0xd4, 0xde, 0x2f, 0xaa, 0x25, 0x35, 0xca, 0x0a, 0x7b, 0xda, 0xfa, 0x07, 0xc7, - 0x5f, 0xcf, 0x36, 0x43, 0x95, 0x2e, 0xab, 0xf8, 0x03, 0x86, 0xdf, 0xda, 0xe8, 0xdf, 0x8d, 0x81, - 0xbb, 0x73, 0xd4, 0xcd, 0x98, 0xca, 0x3c, 0x27, 0x70, 0x86, 0xfd, 0xf0, 0x7a, 0x53, 0xfb, 0xad, - 0x97, 0xda, 0x3f, 0x4f, 0xb9, 0xce, 0xaa, 0x05, 0x89, 0x65, 0x4e, 0xcd, 0xdc, 0xf1, 0x52, 0x56, - 0x22, 0x61, 0x9a, 0x4b, 0x41, 0x41, 0xa4, 0x5c, 0x00, 0x35, 0x29, 0x72, 0xcb, 0x54, 0xd6, 0xd4, - 0xfe, 0x9e, 0x11, 0x33, 0x3c, 0xc6, 0x91, 0x85, 0xb9, 0xcf, 0x0e, 0xea, 0x73, 0xa1, 0x34, 0x13, - 0x31, 0x18, 0x8b, 0xd7, 0xb6, 0xf4, 0xfb, 0xbf, 0xd1, 0x4f, 0xb7, 0x74, 0xc1, 0x72, 0x98, 0x4d, - 0x70, 0xb0, 0x62, 0x8f, 0x3c, 0x61, 0x1a, 0x66, 0xb8, 0x84, 0xa7, 0x8a, 0x97, 0x90, 0x8c, 0x8c, - 0x01, 0x47, 0xdf, 0x46, 0xba, 0x21, 0xea, 0x3c, 0xc0, 0xda, 0xeb, 0x04, 0xce, 0x70, 0x3f, 0xbc, - 0x68, 0x6a, 0x7f, 0xb4, 0x83, 0x99, 0xfe, 0x88, 0x29, 0x4a, 0x2e, 0x34, 0x53, 0x31, 0xe7, 0x38, - 0x32, 0x61, 0xf7, 0x0a, 0x75, 0x13, 0xa6, 0x99, 0xd7, 0x0d, 0x9c, 0x61, 0x6f, 0x72, 0x44, 0x6c, - 0x05, 0x9f, 0x7b, 0x25, 0x73, 0xbb, 0xd1, 0xf0, 0xb0, 0xa9, 0xfd, 0x83, 0x1d, 0xf6, 0x25, 0x8e, - 0x6c, 0x2a, 0x1c, 0x6f, 0x5e, 0x4f, 0x5a, 0x77, 0x67, 0xbf, 0x7f, 0xd6, 0xd6, 0xbc, 0xf8, 0x6f, - 0xc1, 0xd3, 0xf7, 0x00, 0x00, 0x00, 0xff, 0xff, 0x32, 0x9b, 0xad, 0xff, 0xf6, 0x01, 0x00, 0x00, + // 319 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0x41, 0x4b, 0xc3, 0x30, + 0x14, 0xc7, 0xd7, 0x6d, 0x0a, 0x66, 0xf3, 0x60, 0x41, 0x28, 0x13, 0x6c, 0xcd, 0x41, 0x07, 0x6e, + 0x89, 0x6c, 0x9e, 0x86, 0xa7, 0x82, 0xe0, 0x79, 0x5e, 0x44, 0xf0, 0x90, 0xb5, 0x6f, 0x6d, 0x70, + 0x4d, 0x6a, 0x93, 0x0e, 0x76, 0xf4, 0xdb, 0xed, 0x33, 0x78, 0x28, 0xf8, 0x15, 0x7a, 0xf5, 0x22, + 0xc9, 0x54, 0x26, 0x88, 0x82, 0xb7, 0xbc, 0xbc, 0xfc, 0x7f, 0x3f, 0xf2, 0x1e, 0xea, 0xc0, 0x12, + 0x84, 0x26, 0x79, 0x21, 0xb5, 0x74, 0x51, 0x06, 0x2a, 0x21, 0x7a, 0x95, 0x83, 0xea, 0xe1, 0x44, + 0x26, 0x92, 0xda, 0xfb, 0x59, 0x39, 0xa7, 0xa6, 0xb2, 0x85, 0x3d, 0x6d, 0xde, 0xf7, 0x8e, 0xbe, + 0xda, 0x36, 0x43, 0x95, 0x2e, 0xca, 0xe8, 0x03, 0x86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, 0xfb, 0x9f, 0xed, 0x5a, + 0xf0, 0xf8, 0x3d, 0x00, 0x00, 0xff, 0xff, 0x53, 0x5c, 0x1b, 0x1f, 0x0f, 0x02, 0x00, 0x00, } diff --git a/execution/execution.go b/execution/execution.go index 64f0c6fe6..6b9716f07 100644 --- a/execution/execution.go +++ b/execution/execution.go @@ -2,13 +2,14 @@ package execution import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/types" "github.com/tendermint/tendermint/crypto" ) // New returns a new execution. -func New(processHash, instanceHash, parentHash, eventHash hash.Hash, nodeKey, taskKey, price string, inputs *types.Struct, tags []string, executorHash hash.Hash) *Execution { +func New(processHash, instanceHash, parentHash, eventHash hash.Hash, nodeKey, taskKey, price string, inputs *types.Struct, tags []string, executorHash hash.Hash) (*Execution, error) { exec := &Execution{ ProcessHash: processHash, EventHash: eventHash, @@ -24,7 +25,7 @@ func New(processHash, instanceHash, parentHash, eventHash hash.Hash, nodeKey, ta } exec.Hash = hash.Dump(exec) exec.Address = sdk.AccAddress(crypto.AddressHash(exec.Hash)) - return exec + return exec, xvalidator.Struct(exec) } // Execute changes executions status to in progres. diff --git a/execution/execution.pb.go b/execution/execution.pb.go index 2e3a4d285..c1840d527 100644 --- a/execution/execution.pb.go +++ b/execution/execution.pb.go @@ -71,19 +71,19 @@ func (Status) EnumDescriptor() ([]byte, []int) { // Execution represents a single execution run in engine. type Execution struct { // Hash is a unique hash to identify execution. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required,hash"` // parentHash is the unique hash of parent execution. // if execution is triggered by another one, // dependency execution considered as the parent. - ParentHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=parentHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"parentHash" hash:"name:2"` + ParentHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=parentHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"parentHash" hash:"name:2" validate:"required_without=EventHash,omitempty,hash"` // eventHash is unique event hash. - EventHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=eventHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"eventHash" hash:"name:3"` + EventHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=eventHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"eventHash" hash:"name:3" validate:"required_without=ParentHash,omitempty,hash"` // Status is the current status of execution. - Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=mesg.types.Status" json:"status,omitempty" hash:"-"` + Status Status `protobuf:"varint,4,opt,name=status,proto3,enum=mesg.types.Status" json:"status,omitempty" hash:"-" validate:"required"` // instanceHash is hash of the instance that can proceed an execution - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:5"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,5,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:5" validate:"required,hash"` // taskKey is the key of the task of this execution. - TaskKey string `protobuf:"bytes,6,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:6"` + TaskKey string `protobuf:"bytes,6,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:6" validate:"required,printascii"` // inputs data of the execution. Inputs *types.Struct `protobuf:"bytes,7,opt,name=inputs,proto3" json:"inputs,omitempty" hash:"name:7"` // outputs are the returned data of successful execution. @@ -93,19 +93,19 @@ type Execution struct { // tags are optionally associated with execution by the user. Tags []string `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags,omitempty" hash:"name:10" validate:"dive,printascii"` // processHash is the unique hash of the process associated to this execution. - ProcessHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,11,opt,name=processHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"processHash" hash:"name:11"` + ProcessHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,11,opt,name=processHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"processHash" hash:"name:11" validate:"omitempty,hash"` // node key of the process. NodeKey string `protobuf:"bytes,12,opt,name=nodeKey,proto3" json:"nodeKey,omitempty" hash:"name:12"` // runner that should execute this execution. - ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,13,opt,name=executorHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash" hash:"name:13"` + ExecutorHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,13,opt,name=executorHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"executorHash" hash:"name:13" validate:"required,hash"` // price of running the exeuction. - Price string `protobuf:"bytes,14,opt,name=price,proto3" json:"price,omitempty" hash:"name:14" validate:"coins"` + Price string `protobuf:"bytes,14,opt,name=price,proto3" json:"price,omitempty" hash:"name:14" validate:"required,coinsPositiveZero"` // blockHeight where the execution was included into blockchain. BlockHeight int64 `protobuf:"varint,15,opt,name=blockHeight,proto3" json:"blockHeight,omitempty" hash:"-"` // list of emitters of this execution. Emitters []*Execution_Emitter `protobuf:"bytes,16,rep,name=emitters,proto3" json:"emitters,omitempty" hash:"-" validate:"dive"` // The address of the execution. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,17,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"accaddress"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,17,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -138,9 +138,9 @@ var xxx_messageInfo_Execution proto.InternalMessageInfo // Emitter is a runner that proposed an execution. type Execution_Emitter struct { // Emitter's hash. - RunnerHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=runnerHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"runnerHash" hash:"-" validate:"hash"` + RunnerHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=runnerHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"runnerHash" hash:"-" validate:"required,hash"` // Block height when this emitter proposed the execution. - BlockHeight int64 `protobuf:"varint,2,opt,name=blockHeight,proto3" json:"blockHeight,omitempty" hash:"-"` + BlockHeight int64 `protobuf:"varint,2,opt,name=blockHeight,proto3" json:"blockHeight,omitempty" hash:"-" validate:"required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -179,53 +179,60 @@ func init() { func init() { proto.RegisterFile("execution.proto", fileDescriptor_776e2c5022e94aef) } var fileDescriptor_776e2c5022e94aef = []byte{ - // 728 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x6e, 0xd3, 0x48, - 0x14, 0xae, 0x9b, 0x34, 0x3f, 0x27, 0x69, 0x9a, 0x8e, 0xb4, 0x92, 0xd5, 0xdd, 0xad, 0xad, 0xd9, - 0x9b, 0xec, 0xb6, 0x71, 0xb6, 0x29, 0xe5, 0xa7, 0x12, 0x82, 0x06, 0x8a, 0x8a, 0x90, 0xa0, 0x72, - 0x84, 0x90, 0xb8, 0x73, 0xec, 0xa9, 0x33, 0x4a, 0x32, 0x63, 0x79, 0xc6, 0x85, 0xbe, 0x11, 0xe2, - 0x3d, 0x90, 0xfa, 0x0c, 0x5c, 0x58, 0x82, 0x47, 0xc8, 0x25, 0x57, 0xc8, 0xe3, 0x38, 0x75, 0x42, - 0x05, 0xa8, 0xea, 0x55, 0x32, 0x3e, 0xe7, 0xfb, 0xce, 0x77, 0xbe, 0xe3, 0x39, 0x86, 0x0d, 0xf2, - 0x9e, 0xb8, 0x91, 0xa4, 0x9c, 0x59, 0x41, 0xc8, 0x25, 0x47, 0x30, 0x21, 0xc2, 0xb7, 0xe4, 0x45, - 0x40, 0xc4, 0x16, 0xf6, 0xb9, 0xcf, 0x3b, 0xea, 0xf9, 0x20, 0x3a, 0xeb, 0x24, 0x27, 0x75, 0x50, - 0xff, 0xd2, 0xfc, 0xad, 0x3f, 0xe7, 0x61, 0x85, 0xe9, 0x08, 0x19, 0x46, 0xae, 0x4c, 0x83, 0xf8, - 0x53, 0x0d, 0xaa, 0xc7, 0x59, 0x01, 0xd4, 0x87, 0xe2, 0xd0, 0x11, 0x43, 0x5d, 0x33, 0xb5, 0x56, - 0xbd, 0xf7, 0xe8, 0x32, 0x36, 0x56, 0x3e, 0xc7, 0xc6, 0x8e, 0x4f, 0xe5, 0x30, 0x1a, 0x58, 0x2e, - 0x9f, 0x74, 0x92, 0xda, 0xed, 0x33, 0x1e, 0x31, 0xcf, 0x49, 0x10, 0x1d, 0xc2, 0x7c, 0xca, 0x48, - 0x27, 0x41, 0x59, 0x27, 0x8e, 0x18, 0x4e, 0x63, 0xa3, 0x92, 0x1c, 0x0e, 0x71, 0x1b, 0xdb, 0x8a, - 0x0c, 0x79, 0x00, 0x81, 0x13, 0x12, 0x26, 0x93, 0xb8, 0xbe, 0xaa, 0xa8, 0x9f, 0xde, 0x8c, 0x7a, - 0x3d, 0xa5, 0x66, 0xce, 0x84, 0x1c, 0x76, 0xb1, 0x9d, 0x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 0xf5, 0x51, 0x83, 0xf2, 0x4c, 0x22, 0xe2, 0x00, - 0x61, 0xc4, 0x18, 0x49, 0xe7, 0x94, 0xae, 0xc7, 0x57, 0x37, 0x9b, 0xd3, 0x75, 0x9d, 0x26, 0x8f, - 0xb0, 0x9d, 0x2b, 0xb1, 0x6c, 0xfa, 0xea, 0x2f, 0x4c, 0xff, 0xef, 0x25, 0x94, 0xd2, 0x05, 0x84, - 0x6a, 0x50, 0x7e, 0xcd, 0x46, 0x8c, 0xbf, 0x63, 0xcd, 0x15, 0x54, 0x87, 0xca, 0x69, 0xc8, 0x03, - 0x2e, 0x88, 0xd7, 0xd4, 0x50, 0x03, 0xe0, 0x39, 0x3b, 0x0d, 0xb9, 0x9f, 0xf4, 0xd7, 0x5c, 0x45, - 0xeb, 0x50, 0x7d, 0xc2, 0x27, 0xc1, 0x98, 0x48, 0xe2, 0x35, 0x0b, 0x08, 0xa0, 0xf4, 0xcc, 0xa1, - 0x63, 0xe2, 0x35, 0x8b, 0xbd, 0x83, 0xcb, 0x2f, 0xdb, 0x2b, 0x1f, 0xbe, 0x6e, 0x6b, 0x6f, 0x7f, - 0xa3, 0xbd, 0xf9, 0x17, 0x6a, 0x50, 0x52, 0xf7, 0x7e, 0xff, 0x7b, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xe0, 0x8a, 0x48, 0x17, 0xb5, 0x06, 0x00, 0x00, + // 835 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x8e, 0xdb, 0x44, + 0x14, 0x5e, 0x6f, 0x76, 0x93, 0xcd, 0x49, 0x36, 0x4d, 0x47, 0x42, 0xb2, 0x96, 0x52, 0x1b, 0x5f, + 0x40, 0x80, 0x8d, 0xd3, 0x66, 0x5b, 0x40, 0x2b, 0x55, 0x62, 0x5d, 0x2d, 0x2a, 0x3f, 0xaa, 0x56, + 0xae, 0x10, 0xa8, 0x02, 0x2a, 0xaf, 0x3d, 0x75, 0x46, 0x1b, 0xcf, 0x98, 0x99, 0x71, 0xda, 0xe5, + 0x0e, 0xae, 0x78, 0x04, 0x78, 0x03, 0xde, 0x84, 0x3e, 0x03, 0x17, 0x96, 0xe0, 0x11, 0x7c, 0xc9, + 0x15, 0xf2, 0x38, 0xce, 0x4e, 0x96, 0x28, 0xa0, 0x48, 0x5c, 0x25, 0xe3, 0x39, 0xe7, 0xfb, 0xbe, + 0x33, 0xdf, 0x99, 0x33, 0x70, 0x03, 0xbf, 0xc4, 0x61, 0x26, 0x09, 0xa3, 0x6e, 0xca, 0x99, 0x64, + 0x08, 0x12, 0x2c, 0x62, 0x57, 0x5e, 0xa6, 0x58, 0x1c, 0x38, 0x31, 0x8b, 0xd9, 0x48, 0x7d, 0x3f, + 0xcf, 0x9e, 0x8f, 0xca, 0x95, 0x5a, 0xa8, 0x7f, 0x55, 0xfc, 0xc1, 0xeb, 0x8b, 0x6d, 0x95, 0x33, + 0x12, 0x92, 0x67, 0xa1, 0xac, 0x36, 0x9d, 0x9f, 0x7a, 0xd0, 0x3e, 0xad, 0x09, 0xd0, 0x14, 0x76, + 0x26, 0x81, 0x98, 0x98, 0x86, 0x6d, 0x0c, 0xba, 0xde, 0x57, 0xaf, 0x72, 0x6b, 0xeb, 0xf7, 0xdc, + 0x7a, 0x2f, 0x26, 0x72, 0x92, 0x9d, 0xbb, 0x21, 0x4b, 0x46, 0x25, 0xf7, 0xf0, 0x39, 0xcb, 0x68, + 0x14, 0x94, 0x19, 0x23, 0x4c, 0x63, 0x42, 0xf1, 0xa8, 0xcc, 0x72, 0x1f, 0x05, 0x62, 0x52, 0xe4, + 0xd6, 0x9b, 0xe5, 0xe2, 0xd8, 0x19, 0x3a, 0xf6, 0x2c, 0x98, 0x92, 0x28, 0x90, 0xf8, 0xd8, 0xe1, + 0xf8, 0xbb, 0x8c, 0x70, 0x1c, 0x1d, 0x96, 0x7b, 0x8e, 0xaf, 0x58, 0x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 0x53, 0x2c, 0x71, 0xd4, 0x6f, 0x20, 0x80, 0xe6, 0xc7, 0x01, 0x99, 0xe2, 0xa8, 0xbf, 0xe3, 0xdd, + 0x7f, 0xf5, 0xc7, 0xed, 0xad, 0x5f, 0xff, 0xbc, 0x6d, 0x3c, 0xfd, 0x0f, 0xb5, 0x2f, 0x1e, 0xf9, + 0xf3, 0xa6, 0x9a, 0x33, 0x47, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x19, 0xe0, 0xba, 0x5c, 0xf8, + 0x07, 0x00, 0x00, } func (this *Execution) Equal(that interface{}) bool { diff --git a/execution/execution_test.go b/execution/execution_test.go index f32b2b598..a0d4e9c76 100644 --- a/execution/execution_test.go +++ b/execution/execution_test.go @@ -19,7 +19,7 @@ func TestNewFromService(t *testing.T) { tags = []string{"tag"} ) - execution := New(nil, hash, parentHash, eventHash, "", taskKey, "", nil, tags, nil) + execution, _ := New(nil, hash, parentHash, eventHash, "", taskKey, "", nil, tags, nil) require.NotNil(t, execution) require.Equal(t, hash, execution.InstanceHash) require.Equal(t, parentHash, execution.ParentHash) @@ -31,7 +31,7 @@ func TestNewFromService(t *testing.T) { } func TestExecute(t *testing.T) { - e := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) + e, _ := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) require.NoError(t, e.Execute()) require.Equal(t, Status_InProgress, e.Status) require.Error(t, e.Execute()) @@ -39,7 +39,7 @@ func TestExecute(t *testing.T) { func TestComplete(t *testing.T) { var output types.Struct - e := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) + e, _ := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) e.Execute() require.NoError(t, e.Complete(&output)) require.Equal(t, Status_Completed, e.Status) @@ -49,7 +49,7 @@ func TestComplete(t *testing.T) { func TestFailed(t *testing.T) { err := errors.New("test") - e := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) + e, _ := New(nil, nil, nil, nil, "", "", "", nil, nil, nil) e.Execute() require.NoError(t, e.Fail(err)) require.Equal(t, Status_Failed, e.Status) @@ -61,7 +61,7 @@ func TestExecutionHash(t *testing.T) { ids := make(map[string]bool) f := func(instanceHash, parentHash, eventID []byte, taskKey string, tags []string) bool { - e := New(nil, instanceHash, parentHash, eventID, "", taskKey, "", nil, tags, nil) + e, _ := New(nil, instanceHash, parentHash, eventID, "", taskKey, "", nil, tags, nil) if ids[string(e.Hash)] { return false } diff --git a/instance/instance.go b/instance/instance.go index 4a167f261..d07bcaff2 100644 --- a/instance/instance.go +++ b/instance/instance.go @@ -1,12 +1,16 @@ package instance -import "github.com/mesg-foundation/engine/hash" +import ( + "github.com/mesg-foundation/engine/ext/xvalidator" + "github.com/mesg-foundation/engine/hash" +) -func New(serviceHash hash.Hash, envHash hash.Hash) *Instance { +// New returns a new Instance and validate it. +func New(serviceHash hash.Hash, envHash hash.Hash) (*Instance, error) { inst := &Instance{ ServiceHash: serviceHash, EnvHash: envHash, } inst.Hash = hash.Dump(inst) - return inst + return inst, xvalidator.Struct(inst) } diff --git a/instance/instance.pb.go b/instance/instance.pb.go index c32cd0924..0b659d5d2 100644 --- a/instance/instance.pb.go +++ b/instance/instance.pb.go @@ -25,9 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Instance represents service's instance. type Instance struct { - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash"` - ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash" hash:"name:2"` - EnvHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=envHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"envHash" hash:"name:3"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required,hash"` + ServiceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=serviceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"serviceHash" hash:"name:2" validate:"required,hash"` + EnvHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=envHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"envHash" hash:"name:3" validate:"required,hash"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -64,22 +64,23 @@ func init() { func init() { proto.RegisterFile("instance.proto", fileDescriptor_fd22322185b2070b) } var fileDescriptor_fd22322185b2070b = []byte{ - // 226 bytes of a gzipped FileDescriptorProto + // 255 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0xcc, 0x2b, 0x2e, 0x49, 0xcc, 0x4b, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xca, 0x4d, 0x2d, 0x4e, 0xd7, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x96, 0x52, 0x4a, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0x8b, 0x27, - 0x95, 0xa6, 0xe9, 0x83, 0x78, 0x60, 0x0e, 0x98, 0x05, 0x51, 0xaf, 0x34, 0x9b, 0x89, 0x8b, 0xc3, - 0x13, 0x6a, 0x84, 0x90, 0x3b, 0x17, 0x4b, 0x46, 0x62, 0x71, 0x86, 0x04, 0xa3, 0x02, 0xa3, 0x06, - 0x8f, 0x93, 0xf1, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0x6b, 0xa7, 0x67, 0x96, 0x64, 0x94, + 0x95, 0xa6, 0xe9, 0x83, 0x78, 0x60, 0x0e, 0x98, 0x05, 0x51, 0xaf, 0xf4, 0x89, 0x89, 0x8b, 0xc3, + 0x13, 0x6a, 0x84, 0x50, 0x0e, 0x17, 0x4b, 0x46, 0x62, 0x71, 0x86, 0x04, 0xa3, 0x02, 0xa3, 0x06, + 0x8f, 0x53, 0xc4, 0x89, 0x7b, 0xf2, 0x0c, 0xb7, 0xee, 0xc9, 0x6b, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x83, 0x4c, 0xd7, 0x4d, 0xcb, 0x2f, 0xcd, 0x4b, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x4f, 0xcd, 0x4b, 0xcf, 0xcc, 0x4b, 0xd5, 0x07, 0xe9, 0xd2, 0xf3, 0x48, - 0x2c, 0xce, 0x08, 0x02, 0x1b, 0x20, 0x94, 0xc6, 0xc5, 0x5d, 0x9c, 0x5a, 0x54, 0x96, 0x99, 0x9c, - 0x0a, 0x12, 0x94, 0x60, 0x02, 0x9b, 0xe7, 0x42, 0x86, 0x79, 0x9f, 0xee, 0xc9, 0xf3, 0x82, 0x38, - 0x56, 0x4a, 0x79, 0x89, 0xb9, 0xa9, 0x56, 0x46, 0x4a, 0x41, 0xc8, 0x06, 0x0b, 0xc5, 0x71, 0xb1, - 0xa7, 0xe6, 0x95, 0x81, 0xed, 0x60, 0xa6, 0x96, 0x1d, 0xc6, 0x4a, 0x41, 0x30, 0x43, 0x9d, 0x4c, - 0x4e, 0x3c, 0x94, 0x63, 0x58, 0xf1, 0x48, 0x8e, 0x31, 0x4a, 0x8b, 0xb0, 0x81, 0xb0, 0x98, 0x48, - 0x62, 0x03, 0x07, 0xad, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x82, 0x71, 0x79, 0x6a, 0x9c, 0x01, - 0x00, 0x00, + 0x2c, 0xce, 0xf8, 0x74, 0x4f, 0x5e, 0x11, 0xc4, 0xb1, 0x52, 0xd2, 0x55, 0x52, 0x28, 0x4b, 0xcc, + 0xc9, 0x4c, 0x49, 0x2c, 0x49, 0xb5, 0x52, 0x2a, 0x4a, 0x2d, 0x2c, 0xcd, 0x2c, 0x4a, 0x4d, 0xd1, + 0x01, 0xc9, 0x29, 0x05, 0x81, 0x6d, 0x11, 0xaa, 0xe7, 0xe2, 0x2e, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, + 0x4e, 0x05, 0xe9, 0x94, 0x60, 0x02, 0x5b, 0x1a, 0x4b, 0x9e, 0xa5, 0x6a, 0x10, 0x4b, 0xf3, 0x12, + 0x73, 0x53, 0xad, 0x8c, 0xf0, 0xd8, 0x8c, 0x6c, 0xa3, 0x50, 0x39, 0x17, 0x7b, 0x6a, 0x5e, 0x19, + 0xd8, 0x72, 0x66, 0x6a, 0x59, 0x6e, 0x8c, 0xc7, 0x72, 0x98, 0x6d, 0x4e, 0x26, 0x27, 0x1e, 0xca, + 0x31, 0xac, 0x78, 0x24, 0xc7, 0x18, 0xa5, 0x45, 0xd8, 0x26, 0x58, 0x04, 0x27, 0xb1, 0x81, 0x63, + 0xcc, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x1b, 0xdc, 0x00, 0xf3, 0x01, 0x00, 0x00, } func (this *Instance) Equal(that interface{}) bool { diff --git a/ownership/ownership.go b/ownership/ownership.go new file mode 100644 index 000000000..713636653 --- /dev/null +++ b/ownership/ownership.go @@ -0,0 +1,19 @@ +package ownership + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" + "github.com/mesg-foundation/engine/hash" +) + +// New returns a new ownership and validate it. +func New(owner string, resource Ownership_Resource, resourceHash hash.Hash, resourceAddress sdk.AccAddress) (*Ownership, error) { + own := &Ownership{ + Owner: owner, + Resource: resource, + ResourceHash: resourceHash, + ResourceAddress: resourceAddress, + } + own.Hash = hash.Dump(own) + return own, xvalidator.Struct(own) +} diff --git a/ownership/ownership.pb.go b/ownership/ownership.pb.go index 295f8e8f8..203112c10 100644 --- a/ownership/ownership.pb.go +++ b/ownership/ownership.pb.go @@ -58,15 +58,16 @@ func (Ownership_Resource) EnumDescriptor() ([]byte, []int) { // Ownership is a ownership relation between one owner and a resource. type Ownership struct { // Service's hash. - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required,hash"` // The owner of the resource. + // TODO: to transform to accAddress Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" hash:"name:2" validate:"required"` // Resource's hash. - ResourceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=resourceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"resourceHash" hash:"name:3"` + ResourceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=resourceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"resourceHash" hash:"name:3" validate:"required,hash"` // Resource's type. - Resource Ownership_Resource `protobuf:"varint,4,opt,name=resource,proto3,enum=mesg.types.Ownership_Resource" json:"resource,omitempty"` + Resource Ownership_Resource `protobuf:"varint,4,opt,name=resource,proto3,enum=mesg.types.Ownership_Resource" json:"resource,omitempty" validate:"required"` // The address of the resource. - ResourceAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=resourceAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"resourceAddress,omitempty" hash:"-" validate:"accaddress"` + ResourceAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,5,opt,name=resourceAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"resourceAddress,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -104,32 +105,33 @@ func init() { func init() { proto.RegisterFile("ownership.proto", fileDescriptor_21ae26e0dccf9d04) } var fileDescriptor_21ae26e0dccf9d04 = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcf, 0x8e, 0x93, 0x40, - 0x1c, 0x2e, 0x2d, 0xad, 0xed, 0x58, 0x2d, 0x99, 0x13, 0x31, 0x06, 0x70, 0x12, 0x93, 0x26, 0x06, - 0x48, 0xda, 0x78, 0xc1, 0x53, 0x1b, 0x0f, 0x9e, 0xd4, 0xd0, 0x9b, 0xb7, 0xe9, 0xf0, 0x2b, 0x10, - 0x65, 0xa6, 0xce, 0x40, 0x8d, 0x07, 0x5f, 0xc2, 0xa7, 0xf0, 0x51, 0xfa, 0x0c, 0x1e, 0x48, 0x76, - 0x1f, 0xa1, 0xc7, 0x3d, 0x6d, 0x80, 0xd2, 0xed, 0x6e, 0x7a, 0xd8, 0xec, 0x89, 0xf9, 0xc8, 0xf7, - 0x6f, 0xbe, 0x0c, 0x9a, 0x88, 0x5f, 0x1c, 0xa4, 0x4a, 0xd2, 0xad, 0xb7, 0x95, 0x22, 0x17, 0x18, - 0x65, 0xa0, 0x62, 0x2f, 0xff, 0xbd, 0x05, 0xf5, 0x8a, 0xc4, 0x22, 0x16, 0x7e, 0xfd, 0x7f, 0x5d, - 0x6c, 0xfc, 0x0a, 0xd5, 0xa0, 0x3e, 0x35, 0x7c, 0xf2, 0x57, 0x47, 0xa3, 0x2f, 0xad, 0x07, 0x8e, - 0x91, 0x9e, 0x50, 0x95, 0x98, 0x9a, 0xa3, 0x4d, 0xc7, 0xcb, 0xd5, 0xbe, 0xb4, 0x3b, 0xff, 0x4b, - 0xfb, 0x5d, 0x9c, 0xe6, 0x49, 0xb1, 0xf6, 0x98, 0xc8, 0xfc, 0xca, 0xde, 0xdd, 0x88, 0x82, 0x47, - 0x34, 0x4f, 0x05, 0xf7, 0x81, 0xc7, 0x29, 0x07, 0xbf, 0x52, 0x79, 0x9f, 0xa8, 0x4a, 0x0e, 0xa5, - 0xfd, 0xba, 0x02, 0x01, 0x71, 0x89, 0xb3, 0xa3, 0x3f, 0xd2, 0x88, 0xe6, 0x10, 0x10, 0x09, 0x3f, - 0x8b, 0x54, 0x42, 0x44, 0xc2, 0x3a, 0x00, 0x7f, 0x40, 0xfd, 0xba, 0xb9, 0xd9, 0x75, 0xb4, 0xe9, - 0x68, 0xf9, 0xf6, 0x50, 0xda, 0x6f, 0x1a, 0x19, 0xa7, 0x19, 0x04, 0xb3, 0xcb, 0xda, 0x46, 0x83, - 0x13, 0x34, 0x96, 0xa0, 0x44, 0x21, 0x19, 0x54, 0x91, 0x66, 0xaf, 0x6e, 0xfb, 0xf1, 0x69, 0x6d, - 0x5f, 0x9c, 0xc5, 0xce, 0x49, 0x78, 0xcf, 0x19, 0x07, 0x68, 0xd8, 0x62, 0x53, 0x77, 0xb4, 0xe9, - 0xcb, 0x99, 0xe5, 0xdd, 0x0d, 0xec, 0x9d, 0x86, 0xf3, 0xc2, 0x23, 0x2b, 0x3c, 0xf1, 0xf1, 0x1f, - 0x34, 0x69, 0xcf, 0x8b, 0x28, 0x92, 0xa0, 0x94, 0xd9, 0x6f, 0x66, 0x3d, 0x94, 0xb6, 0x75, 0x61, - 0x23, 0xca, 0x18, 0x6d, 0x88, 0xe4, 0xa6, 0xb4, 0xdd, 0xb3, 0x6b, 0x30, 0xa1, 0x32, 0xa1, 0x8e, - 0x1f, 0x57, 0x45, 0xdf, 0xfd, 0x26, 0x7f, 0xc1, 0xd8, 0xd1, 0x3a, 0x7c, 0x98, 0x45, 0x02, 0x34, - 0x6c, 0x4b, 0xe1, 0x21, 0xd2, 0x3f, 0x0b, 0x0e, 0x46, 0x07, 0x3f, 0x47, 0xcf, 0x56, 0x20, 0x77, - 0x29, 0x03, 0x43, 0xab, 0xc0, 0x57, 0x29, 0x18, 0x28, 0x65, 0x74, 0x31, 0x42, 0x83, 0xb0, 0xe0, - 0x1c, 0xa4, 0xd1, 0x5b, 0xbe, 0xdf, 0x5f, 0x59, 0x9d, 0x7f, 0xd7, 0x96, 0xf6, 0xed, 0x11, 0x63, - 0x9e, 0x5e, 0xe0, 0x7a, 0x50, 0x3f, 0xa9, 0xf9, 0x6d, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x62, - 0x80, 0xe0, 0x95, 0x02, 0x00, 0x00, + // 407 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xbf, 0x6e, 0xd3, 0x40, + 0x18, 0xcf, 0xb5, 0x6e, 0x49, 0x8f, 0x8a, 0x5a, 0xc7, 0x80, 0xc5, 0x10, 0x9b, 0x93, 0x80, 0x48, + 0x60, 0x5b, 0x6a, 0xc5, 0x62, 0xa6, 0x7a, 0x62, 0x02, 0xe4, 0x2e, 0x08, 0xc1, 0x70, 0x39, 0x7f, + 0xb5, 0x2d, 0xe2, 0xbb, 0x70, 0x67, 0x07, 0x31, 0xb2, 0xf0, 0x2c, 0x3c, 0x4a, 0x1e, 0x80, 0x89, + 0xc1, 0x12, 0x3c, 0x42, 0x46, 0x26, 0xe4, 0x73, 0x9c, 0x04, 0x14, 0x45, 0xa8, 0x93, 0xfd, 0xb3, + 0xef, 0xf7, 0xe7, 0xfb, 0xdd, 0x87, 0xcf, 0xe4, 0x27, 0x01, 0x4a, 0xe7, 0xc5, 0x2c, 0x98, 0x29, + 0x59, 0x49, 0x82, 0x4b, 0xd0, 0x59, 0x50, 0x7d, 0x9e, 0x81, 0xbe, 0x4f, 0x33, 0x99, 0xc9, 0xd0, + 0x7c, 0x9f, 0xd4, 0xd7, 0x61, 0x8b, 0x0c, 0x30, 0x6f, 0xdd, 0x79, 0xfa, 0xdd, 0xc2, 0x27,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, 0x63, 0xd0, 0xdf, 0x8d, 0xeb, 0x6f, 0x55, 0xc0, 0xa5, 0x2e, 0xa5, 0x5e, + 0x3d, 0x7c, 0x9d, 0x7e, 0x08, 0xbb, 0x88, 0x97, 0x9c, 0xaf, 0x3c, 0x92, 0x7f, 0x4d, 0x69, 0x84, + 0x87, 0x7d, 0x6e, 0x32, 0xc4, 0xd6, 0x4b, 0x29, 0xc0, 0x1e, 0x90, 0xdb, 0xf8, 0xd6, 0x15, 0xa8, + 0x79, 0xc1, 0xc1, 0x46, 0x2d, 0x78, 0xad, 0x24, 0x07, 0xad, 0xed, 0x03, 0x82, 0xf1, 0x71, 0x52, + 0x0b, 0x01, 0xca, 0x3e, 0x8c, 0x9f, 0x2d, 0x7e, 0x8e, 0x06, 0xdf, 0x7e, 0x8d, 0xd0, 0xdb, 0xff, + 0xb8, 0x88, 0xf5, 0x0e, 0x4f, 0x8e, 0xcd, 0x52, 0x5e, 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0xc1, + 0xad, 0x64, 0x6e, 0xd7, 0x02, 0x00, 0x00, } func (this *Ownership) Equal(that interface{}) bool { diff --git a/process/process.go b/process/process.go index c6d9a65a6..837822ea7 100644 --- a/process/process.go +++ b/process/process.go @@ -11,7 +11,7 @@ import ( ) // New returns a new process and validate it. -func New(name string, nodes []*Process_Node, edges []*Process_Edge) *Process { +func New(name string, nodes []*Process_Node, edges []*Process_Edge) (*Process, error) { p := &Process{ Name: name, Nodes: nodes, @@ -19,7 +19,7 @@ func New(name string, nodes []*Process_Node, edges []*Process_Edge) *Process { } p.Hash = hash.Dump(p) p.Address = sdk.AccAddress(crypto.AddressHash(p.Hash)) - return p + return p, p.Validate() } // Validate returns an error if the process is invalid for whatever reason diff --git a/process/process.pb.go b/process/process.pb.go index 4ea80fdb2..098ce8f77 100644 --- a/process/process.pb.go +++ b/process/process.pb.go @@ -98,15 +98,15 @@ func (Process_Node_Filter_Condition_Predicate) EnumDescriptor() ([]byte, []int) // A process is a configuration to trigger a specific task when certains conditions of a trigger are valid. type Process struct { // Process's hash - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required,hash"` // Process's name - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" hash:"name:2" validate:"required"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" hash:"name:2" validate:"required,printascii"` // Nodes with information related to the execution to trigger. Nodes []*Process_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty" hash:"name:4" validate:"dive,required"` // Edges to create the link between the nodes. Edges []*Process_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty" hash:"name:5" validate:"dive,required"` // The address of the process. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,6,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -258,7 +258,7 @@ func (*Process_Node) XXX_OneofWrappers() []interface{} { type Process_Node_Result struct { // Hash of the instance that triggers the process. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required,hash"` // Key of the task that triggers the process. TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:3" validate:"printascii,required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -292,7 +292,7 @@ var xxx_messageInfo_Process_Node_Result proto.InternalMessageInfo type Process_Node_Event struct { // Hash of the instance that triggers the process. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required,hash"` // Key of the event that triggers the process. EventKey string `protobuf:"bytes,3,opt,name=eventKey,proto3" json:"eventKey,omitempty" hash:"name:3" validate:"printascii,required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -326,7 +326,7 @@ var xxx_messageInfo_Process_Node_Event proto.InternalMessageInfo type Process_Node_Task struct { // Hash of the instance to execute. - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,2,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:2" validate:"required,hash"` // Task of the instance to execute. TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty" hash:"name:3" validate:"printascii,required"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -836,83 +836,84 @@ func init() { func init() { proto.RegisterFile("process.proto", fileDescriptor_54c4d0e8c0aaf5c3) } var fileDescriptor_54c4d0e8c0aaf5c3 = []byte{ - // 1204 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x97, 0x5f, 0x6f, 0xdb, 0xd4, - 0x1b, 0xc7, 0xeb, 0xc4, 0xf9, 0xf7, 0x34, 0xab, 0xf2, 0x3b, 0xfa, 0x09, 0x22, 0xd3, 0xd5, 0x25, - 0xd3, 0x68, 0x0b, 0xab, 0x43, 0xd3, 0x76, 0x63, 0x45, 0x08, 0xd5, 0x55, 0xb6, 0x95, 0x65, 0x59, - 0x9b, 0xa5, 0x03, 0x8d, 0x8b, 0xca, 0xb5, 0x4f, 0x12, 0xab, 0x8e, 0x9d, 0xf9, 0x1c, 0x97, 0x16, - 0x71, 0x89, 0xc4, 0x5b, 0xe1, 0x2d, 0xf0, 0x0e, 0x26, 0x6e, 0x40, 0x70, 0xc7, 0x45, 0x24, 0x76, - 0xc7, 0x6d, 0x24, 0x6e, 0xb8, 0x40, 0xe8, 0x9c, 0x63, 0xa7, 0x69, 0x93, 0xb4, 0xe9, 0x06, 0x42, - 0xe2, 0x2a, 0xb1, 0xfd, 0x3c, 0x9f, 0xc7, 0xcf, 0xf3, 0x9c, 0xf3, 0x3d, 0x8f, 0xe1, 0x5a, 0xc7, - 0xf7, 0x4c, 0x4c, 0x88, 0xd6, 0xf1, 0x3d, 0xea, 0x21, 0x68, 0x63, 0xd2, 0xd4, 0xe8, 0x49, 0x07, - 0x13, 0xa5, 0xd0, 0xf4, 0x9a, 0x5e, 0x91, 0xdf, 0x3f, 0x08, 0x1a, 0x45, 0x76, 0xc5, 0x2f, 0xf8, - 0x3f, 0x61, 0xaf, 0xbc, 0xd5, 0x7f, 0xcc, 0x7d, 0x8a, 0x84, 0xfa, 0x81, 0x49, 0xc5, 0xc3, 0xc2, - 0x77, 0xb3, 0x90, 0xda, 0x11, 0x78, 0xd4, 0x04, 0xb9, 0x65, 0x90, 0x56, 0x5e, 0x9a, 0x97, 0x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0x04, 0x32, 0xb3, - 0x40, 0x1f, 0x0e, 0xce, 0xca, 0x0b, 0xbd, 0xae, 0x7a, 0x63, 0xdc, 0x5b, 0x9d, 0x1e, 0xa4, 0x5c, - 0xc5, 0xd8, 0x56, 0x59, 0x82, 0x84, 0xed, 0x5a, 0xf8, 0x98, 0xbf, 0x96, 0x3c, 0xfa, 0x7c, 0x11, - 0x16, 0xfd, 0x04, 0xe2, 0xaf, 0x97, 0xc0, 0x6a, 0x98, 0x80, 0x0e, 0x90, 0x26, 0xd8, 0xc1, 0x26, - 0xf5, 0x7c, 0x3d, 0x09, 0x32, 0x23, 0x29, 0xc7, 0x20, 0xb3, 0x8f, 0x12, 0x36, 0xff, 0x13, 0xdf, - 0xbc, 0xe2, 0xfc, 0x4f, 0x7c, 0x93, 0x39, 0x5a, 0xfd, 0xd3, 0x72, 0xc2, 0x55, 0xcf, 0x3c, 0xf4, - 0xd5, 0x17, 0xbf, 0xce, 0x4d, 0x7d, 0xfb, 0x72, 0x4e, 0x7a, 0xb6, 0x74, 0xf9, 0xf0, 0x13, 0x7e, - 0xc3, 0x1e, 0x24, 0xf9, 0x7e, 0x58, 0xfd, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x7e, 0x68, 0xa8, - 0xd5, 0x0e, 0x00, 0x00, + // 1226 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x97, 0xdf, 0x6f, 0xdb, 0x54, + 0x14, 0xc7, 0xeb, 0xc4, 0x49, 0x9a, 0xd3, 0x6c, 0x0a, 0x57, 0x08, 0x59, 0x66, 0x9b, 0x8b, 0xa7, + 0xad, 0x1d, 0xac, 0x0e, 0x4b, 0xba, 0x0d, 0xca, 0x03, 0xaa, 0x4b, 0xb6, 0x95, 0x65, 0x59, 0x1b, + 0xd2, 0x09, 0x0d, 0x50, 0xe5, 0xda, 0x37, 0x89, 0x55, 0xc7, 0xce, 0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x12, 0x79, 0x94, 0x77, 0x6e, 0xa1, 0xa8, 0x4d, 0x2a, + 0xb9, 0x51, 0xe3, 0x66, 0xe6, 0x1b, 0xbd, 0xae, 0x76, 0xe1, 0x44, 0x6b, 0x1f, 0xcc, 0xd5, 0x62, + 0x06, 0xda, 0x84, 0x14, 0x3e, 0xc0, 0x3e, 0x55, 0x92, 0x1c, 0x76, 0x65, 0x22, 0xac, 0xcc, 0xac, + 0x46, 0x58, 0x25, 0xc6, 0x12, 0x04, 0x74, 0x0f, 0x64, 0x6a, 0x91, 0x7d, 0x45, 0xe6, 0xa4, 0xcb, + 0x13, 0x49, 0x75, 0x8b, 0xec, 0x8f, 0x80, 0x56, 0x19, 0x88, 0xfb, 0xa3, 0x0d, 0x48, 0xb6, 0xad, + 0x8e, 0x92, 0xe2, 0x98, 0x4b, 0x13, 0x31, 0x8f, 0xac, 0xce, 0x08, 0xe5, 0x36, 0xa3, 0x30, 0x6f, + 0x56, 0xa5, 0x86, 0xeb, 0x51, 0x1c, 0xf2, 0xf6, 0x4e, 0xab, 0xd2, 0x3d, 0x6e, 0x36, 0x82, 0xba, + 0xc3, 0xab, 0x24, 0x18, 0xea, 0xaf, 0x12, 0xa4, 0x45, 0x35, 0xd1, 0xb7, 0x12, 0xe4, 0x5c, 0x9f, + 0x50, 0xcb, 0xb7, 0x31, 0x1b, 0x39, 0xde, 0x85, 0x9c, 0xf9, 0xd5, 0xab, 0x4d, 0xeb, 0xf5, 0x33, + 0x47, 0x4e, 0x8c, 0xec, 0x89, 0x90, 0xe8, 0x53, 0xc8, 0xb0, 0x4a, 0x3d, 0xc4, 0x47, 0xbc, 0x6d, + 0xa3, 0xd3, 0x5b, 0x1a, 0x46, 0x1d, 0x0f, 0xed, 0xd0, 0x18, 0xf4, 0x01, 0xea, 0x6f, 0x12, 0xa4, + 0x78, 0x6f, 0xff, 0x13, 0x99, 0x55, 0x60, 0x9e, 0x2f, 0xa6, 0xd7, 0x49, 0x6d, 0x40, 0x50, 0x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 0x30, 0x4f, 0xb0, 0x87, 0x6d, 0x1a, 0x84, 0x66, 0x1a, 0x64, 0x46, 0x52, 0x0f, 0x41, 0x66, 0x5f, + 0x31, 0xec, 0x8b, 0x80, 0x84, 0xf6, 0x39, 0xbf, 0x08, 0x48, 0x68, 0x33, 0x47, 0x67, 0xb0, 0x5b, + 0xce, 0xb8, 0xea, 0x99, 0x87, 0x59, 0x7a, 0xfe, 0xc7, 0x95, 0xb9, 0x1f, 0x5f, 0x5c, 0x91, 0x9e, + 0xde, 0x38, 0xfb, 0x04, 0x14, 0x7f, 0x04, 0xef, 0xa5, 0xf9, 0x3c, 0x94, 0xfe, 0x0e, 0x00, 0x00, + 0xff, 0xff, 0x12, 0xc3, 0x10, 0x5e, 0x16, 0x0f, 0x00, 0x00, } func (this *Process) Equal(that interface{}) bool { diff --git a/process/process_test.go b/process/process_test.go index 5074fa0df..c3c6c6362 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -3,9 +3,11 @@ package process import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/protobuf/types" "github.com/stretchr/testify/assert" + "github.com/tendermint/tendermint/crypto" ) func TestValidateProcess(t *testing.T) { @@ -47,10 +49,12 @@ func TestValidateProcess(t *testing.T) { err string }{ {w: &Process{ - Hash: hash.Int(1), - Name: "invalid-struct", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "invalid-struct", }, err: "should contain exactly one trigger"}, {w: &Process{ + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), Nodes: []*Process_Node{ { Type: &Process_Node_Result_{&Process_Node_Result{InstanceHash: hash.Int(1)}}, @@ -60,29 +64,33 @@ func TestValidateProcess(t *testing.T) { Name: "missing-key", }, err: "Key is a required field. TaskKey is a required field"}, {w: &Process{ - Hash: hash.Int(1), - Name: "edge-src-missing-node", - Nodes: nodes, - Edges: append(edges, &Process_Edge{Src: "-", Dst: "nodeKey2"}), + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "edge-src-missing-node", + Nodes: nodes, + Edges: append(edges, &Process_Edge{Src: "-", Dst: "nodeKey2"}), }, err: "node \"-\" not found"}, {w: &Process{ - Hash: hash.Int(1), - Name: "edge-dst-missing-node", - Nodes: nodes, - Edges: append(edges, &Process_Edge{Src: "nodeKey1", Dst: "-"}), + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "edge-dst-missing-node", + Nodes: nodes, + Edges: append(edges, &Process_Edge{Src: "nodeKey1", Dst: "-"}), }, err: "node \"-\" not found"}, {w: &Process{ - Hash: hash.Int(1), - Name: "cyclic-graph", - Nodes: nodes, + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "cyclic-graph", + Nodes: nodes, Edges: append(edges, &Process_Edge{Src: "nodeKey1", Dst: "nodeKey2"}, &Process_Edge{Src: "nodeKey2", Dst: "nodeKey1"}, ), }, err: "process should not contain any cycles"}, {w: &Process{ - Hash: hash.Int(1), - Name: "non-connected-graph", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "non-connected-graph", Nodes: append(nodes, &Process_Node{ Key: "nodeKey3", Type: &Process_Node_Task_{&Process_Node_Task{ @@ -102,8 +110,9 @@ func TestValidateProcess(t *testing.T) { ), }, err: "process should be a connected graph"}, {w: &Process{ - Hash: hash.Int(1), - Name: "multiple-parent-graph", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "multiple-parent-graph", Nodes: append(nodes, &Process_Node{ Key: "nodeKey3", Type: &Process_Node_Task_{&Process_Node_Task{ @@ -125,8 +134,9 @@ func TestValidateProcess(t *testing.T) { ), }, err: "process should contain nodes with one parent maximum"}, {w: &Process{ - Hash: hash.Int(1), - Name: "multiple-parent-graph", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "multiple-parent-graph", Nodes: append(nodes, &Process_Node{ Key: "nodeKey3", Type: &Process_Node_Task_{&Process_Node_Task{ @@ -168,8 +178,9 @@ func TestValidateProcess(t *testing.T) { ), }, valid: true}, {w: &Process{ - Hash: hash.Int(1), - Name: "inputs-with-invalid-node", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "inputs-with-invalid-node", Nodes: append(nodes, &Process_Node{ Key: "mapping", Type: &Process_Node_Map_{&Process_Node_Map{ @@ -184,8 +195,9 @@ func TestValidateProcess(t *testing.T) { }), }, err: "node \"invalid\" not found"}, {w: &Process{ - Hash: hash.Int(1), - Name: "inputs-with-valid-ref", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "inputs-with-valid-ref", Nodes: append(nodes, &Process_Node{ Key: "mapping", Type: &Process_Node_Map_{&Process_Node_Map{ @@ -204,8 +216,9 @@ func TestValidateProcess(t *testing.T) { ), }, valid: true}, {w: &Process{ - Hash: hash.Int(1), - Name: "filter-gte-invalid-value-type", + Address: sdk.AccAddress(crypto.AddressHash([]byte("address"))), + Hash: hash.Int(1), + Name: "filter-gte-invalid-value-type", Nodes: append(nodes, &Process_Node{ Key: "filter", Type: &Process_Node_Filter_{&Process_Node_Filter{ diff --git a/protobuf/types/event.proto b/protobuf/types/event.proto index 27adb1595..f085fa38c 100644 --- a/protobuf/types/event.proto +++ b/protobuf/types/event.proto @@ -12,7 +12,7 @@ option (gogoproto.goproto_getters_all) = false; message Event { // Hash is a unique hash to identify event. bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-"', + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; diff --git a/protobuf/types/execution.proto b/protobuf/types/execution.proto index 244e91db5..46473fcfb 100644 --- a/protobuf/types/execution.proto +++ b/protobuf/types/execution.proto @@ -34,7 +34,7 @@ enum Status { message Execution { // Hash is a unique hash to identify execution. bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-"', + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; @@ -43,33 +43,33 @@ message Execution { // if execution is triggered by another one, // dependency execution considered as the parent. bytes parentHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2"', + (gogoproto.moretags) = 'hash:"name:2" validate:"required_without=EventHash,omitempty,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // eventHash is unique event hash. bytes eventHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', + (gogoproto.moretags) = 'hash:"name:3" validate:"required_without=ParentHash,omitempty,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // Status is the current status of execution. Status status = 4 [ - (gogoproto.moretags) = 'hash:"-"' + (gogoproto.moretags) = 'hash:"-" validate:"required"' ]; // instanceHash is hash of the instance that can proceed an execution bytes instanceHash = 5 [ - (gogoproto.moretags) = 'hash:"name:5"', + (gogoproto.moretags) = 'hash:"name:5" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // taskKey is the key of the task of this execution. string taskKey = 6 [ - (gogoproto.moretags) = 'hash:"name:6"' + (gogoproto.moretags) = 'hash:"name:6" validate:"required,printascii"' ]; // inputs data of the execution. @@ -94,7 +94,7 @@ message Execution { // processHash is the unique hash of the process associated to this execution. bytes processHash = 11 [ - (gogoproto.moretags) = 'hash:"name:11"', + (gogoproto.moretags) = 'hash:"name:11" validate:"omitempty,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; @@ -106,14 +106,14 @@ message Execution { // runner that should execute this execution. bytes executorHash = 13 [ - (gogoproto.moretags) = 'hash:"name:13"', + (gogoproto.moretags) = 'hash:"name:13" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // price of running the exeuction. string price = 14 [ - (gogoproto.moretags) = 'hash:"name:14" validate:"coins"' + (gogoproto.moretags) = 'hash:"name:14" validate:"required,coinsPositiveZero"' ]; // blockHeight where the execution was included into blockchain. @@ -125,14 +125,14 @@ message Execution { message Emitter { // Emitter's hash. bytes runnerHash = 1 [ - (gogoproto.moretags) = 'hash:"-" validate:"hash"', + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // Block height when this emitter proposed the execution. int64 blockHeight = 2 [ - (gogoproto.moretags) = 'hash:"-"' + (gogoproto.moretags) = 'hash:"-" validate:"required"' ]; } @@ -143,7 +143,7 @@ message Execution { // The address of the execution. bytes address = 17 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/instance.proto b/protobuf/types/instance.proto index 433fe7e90..e4ebaaf80 100644 --- a/protobuf/types/instance.proto +++ b/protobuf/types/instance.proto @@ -11,18 +11,19 @@ option (gogoproto.equal_all) = true; // Instance represents service's instance. message Instance { bytes hash = 1 [ + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; bytes serviceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2"', + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; bytes envHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', + (gogoproto.moretags) = 'hash:"name:3" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; diff --git a/protobuf/types/ownership.proto b/protobuf/types/ownership.proto index f9039c50a..da61def0c 100644 --- a/protobuf/types/ownership.proto +++ b/protobuf/types/ownership.proto @@ -14,19 +14,20 @@ message Ownership { // Service's hash. bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-" validate:"required"', + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // The owner of the resource. + // TODO: to transform to accAddress string owner = 2 [ (gogoproto.moretags) = 'hash:"name:2" validate:"required"' ]; // Resource's hash. bytes resourceHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', + (gogoproto.moretags) = 'hash:"name:3" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; @@ -39,11 +40,13 @@ message Ownership { } // Resource's type. - Resource resource = 4; + Resource resource = 4 [ + (gogoproto.moretags) = 'validate:"required"' + ]; // The address of the resource. bytes resourceAddress = 5 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/process.proto b/protobuf/types/process.proto index 766b18ed4..bba8945de 100644 --- a/protobuf/types/process.proto +++ b/protobuf/types/process.proto @@ -16,7 +16,7 @@ message Process { message Result { // Hash of the instance that triggers the process. bytes instanceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"', + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; @@ -30,7 +30,7 @@ message Process { message Event { // Hash of the instance that triggers the process. bytes instanceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"', + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; @@ -44,7 +44,7 @@ message Process { message Task { // Hash of the instance to execute. bytes instanceHash = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"', + (gogoproto.moretags) = 'hash:"name:2" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; @@ -234,14 +234,14 @@ message Process { // Process's hash bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-" validate:"required"', + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // Process's name string name = 2 [ - (gogoproto.moretags) = 'hash:"name:2" validate:"required"' + (gogoproto.moretags) = 'hash:"name:2" validate:"required,printascii"' ]; // Nodes with information related to the execution to trigger. @@ -256,7 +256,7 @@ message Process { // The address of the process. bytes address = 6 [ - (gogoproto.moretags) = 'hash:"-"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/protobuf/types/runner.proto b/protobuf/types/runner.proto index 4e83bf559..2d0d01529 100644 --- a/protobuf/types/runner.proto +++ b/protobuf/types/runner.proto @@ -12,26 +12,26 @@ option (gogoproto.equal_all) = true; message Runner { // Runner's hash bytes hash = 1 [ - (gogoproto.moretags) = 'hash:"-"', + (gogoproto.moretags) = 'hash:"-" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // owner of the engine of this runner string owner = 2 [ - (gogoproto.moretags) = 'hash:"name:2"' + (gogoproto.moretags) = 'hash:"name:2" validate:"required"' ]; // instanceHash is hash of the instance that runner will handle bytes instanceHash = 3 [ - (gogoproto.moretags) = 'hash:"name:3"', + (gogoproto.moretags) = 'hash:"name:3" validate:"required,hash"', (gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash", (gogoproto.nullable) = false ]; // The address of the runner. bytes address = 4 [ - (gogoproto.moretags) = 'hash:"-" validate:"accaddress"', + (gogoproto.moretags) = 'hash:"-" validate:"required,accaddress"', (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress" ]; } diff --git a/runner/builder/builder.go b/runner/builder/builder.go index ffa62479e..dde206e04 100644 --- a/runner/builder/builder.go +++ b/runner/builder/builder.go @@ -42,19 +42,21 @@ func (b *Builder) Create(req *api.CreateRunnerRequest) (*runnerpb.Runner, error) if err != nil { return nil, err } - instanceEnv := xos.EnvMergeSlices(srv.Configuration.Env, req.Env) envHash := hash.Dump(instanceEnv) - // TODO: should be done by instance or runner - instanceHash := hash.Dump(&instancepb.Instance{ - ServiceHash: srv.Hash, - EnvHash: envHash, - }) + + inst, err := instancepb.New(srv.Hash, envHash) + if err != nil { + return nil, err + } acc, err := b.mc.GetAccount() if err != nil { return nil, err } - expRunner := runnerpb.New(acc.GetAddress().String(), instanceHash) + expRunner, err := runnerpb.New(acc.GetAddress().String(), inst.Hash) + if err != nil { + return nil, err + } expRunnerHash := expRunner.Hash if runExisting, _ := b.mc.GetRunner(expRunnerHash); runExisting != nil { @@ -66,7 +68,7 @@ func (b *Builder) Create(req *api.CreateRunnerRequest) (*runnerpb.Runner, error) if err != nil { return nil, err } - _, err = start(b.container, srv, instanceHash, expRunnerHash, imageHash, instanceEnv, b.engineName, b.port) + _, err = start(b.container, srv, inst.Hash, expRunnerHash, imageHash, instanceEnv, b.engineName, b.port) if err != nil { return nil, err } diff --git a/runner/runner.go b/runner/runner.go index 9a1483b71..400a92479 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -2,17 +2,18 @@ package runner import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mesg-foundation/engine/ext/xvalidator" "github.com/mesg-foundation/engine/hash" "github.com/tendermint/tendermint/crypto" ) // New returns a new execution. -func New(owner string, instanceHash hash.Hash) *Runner { +func New(owner string, instanceHash hash.Hash) (*Runner, error) { run := &Runner{ Owner: owner, InstanceHash: instanceHash, } run.Hash = hash.Dump(run) run.Address = sdk.AccAddress(crypto.AddressHash(run.Hash)) - return run + return run, xvalidator.Struct(run) } diff --git a/runner/runner.pb.go b/runner/runner.pb.go index 09517fc9d..ff344541b 100644 --- a/runner/runner.pb.go +++ b/runner/runner.pb.go @@ -27,13 +27,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Runner represents one node service's instance. type Runner struct { // Runner's hash - Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-"` + Hash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,1,opt,name=hash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"hash" hash:"-" validate:"required,hash"` // owner of the engine of this runner - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" hash:"name:2"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" hash:"name:2" validate:"required"` // instanceHash is hash of the instance that runner will handle - InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:3"` + InstanceHash github_com_mesg_foundation_engine_hash.Hash `protobuf:"bytes,3,opt,name=instanceHash,proto3,customtype=github.com/mesg-foundation/engine/hash.Hash" json:"instanceHash" hash:"name:3" validate:"required,hash"` // The address of the runner. - Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"accaddress"` + Address github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=address,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"address,omitempty" hash:"-" validate:"required,accaddress"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -70,27 +70,28 @@ func init() { func init() { proto.RegisterFile("runner.proto", fileDescriptor_48eceea7e2abc593) } var fileDescriptor_48eceea7e2abc593 = []byte{ - // 307 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xb1, 0x4e, 0xf3, 0x30, - 0x14, 0x85, 0x9b, 0xfe, 0xfd, 0x0b, 0x58, 0x61, 0x20, 0x53, 0xc4, 0x10, 0x47, 0x5e, 0x88, 0x84, - 0x12, 0x4b, 0xed, 0x96, 0x05, 0x35, 0x62, 0x60, 0x4e, 0x37, 0x36, 0xc7, 0x71, 0x93, 0x08, 0x62, - 0x57, 0xb1, 0x03, 0xe2, 0x8d, 0x78, 0x94, 0x3e, 0x03, 0x83, 0x11, 0x3c, 0x42, 0x46, 0x26, 0x14, - 0xbb, 0x95, 0xca, 0x84, 0xc4, 0x64, 0x5f, 0xfb, 0xdc, 0xef, 0x1c, 0xfb, 0x02, 0xb7, 0xeb, 0x39, - 0x67, 0x5d, 0xb2, 0xed, 0x84, 0x12, 0x1e, 0x68, 0x99, 0xac, 0x12, 0xf5, 0xb2, 0x65, 0xf2, 0x12, - 0x55, 0xa2, 0x12, 0xd8, 0x9c, 0x17, 0xfd, 0x06, 0x8f, 0x95, 0x29, 0xcc, 0xce, 0xea, 0xd1, 0xfb, - 0x14, 0xcc, 0x73, 0x03, 0xf0, 0xd6, 0x60, 0x56, 0x13, 0x59, 0xfb, 0x4e, 0xe8, 0x44, 0x6e, 0x76, - 0xb3, 0xd3, 0x70, 0xf2, 0xa6, 0xe1, 0x75, 0xd5, 0xa8, 0xba, 0x2f, 0x12, 0x2a, 0x5a, 0x3c, 0xb2, - 0xe3, 0x8d, 0xe8, 0x79, 0x49, 0x54, 0x23, 0x38, 0x66, 0xbc, 0x6a, 0x38, 0xc3, 0x63, 0x57, 0x72, - 0x47, 0x64, 0x3d, 0x68, 0x78, 0x3a, 0x16, 0x29, 0x8a, 0x51, 0x6e, 0x60, 0xde, 0x15, 0xf8, 0x2f, - 0x9e, 0x39, 0xeb, 0xfc, 0x69, 0xe8, 0x44, 0x67, 0xd9, 0xc5, 0xa0, 0xe1, 0xb9, 0x95, 0x70, 0xd2, - 0xb2, 0x74, 0x81, 0x72, 0x7b, 0xef, 0xd5, 0xc0, 0x6d, 0xb8, 0x54, 0x84, 0x53, 0x36, 0xa2, 0xfc, - 0x7f, 0x26, 0xc5, 0xed, 0xdf, 0x52, 0x1c, 0x5b, 0x2c, 0x51, 0xfe, 0x83, 0xec, 0xb5, 0xe0, 0x84, - 0x94, 0x65, 0xc7, 0xa4, 0xf4, 0x67, 0xc6, 0x64, 0x3d, 0x68, 0x18, 0x1c, 0x72, 0x87, 0x4f, 0xe4, - 0xb1, 0x29, 0x89, 0x62, 0x29, 0x22, 0x94, 0xee, 0x85, 0xe8, 0x4b, 0xc3, 0xf8, 0x28, 0x02, 0x15, - 0xb2, 0x15, 0x72, 0xbf, 0xc4, 0xb2, 0x7c, 0xc0, 0xe6, 0xc7, 0x93, 0x15, 0xa5, 0x2b, 0xdb, 0x91, - 0x1f, 0x3c, 0xb2, 0xc5, 0xee, 0x23, 0x98, 0xbc, 0x7e, 0x06, 0xce, 0x7d, 0xf4, 0xfb, 0x23, 0xec, - 0x2c, 0x8b, 0xb9, 0x19, 0xce, 0xf2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x91, 0x27, 0xd4, 0xaf, 0xdc, - 0x01, 0x00, 0x00, + // 324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0x9b, 0xbf, 0xfd, 0x8b, 0xb0, 0x3a, 0x65, 0x8a, 0x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0x0a, 0x18, 0x0d, 0x7e, 0x32, 0xc0, 0x69, 0xad, 0xf1, 0x1f, 0x3d, 0xd4, 0xe1, 0x42, + 0x1b, 0x22, 0x28, 0x58, 0x70, 0xd0, 0x74, 0x99, 0x6f, 0xfe, 0x96, 0xf9, 0x78, 0x8b, 0x3b, 0xdc, + 0x11, 0xfc, 0x1b, 0xd2, 0x5f, 0xa2, 0x3d, 0xc2, 0x98, 0x02, 0xad, 0x83, 0x96, 0xa3, 0x5f, 0xaf, + 0xab, 0xf0, 0x64, 0x57, 0xfb, 0x84, 0xd2, 0x8d, 0x02, 0xbf, 0x57, 0x61, 0xb4, 0x15, 0x92, 0x4a, + 0x5d, 0x48, 0xbd, 0x59, 0x22, 0xcd, 0x6e, 0x13, 0x37, 0xc1, 0x78, 0x4c, 0xe9, 0xb8, 0x56, 0xa4, + 0x9f, 0xb0, 0xc9, 0x60, 0xf5, 0xda, 0x6d, 0x3c, 0xbd, 0x75, 0xbd, 0xab, 0xfe, 0xef, 0x6d, 0xd6, + 0x7f, 0x63, 0xda, 0x76, 0xc3, 0x1e, 0x7e, 0x04, 0x00, 0x00, 0xff, 0xff, 0x81, 0xe2, 0x9d, 0x6e, + 0x2c, 0x02, 0x00, 0x00, } func (this *Runner) Equal(that interface{}) bool { diff --git a/service/service.go b/service/service.go index 805e1bf71..2484b3b55 100644 --- a/service/service.go +++ b/service/service.go @@ -9,7 +9,8 @@ import ( "github.com/tendermint/tendermint/crypto" ) -func New(sid, name, description string, configuration Service_Configuration, tasks []*Service_Task, events []*Service_Event, dependencies []*Service_Dependency, repository, source string) *Service { +// New initializes a new Service. +func New(sid, name, description string, configuration Service_Configuration, tasks []*Service_Task, events []*Service_Event, dependencies []*Service_Dependency, repository, source string) (*Service, error) { // create service srv := &Service{ Sid: sid, @@ -26,7 +27,14 @@ func New(sid, name, description string, configuration Service_Configuration, tas // calculate and apply hash to service. srv.Hash = hash.Dump(srv) srv.Address = sdk.AccAddress(crypto.AddressHash(srv.Hash)) - return srv + + // set a sid if this one is empty (yes, after hash calculation..) + if srv.Sid == "" { + // make sure that sid doesn't have the same length with id. + srv.Sid = "_" + srv.Hash.String() + } + + return srv, srv.Validate() } // MainServiceKey is key for main service. diff --git a/x/execution/internal/keeper/keeper.go b/x/execution/internal/keeper/keeper.go index 8e4047ed2..3e0d54674 100644 --- a/x/execution/internal/keeper/keeper.go +++ b/x/execution/internal/keeper/keeper.go @@ -105,7 +105,7 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreate) (*executionpb.Exec return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "signer is not the execution's executor") } - exec := executionpb.New( + exec, err := executionpb.New( msg.ProcessHash, run.InstanceHash, msg.ParentHash, @@ -117,6 +117,9 @@ func (k *Keeper) Create(ctx sdk.Context, msg types.MsgCreate) (*executionpb.Exec msg.Tags, msg.ExecutorHash, ) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } // check if exec already exists store := ctx.KVStore(k.storeKey) diff --git a/x/instance/internal/keeper/keeper.go b/x/instance/internal/keeper/keeper.go index badeb37c8..890185b63 100644 --- a/x/instance/internal/keeper/keeper.go +++ b/x/instance/internal/keeper/keeper.go @@ -37,7 +37,10 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) FetchOrCreate(ctx sdk.Context, serviceHash hash.Hash, envHash hash.Hash) (*instance.Instance, error) { store := ctx.KVStore(k.storeKey) - inst := instance.New(serviceHash, envHash) + inst, err := instance.New(serviceHash, envHash) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } if !store.Has(inst.Hash) { value, err := k.cdc.MarshalBinaryLengthPrefixed(inst) diff --git a/x/ownership/internal/keeper/keeper.go b/x/ownership/internal/keeper/keeper.go index 0f9a2495f..43d816adb 100644 --- a/x/ownership/internal/keeper/keeper.go +++ b/x/ownership/internal/keeper/keeper.go @@ -65,14 +65,10 @@ func (k Keeper) Set(ctx sdk.Context, owner sdk.AccAddress, resourceHash hash.Has return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "resource %s:%q already has an owner", resource, resourceHash) } - // TODO: should be moved to a new function - own = &ownership.Ownership{ - Owner: owner.String(), - Resource: resource, - ResourceHash: resourceHash, - ResourceAddress: resourceAddress, + own, err = ownership.New(owner.String(), resource, resourceHash, resourceAddress) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) } - own.Hash = hash.Dump(own) data, err := k.cdc.MarshalBinaryLengthPrefixed(own) if err != nil { diff --git a/x/process/client/rest/query.go b/x/process/client/rest/query.go index 68b428518..a1ac1ca0e 100644 --- a/x/process/client/rest/query.go +++ b/x/process/client/rest/query.go @@ -116,7 +116,11 @@ func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - proc := process.New(req.Name, req.Nodes, req.Edges) + proc, err := process.New(req.Name, req.Nodes, req.Edges) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } rest.PostProcessResponse(w, cliCtx, proc.Hash.String()) } diff --git a/x/process/internal/keeper/keeper.go b/x/process/internal/keeper/keeper.go index 6a7b6e76f..b8cb903bf 100644 --- a/x/process/internal/keeper/keeper.go +++ b/x/process/internal/keeper/keeper.go @@ -45,7 +45,12 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // Create creates a new process. func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*processpb.Process, error) { store := ctx.KVStore(k.storeKey) - p := process.New(msg.Name, msg.Nodes, msg.Edges) + + p, err := process.New(msg.Name, msg.Nodes, msg.Edges) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + if store.Has(p.Hash) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "process %q already exists", p.Hash) } diff --git a/x/process/internal/types/msg.go b/x/process/internal/types/msg.go index 30030ab87..37eecf7ca 100644 --- a/x/process/internal/types/msg.go +++ b/x/process/internal/types/msg.go @@ -22,8 +22,7 @@ func (msg MsgCreate) ValidateBasic() error { if err := xvalidator.Struct(msg); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } - p := processpb.New(msg.Name, msg.Nodes, msg.Edges) - if err := p.Validate(); err != nil { + if _, err := processpb.New(msg.Name, msg.Nodes, msg.Edges); err != nil { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error()) } return nil diff --git a/x/runner/client/rest/query.go b/x/runner/client/rest/query.go index 9c8f09463..d9c642a59 100644 --- a/x/runner/client/rest/query.go +++ b/x/runner/client/rest/query.go @@ -145,8 +145,17 @@ func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { } envHash := hash.Dump(xos.EnvMergeSlices(srv.Configuration.Env, req.Env)) - inst := instance.New(req.ServiceHash, envHash) - run := runner.New(req.Address, inst.Hash) + inst, err := instance.New(req.ServiceHash, envHash) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + run, err := runner.New(req.Address, inst.Hash) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } res := HashResponse{ RunnerHash: run.Hash, diff --git a/x/runner/internal/keeper/keeper.go b/x/runner/internal/keeper/keeper.go index ec17a094e..9db72eb8b 100644 --- a/x/runner/internal/keeper/keeper.go +++ b/x/runner/internal/keeper/keeper.go @@ -45,7 +45,11 @@ func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*runner.Runner, e return nil, err } - r := runner.New(msg.Owner.String(), inst.Hash) + r, err := runner.New(msg.Owner.String(), inst.Hash) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } + if store.Has(r.Hash) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "runner %q already exists", r.Hash) } diff --git a/x/service/client/rest/query.go b/x/service/client/rest/query.go index 3b06b44b3..012a0c127 100644 --- a/x/service/client/rest/query.go +++ b/x/service/client/rest/query.go @@ -96,7 +96,7 @@ func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - srv := service.New( + srv, err := service.New( req.Sid, req.Name, req.Description, @@ -107,6 +107,10 @@ func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { req.Repository, req.Source, ) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } rest.PostProcessResponse(w, cliCtx, srv.Hash.String()) } diff --git a/x/service/internal/keeper/keeper.go b/x/service/internal/keeper/keeper.go index 8684758f7..28063ffa7 100644 --- a/x/service/internal/keeper/keeper.go +++ b/x/service/internal/keeper/keeper.go @@ -39,7 +39,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*servicepb.Service, error) { store := ctx.KVStore(k.storeKey) // create service - srv := servicepb.New( + srv, err := servicepb.New( msg.Sid, msg.Name, msg.Description, @@ -50,22 +50,15 @@ func (k Keeper) Create(ctx sdk.Context, msg *types.MsgCreate) (*servicepb.Servic msg.Repository, msg.Source, ) + if err != nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) + } // check if service already exists. if store.Has(srv.Hash) { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "service %q already exists", srv.Hash) } - // TODO: the following test should be moved in New function - if srv.Sid == "" { - // make sure that sid doesn't have the same length with id. - srv.Sid = "_" + srv.Hash.String() - } - - if err := srv.Validate(); err != nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error()) - } - if _, err := k.ownershipKeeper.Set(ctx, msg.Owner, srv.Hash, ownershippb.Ownership_Service, srv.Address); err != nil { return nil, err }