From a8b2500203435e680e93c485bfc285d28140b0b8 Mon Sep 17 00:00:00 2001 From: ccamel Date: Tue, 11 Apr 2023 19:18:41 +0200 Subject: [PATCH] refactor(logic)!: specify whitelist / blacklist in its own type --- proto/logic/v1beta2/params.proto | 48 ++-- x/logic/keeper/interpreter.go | 4 +- x/logic/migrations/v3/migrations.go | 8 +- x/logic/types/params.go | 12 +- x/logic/types/params.pb.go | 375 ++++++++++++++++++++-------- 5 files changed, 316 insertions(+), 131 deletions(-) diff --git a/proto/logic/v1beta2/params.proto b/proto/logic/v1beta2/params.proto index 382c0125..e4b21c72 100644 --- a/proto/logic/v1beta2/params.proto +++ b/proto/logic/v1beta2/params.proto @@ -71,30 +71,38 @@ message Limits { ]; } -// Interpreter defines the various parameters for the interpreter. -message Interpreter { - option (gogoproto.goproto_stringer) = true; - - // predicates_whitelist specifies a list of prolog predicates that are allowed and can be used by the interpreter. - // The predicates are represented as `/[]`, for example: `findall/3`, or `call`. If a predicate name without arity - // is included in this list, then all predicates with that name will be considered regardless of arity. For example, if `call` is included - // in the whitelist, then all predicates `call/1`, `call/2`, `call/3`... will be allowed. - // If this field is not specified, the interpreter will use the default set of predicates. - repeated string predicates_whitelist = 1 [ +// Filter defines the parameters for filtering the set of strings which can designate anything. +// The filter is used to whitelist or blacklist strings. +message Filter { + // whitelist specifies a list of strings that are allowed. + // If this field is not specified, all strings (in the context of the filter) are allowed. + repeated string whitelist = 1 [ (gogoproto.nullable) = true, - (gogoproto.moretags) = "yaml:\"predicates_whitelist\"" + (gogoproto.moretags) = "yaml:\"whitelist\"" ]; - // predicates_blacklist specifies a list of prolog predicates that are excluded from the set of registered predicates - // and can never be executed by the interpreter. - // The predicates are represented as `/[]`, for example: `findall/3`, or `call`. If a predicate name without arity - // is included in this list, then all predicates with that name will be considered regardless of arity. For example, if `call` is included - // in the blacklist, then all predicates `call/1`, `call/2`, `call/3`... will be excluded. - // If a predicate is included in both whitelist and blacklist, it will be excluded. This means that blacklisted predicates prevails - // on whitelisted predicates. - repeated string predicates_blacklist = 2 [ + // blacklist specifies a list of strings that are excluded from the set of allowed strings. + // If a string is included in both whitelist and blacklist, it will be excluded. This means that + // blacklisted strings prevails over whitelisted ones. + // If this field is not specified, no strings are excluded. + repeated string blacklist = 2 [ (gogoproto.nullable) = true, - (gogoproto.moretags) = "yaml:\"predicates_blacklist\"" + (gogoproto.moretags) = "yaml:\"blacklist\"" + ]; +} + +// Interpreter defines the various parameters for the interpreter. +message Interpreter { + option (gogoproto.goproto_stringer) = true; + + // predicates_filter specifies the filter for the predicates that are allowed to be used by the interpreter. + // The filter is used to whitelist or blacklist predicates represented as `/[]`, for example: + // `findall/3`, or `call`. If a predicate name without arity is included in the filter, then all predicates with that + // name will be considered regardless of arity. For example, if `call` is included in the filter, then all predicates + // `call/1`, `call/2`, `call/3`... will be allowed. + Filter predicates_filter = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"predicates_filter\"" ]; // bootstrap specifies the initial program to run when booting the logic interpreter. diff --git a/x/logic/keeper/interpreter.go b/x/logic/keeper/interpreter.go index 7c3228fc..9373f298 100644 --- a/x/logic/keeper/interpreter.go +++ b/x/logic/keeper/interpreter.go @@ -114,8 +114,8 @@ func (k Keeper) newInterpreter(ctx goctx.Context) (*prolog.Interpreter, *util.Bo gasPolicy := params.GetGasPolicy() limits := params.GetLimits() - whitelist := util.NonZeroOrDefault(interpreterParams.PredicatesWhitelist, interpreter.RegistryNames) - blacklist := interpreterParams.GetPredicatesBlacklist() + whitelist := util.NonZeroOrDefault(interpreterParams.PredicatesFilter.Whitelist, interpreter.RegistryNames) + blacklist := interpreterParams.PredicatesFilter.Blacklist gasMeter := meter.WithWeightedMeter(sdkctx.GasMeter(), nonNilNorZeroOrDefaultUint64(gasPolicy.WeightingFactor, defaultWeightFactor)) predicates := lo.Reduce( diff --git a/x/logic/migrations/v3/migrations.go b/x/logic/migrations/v3/migrations.go index ebc0c357..ee85ffd0 100644 --- a/x/logic/migrations/v3/migrations.go +++ b/x/logic/migrations/v3/migrations.go @@ -42,9 +42,11 @@ func MigrateStore(ctx sdk.Context, newParams := types.Params{ Interpreter: types.Interpreter{ - Bootstrap: oldParams.Interpreter.Bootstrap, - PredicatesWhitelist: oldParams.Interpreter.RegisteredPredicates, - PredicatesBlacklist: []string{}, + Bootstrap: oldParams.Interpreter.Bootstrap, + PredicatesFilter: types.Filter{ + Whitelist: oldParams.Interpreter.RegisteredPredicates, + Blacklist: []string{}, + }, }, Limits: types.Limits{ MaxGas: oldParams.Limits.MaxGas, diff --git a/x/logic/types/params.go b/x/logic/types/params.go index f5b5fb64..c5eeee47 100644 --- a/x/logic/types/params.go +++ b/x/logic/types/params.go @@ -60,12 +60,12 @@ func NewInterpreter(opts ...InterpreterOption) Interpreter { opt(&i) } - if i.PredicatesWhitelist == nil { - i.PredicatesWhitelist = DefaultPredicatesWhitelist + if i.PredicatesFilter.Whitelist == nil { + i.PredicatesFilter.Whitelist = DefaultPredicatesWhitelist } - if i.PredicatesBlacklist == nil { - i.PredicatesBlacklist = DefaultPredicatesBlacklist + if i.PredicatesFilter.Blacklist == nil { + i.PredicatesFilter.Blacklist = DefaultPredicatesBlacklist } return i @@ -77,14 +77,14 @@ type InterpreterOption func(*Interpreter) // WithPredicatesWhitelist sets the whitelist of predicates. func WithPredicatesWhitelist(whitelist []string) InterpreterOption { return func(i *Interpreter) { - i.PredicatesWhitelist = whitelist + i.PredicatesFilter.Whitelist = whitelist } } // WithPredicatesBlacklist sets the blacklist of predicates. func WithPredicatesBlacklist(blacklist []string) InterpreterOption { return func(i *Interpreter) { - i.PredicatesBlacklist = blacklist + i.PredicatesFilter.Blacklist = blacklist } } diff --git a/x/logic/types/params.pb.go b/x/logic/types/params.pb.go index f67d4954..e444be71 100644 --- a/x/logic/types/params.pb.go +++ b/x/logic/types/params.pb.go @@ -141,22 +141,74 @@ func (m *Limits) XXX_DiscardUnknown() { var xxx_messageInfo_Limits proto.InternalMessageInfo +// Filter defines the parameters for filtering the set of strings which can designate anything. +// The filter is used to whitelist or blacklist strings. +type Filter struct { + // whitelist specifies a list of strings that are allowed. + // If this field is not specified, all strings (in the context of the filter) are allowed. + Whitelist []string `protobuf:"bytes,1,rep,name=whitelist,proto3" json:"whitelist,omitempty" yaml:"whitelist"` + // blacklist specifies a list of strings that are excluded from the set of allowed strings. + // If a string is included in both whitelist and blacklist, it will be excluded. This means that + // blacklisted strings prevails over whitelisted ones. + // If this field is not specified, no strings are excluded. + Blacklist []string `protobuf:"bytes,2,rep,name=blacklist,proto3" json:"blacklist,omitempty" yaml:"blacklist"` +} + +func (m *Filter) Reset() { *m = Filter{} } +func (m *Filter) String() string { return proto.CompactTextString(m) } +func (*Filter) ProtoMessage() {} +func (*Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_3af0daa241de0fa3, []int{2} +} +func (m *Filter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Filter.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Filter.Merge(m, src) +} +func (m *Filter) XXX_Size() int { + return m.Size() +} +func (m *Filter) XXX_DiscardUnknown() { + xxx_messageInfo_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_Filter proto.InternalMessageInfo + +func (m *Filter) GetWhitelist() []string { + if m != nil { + return m.Whitelist + } + return nil +} + +func (m *Filter) GetBlacklist() []string { + if m != nil { + return m.Blacklist + } + return nil +} + // Interpreter defines the various parameters for the interpreter. type Interpreter struct { - // predicates_whitelist specifies a list of prolog predicates that are allowed and can be used by the interpreter. - // The predicates are represented as `/[]`, for example: `findall/3`, or `call`. If a predicate name without arity - // is included in this list, then all predicates with that name will be considered regardless of arity. For example, if `call` is included - // in the whitelist, then all predicates `call/1`, `call/2`, `call/3`... will be allowed. - // If this field is not specified, the interpreter will use the default set of predicates. - PredicatesWhitelist []string `protobuf:"bytes,1,rep,name=predicates_whitelist,json=predicatesWhitelist,proto3" json:"predicates_whitelist,omitempty" yaml:"predicates_whitelist"` - // predicates_blacklist specifies a list of prolog predicates that are excluded from the set of registered predicates - // and can never be executed by the interpreter. - // The predicates are represented as `/[]`, for example: `findall/3`, or `call`. If a predicate name without arity - // is included in this list, then all predicates with that name will be considered regardless of arity. For example, if `call` is included - // in the blacklist, then all predicates `call/1`, `call/2`, `call/3`... will be excluded. - // If a predicate is included in both whitelist and blacklist, it will be excluded. This means that blacklisted predicates prevails - // on whitelisted predicates. - PredicatesBlacklist []string `protobuf:"bytes,2,rep,name=predicates_blacklist,json=predicatesBlacklist,proto3" json:"predicates_blacklist,omitempty" yaml:"predicates_blacklist"` + // predicates_filter specifies the filter for the predicates that are allowed to be used by the interpreter. + // The filter is used to whitelist or blacklist predicates represented as `/[]`, for example: + // `findall/3`, or `call`. If a predicate name without arity is included in the filter, then all predicates with that + // name will be considered regardless of arity. For example, if `call` is included in the filter, then all predicates + // `call/1`, `call/2`, `call/3`... will be allowed. + PredicatesFilter Filter `protobuf:"bytes,1,opt,name=predicates_filter,json=predicatesFilter,proto3" json:"predicates_filter" yaml:"predicates_filter"` // bootstrap specifies the initial program to run when booting the logic interpreter. // If not specified, the default boot sequence will be executed. Bootstrap string `protobuf:"bytes,3,opt,name=bootstrap,proto3" json:"bootstrap,omitempty" yaml:"bootstrap"` @@ -166,7 +218,7 @@ func (m *Interpreter) Reset() { *m = Interpreter{} } func (m *Interpreter) String() string { return proto.CompactTextString(m) } func (*Interpreter) ProtoMessage() {} func (*Interpreter) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{2} + return fileDescriptor_3af0daa241de0fa3, []int{3} } func (m *Interpreter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -195,18 +247,11 @@ func (m *Interpreter) XXX_DiscardUnknown() { var xxx_messageInfo_Interpreter proto.InternalMessageInfo -func (m *Interpreter) GetPredicatesWhitelist() []string { +func (m *Interpreter) GetPredicatesFilter() Filter { if m != nil { - return m.PredicatesWhitelist + return m.PredicatesFilter } - return nil -} - -func (m *Interpreter) GetPredicatesBlacklist() []string { - if m != nil { - return m.PredicatesBlacklist - } - return nil + return Filter{} } func (m *Interpreter) GetBootstrap() string { @@ -235,7 +280,7 @@ func (m *GasPolicy) Reset() { *m = GasPolicy{} } func (m *GasPolicy) String() string { return proto.CompactTextString(m) } func (*GasPolicy) ProtoMessage() {} func (*GasPolicy) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{3} + return fileDescriptor_3af0daa241de0fa3, []int{4} } func (m *GasPolicy) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -284,7 +329,7 @@ func (m *PredicateCost) Reset() { *m = PredicateCost{} } func (m *PredicateCost) String() string { return proto.CompactTextString(m) } func (*PredicateCost) ProtoMessage() {} func (*PredicateCost) Descriptor() ([]byte, []int) { - return fileDescriptor_3af0daa241de0fa3, []int{4} + return fileDescriptor_3af0daa241de0fa3, []int{5} } func (m *PredicateCost) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -323,6 +368,7 @@ func (m *PredicateCost) GetPredicate() string { func init() { proto.RegisterType((*Params)(nil), "logic.v1beta2.Params") proto.RegisterType((*Limits)(nil), "logic.v1beta2.Limits") + proto.RegisterType((*Filter)(nil), "logic.v1beta2.Filter") proto.RegisterType((*Interpreter)(nil), "logic.v1beta2.Interpreter") proto.RegisterType((*GasPolicy)(nil), "logic.v1beta2.GasPolicy") proto.RegisterType((*PredicateCost)(nil), "logic.v1beta2.PredicateCost") @@ -331,51 +377,53 @@ func init() { func init() { proto.RegisterFile("logic/v1beta2/params.proto", fileDescriptor_3af0daa241de0fa3) } var fileDescriptor_3af0daa241de0fa3 = []byte{ - // 702 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00,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0x3c, 0x86, 0xcd, 0xe9, 0xd3, 0x97, - 0xa3, 0xf4, 0xf3, 0xb1, 0x08, 0x97, 0x75, 0xa1, 0x39, 0xd6, 0xb7, 0xb8, 0x90, 0xb0, 0x03, 0xe6, - 0x27, 0x8d, 0xc2, 0x2a, 0xac, 0x14, 0xd6, 0x4a, 0xeb, 0xd7, 0x33, 0xf7, 0xc6, 0x44, 0x9b, 0xbd, - 0xac, 0xef, 0x8e, 0xa5, 0xcc, 0xc3, 0xd3, 0x59, 0x73, 0x7e, 0xda, 0x2d, 0xd0, 0x37, 0x03, 0xcc, - 0x4e, 0xe6, 0x6e, 0x00, 0x33, 0xf6, 0xe8, 0x03, 0xcf, 0x3c, 0xc3, 0xb8, 0x8c, 0x70, 0x62, 0x85, - 0x6f, 0xc1, 0x4c, 0xea, 0x94, 0x1e, 0x4e, 0x7f, 0x4a, 0x7a, 0xc5, 0x6a, 0x9d, 0xa9, 0x7b, 0x47, - 0x51, 0xed, 0x7b, 0x47, 0x27, 0x55, 0xe3, 0xf8, 0xa4, 0x6a, 0xfc, 0x3a, 0xa9, 0x1a, 0x9f, 0x4f, - 0xab, 0xb9, 0xe3, 0xd3, 0x6a, 0xee, 0xc7, 0x69, 0x35, 0xf7, 0x66, 0x35, 0x95, 0xc0, 0xf7, 0xfd, - 0xbb, 0xea, 0xa3, 0xd3, 0x18, 0x34, 0xa2, 0xd7, 0x8b, 0x8a, 0x68, 0x17, 0xd5, 0x1b, 0xe3, 0xce, - 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x56, 0x08, 0x95, 0x74, 0x06, 0x00, 0x00, + // 731 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x6e, 0xd3, 0x4a, + 0x14, 0x8e, 0x93, 0x2a, 0xf7, 0x7a, 0xa2, 0xb6, 0xe9, 0xa8, 0xbd, 0xd7, 0x37,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5c, 0xc9, 0xf9, 0xba, 0x0e, 0x17, 0xd3, 0xb1, 0xed, 0xcc, 0xef, 0xbe, 0x1e, 0xbb, + 0x5f, 0x2d, 0x8b, 0xf0, 0xaa, 0x06, 0x3a, 0xd3, 0xf8, 0x0e, 0x17, 0x12, 0xf6, 0xc1, 0xf2, 0x6c, + 0xa2, 0xb0, 0x4a, 0xcd, 0xd2, 0x46, 0x65, 0xf3, 0x5a, 0xee, 0xbe, 0x66, 0x68, 0xf6, 0xba, 0xbe, + 0xb6, 0xb5, 0xdc, 0xb5, 0x69, 0xaf, 0xa5, 0x20, 0x9b, 0x2d, 0xd0, 0x67, 0x03, 0x2c, 0xce, 0xfa, + 0x6e, 0x01, 0x33, 0xc9, 0xd1, 0x0d, 0xcf, 0xdd, 0x61, 0x02, 0x23, 0x9c, 0xa6, 0xc2, 0x57, 0x60, + 0x21, 0xd3, 0xa5, 0x07, 0xf3, 0x77, 0x49, 0x57, 0xac, 0xea, 0xcc, 0xbc, 0xa7, 0x94, 0xaa, 0x7d, + 0xef, 0xf4, 0xbc, 0x6e, 0x9c, 0x9d, 0xd7, 0x8d, 0x1f, 0xe7, 0x75, 0xe3, 0xc3, 0x45, 0xbd, 0x70, + 0x76, 0x51, 0x2f, 0x7c, 0xbb, 0xa8, 0x17, 0x5e, 0x5e, 0xcf, 0x38, 0xf0, 0xa3, 0xe0, 0xae, 0xfa, + 0xe9, 0xb7, 0x47, 0xed, 0xf8, 0x73, 0xa4, 0x2c, 0x7a, 0x65, 0xf5, 0x85, 0xb9, 0xf3, 0x2b, 0x00, + 0x00, 0xff, 0xff, 0x8e, 0x84, 0x11, 0xfb, 0xa4, 0x06, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -502,6 +550,47 @@ func (m *Limits) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Filter) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Filter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Filter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Blacklist) > 0 { + for iNdEx := len(m.Blacklist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Blacklist[iNdEx]) + copy(dAtA[i:], m.Blacklist[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.Blacklist[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Whitelist) > 0 { + for iNdEx := len(m.Whitelist) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Whitelist[iNdEx]) + copy(dAtA[i:], m.Whitelist[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.Whitelist[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *Interpreter) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -529,24 +618,16 @@ func (m *Interpreter) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.PredicatesBlacklist) > 0 { - for iNdEx := len(m.PredicatesBlacklist) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.PredicatesBlacklist[iNdEx]) - copy(dAtA[i:], m.PredicatesBlacklist[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.PredicatesBlacklist[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.PredicatesWhitelist) > 0 { - for iNdEx := len(m.PredicatesWhitelist) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.PredicatesWhitelist[iNdEx]) - copy(dAtA[i:], m.PredicatesWhitelist[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.PredicatesWhitelist[iNdEx]))) - i-- - dAtA[i] = 0xa + { + size, err := m.PredicatesFilter.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -704,24 +785,35 @@ func (m *Limits) Size() (n int) { return n } -func (m *Interpreter) Size() (n int) { +func (m *Filter) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.PredicatesWhitelist) > 0 { - for _, s := range m.PredicatesWhitelist { + if len(m.Whitelist) > 0 { + for _, s := range m.Whitelist { l = len(s) n += 1 + l + sovParams(uint64(l)) } } - if len(m.PredicatesBlacklist) > 0 { - for _, s := range m.PredicatesBlacklist { + if len(m.Blacklist) > 0 { + for _, s := range m.Blacklist { l = len(s) n += 1 + l + sovParams(uint64(l)) } } + return n +} + +func (m *Interpreter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PredicatesFilter.Size() + n += 1 + l + sovParams(uint64(l)) l = len(m.Bootstrap) if l > 0 { n += 1 + l + sovParams(uint64(l)) @@ -1118,7 +1210,7 @@ func (m *Limits) Unmarshal(dAtA []byte) error { } return nil } -func (m *Interpreter) Unmarshal(dAtA []byte) error { +func (m *Filter) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1141,15 +1233,15 @@ func (m *Interpreter) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Interpreter: wiretype end group for non-group") + return fmt.Errorf("proto: Filter: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Interpreter: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Filter: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PredicatesWhitelist", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1177,11 +1269,11 @@ func (m *Interpreter) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PredicatesWhitelist = append(m.PredicatesWhitelist, string(dAtA[iNdEx:postIndex])) + m.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PredicatesBlacklist", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blacklist", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1209,7 +1301,90 @@ func (m *Interpreter) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PredicatesBlacklist = append(m.PredicatesBlacklist, string(dAtA[iNdEx:postIndex])) + m.Blacklist = append(m.Blacklist, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Interpreter) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Interpreter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Interpreter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PredicatesFilter", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PredicatesFilter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 3: if wireType != 2 {