Remove proto/sharding and move slashing to own dir (#4332)

* Clean proto and move slasher proto to own folder

* Change package name to match files

* Fix typo

* Fix tests

* Undo out of scope changes

* Run gazlle

* Fix build.bazel

* goimports
This commit is contained in:
Ivan Martinez 2019-12-20 22:47:00 -05:00 committed by Raul Jordan
parent a949673e33
commit ec1e7ae005
21 changed files with 747 additions and 3669 deletions

View File

@ -5,25 +5,25 @@ This package defines common protobuf messages and services used by Ethereum Sere
```
proto/
beacon/
db/
p2p/
v1/
rpc/
v1/
sharding/
p2p/
v1/
cluster/
slashing/
testing/
```
We specify messages available for p2p communication common to beacon chain nodes and sharding clients.
For now, we are checking in all generated code to support native go dependency
management. The generated pb.go files can be derived from bazel's bin
management. The generated pb.go files can be derived from bazel's bin
directory.
For example, when we build the testing go proto library
`bazel build //proto/testing:ethereum_testing_go_proto` there is a pb.go
generated at
For example, when we build the testing go proto library
`bazel build //proto/testing:ethereum_testing_go_proto` there is a pb.go
generated at
`bazel-bin/proto/testing/linux_amd64_stripped/ethereum_testing_go_proto\~/github.com/prysmaticlabs/prysm/proto/testing/test.pb.go`.
This generated file can be copied, or you can use you protoc locally if you
prefer.

View File

@ -5,10 +5,11 @@ package db
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
v1alpha1 "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
io "io"
math "math"
proto "github.com/gogo/protobuf/proto"
v1alpha1 "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
)
// Reference imports to suppress errors if they are not otherwise used.

View File

@ -12,7 +12,6 @@ go_proto_library(
visibility = ["//visibility:public"],
deps = [
"//proto/beacon/p2p/v1:go_default_library",
"//proto/sharding/p2p/v1:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@go_googleapis//google/api:annotations_go_proto",
"@grpc_ecosystem_grpc_gateway//protoc-gen-swagger/options:options_go_proto",
@ -30,7 +29,6 @@ go_proto_library(
visibility = ["//visibility:public"],
deps = [
"//proto/beacon/p2p/v1:go_default_library",
"//proto/sharding/p2p/v1:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@go_googleapis//google/api:annotations_go_proto",
"@grpc_ecosystem_grpc_gateway//protoc-gen-swagger/options:options_go_proto",
@ -48,16 +46,15 @@ proto_library(
name = "v1_proto",
srcs = [
"services.proto",
"slasher.proto",
],
visibility = ["//visibility:public"],
deps = [
"//proto/beacon/p2p/v1:v1_proto",
"//proto/sharding/p2p/v1:v1_proto",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:timestamp_proto",
"@go_googleapis//google/api:annotations_proto",
"@gogo_special_proto//github.com/gogo/protobuf/gogoproto",
"@grpc_ecosystem_grpc_gateway//protoc-gen-swagger/options:options_proto",
],
)

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
# gazelle:ignore
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
go_proto_library(
name = "v1_go_proto",
compiler = "//:proto_compiler",
importpath = "github.com/prysmaticlabs/prysm/proto/sharding/p2p/v1",
proto = ":v1_proto",
visibility = ["//visibility:public"],
deps = ["//proto/beacon/p2p/v1:go_default_library"],
)
go_library(
name = "go_default_library",
embed = [":v1_go_proto"],
importpath = "github.com/prysmaticlabs/prysm/proto/sharding/p2p/v1",
visibility = ["//visibility:public"],
)
proto_library(
name = "v1_proto",
srcs = ["messages.proto"],
visibility = ["//visibility:public"],
deps = ["//proto/beacon/p2p/v1:v1_proto"],
)

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +0,0 @@
syntax = "proto3";
package ethereum.sharding.p2p.v1;
enum Topic {
UNKNOWN = 0;
COLLATION_BODY_REQUEST = 1;
COLLATION_BODY_RESPONSE = 2;
TRANSACTIONS = 3;
}
message CollationBodyRequest {
uint64 shard_id = 1;
uint64 period = 2;
bytes chunk_root = 3;
bytes proposer_address = 4;
bytes signature = 5;
}
message CollationBodyResponse {
bytes header_hash = 1;
bytes body = 2;
}
message Transaction {
uint64 nonce = 1;
uint64 gas_price = 2;
uint64 gas_limit = 3;
bytes recipient = 4;
uint64 value = 5;
bytes input = 6;
Signature signature = 7;
}
message Signature {
uint64 v = 1;
uint64 r = 2;
uint64 s = 3;
}

View File

@ -0,0 +1,33 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
# gazelle:ignore
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "ethereum_slashing_proto",
srcs = ["slashing.proto"],
visibility = ["//visibility:public"],
deps = [
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:proto",
"@com_google_protobuf//:empty_proto",
],
)
go_proto_library(
name = "ethereum_slashing_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/prysmaticlabs/prysm/proto/slashing",
proto = ":ethereum_slashing_proto",
visibility = ["//visibility:public"],
deps = [
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
],
)
go_library(
name = "go_default_library",
embed = [":ethereum_slashing_go_proto"],
importpath = "github.com/prysmaticlabs/prysm/proto/slashing",
visibility = ["//visibility:public"],
)

630
proto/slashing/slashing.pb.go generated Normal file
View File

@ -0,0 +1,630 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto/slashing/slashing.proto
package ethereum_slashing
import (
context "context"
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
empty "github.com/golang/protobuf/ptypes/empty"
v1alpha1 "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type ValidatorIDToIdxAtt struct {
Indices []uint64 `protobuf:"varint,1,rep,packed,name=indices,proto3" json:"indices,omitempty"`
DataRoot []byte `protobuf:"bytes,2,opt,name=data_root,json=dataRoot,proto3" json:"data_root,omitempty"`
Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ValidatorIDToIdxAtt) Reset() { *m = ValidatorIDToIdxAtt{} }
func (m *ValidatorIDToIdxAtt) String() string { return proto.CompactTextString(m) }
func (*ValidatorIDToIdxAtt) ProtoMessage() {}
func (*ValidatorIDToIdxAtt) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{0}
}
func (m *ValidatorIDToIdxAtt) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ValidatorIDToIdxAtt.Unmarshal(m, b)
}
func (m *ValidatorIDToIdxAtt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ValidatorIDToIdxAtt.Marshal(b, m, deterministic)
}
func (m *ValidatorIDToIdxAtt) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValidatorIDToIdxAtt.Merge(m, src)
}
func (m *ValidatorIDToIdxAtt) XXX_Size() int {
return xxx_messageInfo_ValidatorIDToIdxAtt.Size(m)
}
func (m *ValidatorIDToIdxAtt) XXX_DiscardUnknown() {
xxx_messageInfo_ValidatorIDToIdxAtt.DiscardUnknown(m)
}
var xxx_messageInfo_ValidatorIDToIdxAtt proto.InternalMessageInfo
func (m *ValidatorIDToIdxAtt) GetIndices() []uint64 {
if m != nil {
return m.Indices
}
return nil
}
func (m *ValidatorIDToIdxAtt) GetDataRoot() []byte {
if m != nil {
return m.DataRoot
}
return nil
}
func (m *ValidatorIDToIdxAtt) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
type ValidatorIDToIdxAttList struct {
IndicesList []*ValidatorIDToIdxAtt `protobuf:"bytes,1,rep,name=indicesList,proto3" json:"indicesList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ValidatorIDToIdxAttList) Reset() { *m = ValidatorIDToIdxAttList{} }
func (m *ValidatorIDToIdxAttList) String() string { return proto.CompactTextString(m) }
func (*ValidatorIDToIdxAttList) ProtoMessage() {}
func (*ValidatorIDToIdxAttList) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{1}
}
func (m *ValidatorIDToIdxAttList) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ValidatorIDToIdxAttList.Unmarshal(m, b)
}
func (m *ValidatorIDToIdxAttList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ValidatorIDToIdxAttList.Marshal(b, m, deterministic)
}
func (m *ValidatorIDToIdxAttList) XXX_Merge(src proto.Message) {
xxx_messageInfo_ValidatorIDToIdxAttList.Merge(m, src)
}
func (m *ValidatorIDToIdxAttList) XXX_Size() int {
return xxx_messageInfo_ValidatorIDToIdxAttList.Size(m)
}
func (m *ValidatorIDToIdxAttList) XXX_DiscardUnknown() {
xxx_messageInfo_ValidatorIDToIdxAttList.DiscardUnknown(m)
}
var xxx_messageInfo_ValidatorIDToIdxAttList proto.InternalMessageInfo
func (m *ValidatorIDToIdxAttList) GetIndicesList() []*ValidatorIDToIdxAtt {
if m != nil {
return m.IndicesList
}
return nil
}
type ProposerSlashingRequest struct {
BlockHeader *v1alpha1.BeaconBlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"`
ValidatorIndex uint64 `protobuf:"varint,2,opt,name=validator_index,json=validatorIndex,proto3" json:"validator_index,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ProposerSlashingRequest) Reset() { *m = ProposerSlashingRequest{} }
func (m *ProposerSlashingRequest) String() string { return proto.CompactTextString(m) }
func (*ProposerSlashingRequest) ProtoMessage() {}
func (*ProposerSlashingRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{2}
}
func (m *ProposerSlashingRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ProposerSlashingRequest.Unmarshal(m, b)
}
func (m *ProposerSlashingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ProposerSlashingRequest.Marshal(b, m, deterministic)
}
func (m *ProposerSlashingRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ProposerSlashingRequest.Merge(m, src)
}
func (m *ProposerSlashingRequest) XXX_Size() int {
return xxx_messageInfo_ProposerSlashingRequest.Size(m)
}
func (m *ProposerSlashingRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ProposerSlashingRequest.DiscardUnknown(m)
}
var xxx_messageInfo_ProposerSlashingRequest proto.InternalMessageInfo
func (m *ProposerSlashingRequest) GetBlockHeader() *v1alpha1.BeaconBlockHeader {
if m != nil {
return m.BlockHeader
}
return nil
}
func (m *ProposerSlashingRequest) GetValidatorIndex() uint64 {
if m != nil {
return m.ValidatorIndex
}
return 0
}
type ProposerSlashingResponse struct {
ProposerSlashing []*v1alpha1.ProposerSlashing `protobuf:"bytes,1,rep,name=proposer_slashing,json=proposerSlashing,proto3" json:"proposer_slashing,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ProposerSlashingResponse) Reset() { *m = ProposerSlashingResponse{} }
func (m *ProposerSlashingResponse) String() string { return proto.CompactTextString(m) }
func (*ProposerSlashingResponse) ProtoMessage() {}
func (*ProposerSlashingResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{3}
}
func (m *ProposerSlashingResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ProposerSlashingResponse.Unmarshal(m, b)
}
func (m *ProposerSlashingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ProposerSlashingResponse.Marshal(b, m, deterministic)
}
func (m *ProposerSlashingResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ProposerSlashingResponse.Merge(m, src)
}
func (m *ProposerSlashingResponse) XXX_Size() int {
return xxx_messageInfo_ProposerSlashingResponse.Size(m)
}
func (m *ProposerSlashingResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ProposerSlashingResponse.DiscardUnknown(m)
}
var xxx_messageInfo_ProposerSlashingResponse proto.InternalMessageInfo
func (m *ProposerSlashingResponse) GetProposerSlashing() []*v1alpha1.ProposerSlashing {
if m != nil {
return m.ProposerSlashing
}
return nil
}
type AttesterSlashingResponse struct {
AttesterSlashing []*v1alpha1.AttesterSlashing `protobuf:"bytes,1,rep,name=attester_slashing,json=attesterSlashing,proto3" json:"attester_slashing,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AttesterSlashingResponse) Reset() { *m = AttesterSlashingResponse{} }
func (m *AttesterSlashingResponse) String() string { return proto.CompactTextString(m) }
func (*AttesterSlashingResponse) ProtoMessage() {}
func (*AttesterSlashingResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{4}
}
func (m *AttesterSlashingResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AttesterSlashingResponse.Unmarshal(m, b)
}
func (m *AttesterSlashingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AttesterSlashingResponse.Marshal(b, m, deterministic)
}
func (m *AttesterSlashingResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_AttesterSlashingResponse.Merge(m, src)
}
func (m *AttesterSlashingResponse) XXX_Size() int {
return xxx_messageInfo_AttesterSlashingResponse.Size(m)
}
func (m *AttesterSlashingResponse) XXX_DiscardUnknown() {
xxx_messageInfo_AttesterSlashingResponse.DiscardUnknown(m)
}
var xxx_messageInfo_AttesterSlashingResponse proto.InternalMessageInfo
func (m *AttesterSlashingResponse) GetAttesterSlashing() []*v1alpha1.AttesterSlashing {
if m != nil {
return m.AttesterSlashing
}
return nil
}
type MinMaxEpochSpan struct {
MinEpochSpan uint32 `protobuf:"varint,1,opt,name=min_epoch_span,json=minEpochSpan,proto3" json:"min_epoch_span,omitempty"`
MaxEpochSpan uint32 `protobuf:"varint,2,opt,name=max_epoch_span,json=maxEpochSpan,proto3" json:"max_epoch_span,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *MinMaxEpochSpan) Reset() { *m = MinMaxEpochSpan{} }
func (m *MinMaxEpochSpan) String() string { return proto.CompactTextString(m) }
func (*MinMaxEpochSpan) ProtoMessage() {}
func (*MinMaxEpochSpan) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{5}
}
func (m *MinMaxEpochSpan) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MinMaxEpochSpan.Unmarshal(m, b)
}
func (m *MinMaxEpochSpan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_MinMaxEpochSpan.Marshal(b, m, deterministic)
}
func (m *MinMaxEpochSpan) XXX_Merge(src proto.Message) {
xxx_messageInfo_MinMaxEpochSpan.Merge(m, src)
}
func (m *MinMaxEpochSpan) XXX_Size() int {
return xxx_messageInfo_MinMaxEpochSpan.Size(m)
}
func (m *MinMaxEpochSpan) XXX_DiscardUnknown() {
xxx_messageInfo_MinMaxEpochSpan.DiscardUnknown(m)
}
var xxx_messageInfo_MinMaxEpochSpan proto.InternalMessageInfo
func (m *MinMaxEpochSpan) GetMinEpochSpan() uint32 {
if m != nil {
return m.MinEpochSpan
}
return 0
}
func (m *MinMaxEpochSpan) GetMaxEpochSpan() uint32 {
if m != nil {
return m.MaxEpochSpan
}
return 0
}
type EpochSpanMap struct {
EpochSpanMap map[uint64]*MinMaxEpochSpan `protobuf:"bytes,1,rep,name=epoch_span_map,json=epochSpanMap,proto3" json:"epoch_span_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EpochSpanMap) Reset() { *m = EpochSpanMap{} }
func (m *EpochSpanMap) String() string { return proto.CompactTextString(m) }
func (*EpochSpanMap) ProtoMessage() {}
func (*EpochSpanMap) Descriptor() ([]byte, []int) {
return fileDescriptor_da7e95107d0081b4, []int{6}
}
func (m *EpochSpanMap) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EpochSpanMap.Unmarshal(m, b)
}
func (m *EpochSpanMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EpochSpanMap.Marshal(b, m, deterministic)
}
func (m *EpochSpanMap) XXX_Merge(src proto.Message) {
xxx_messageInfo_EpochSpanMap.Merge(m, src)
}
func (m *EpochSpanMap) XXX_Size() int {
return xxx_messageInfo_EpochSpanMap.Size(m)
}
func (m *EpochSpanMap) XXX_DiscardUnknown() {
xxx_messageInfo_EpochSpanMap.DiscardUnknown(m)
}
var xxx_messageInfo_EpochSpanMap proto.InternalMessageInfo
func (m *EpochSpanMap) GetEpochSpanMap() map[uint64]*MinMaxEpochSpan {
if m != nil {
return m.EpochSpanMap
}
return nil
}
func init() {
proto.RegisterType((*ValidatorIDToIdxAtt)(nil), "ethereum.slashing.ValidatorIDToIdxAtt")
proto.RegisterType((*ValidatorIDToIdxAttList)(nil), "ethereum.slashing.ValidatorIDToIdxAttList")
proto.RegisterType((*ProposerSlashingRequest)(nil), "ethereum.slashing.ProposerSlashingRequest")
proto.RegisterType((*ProposerSlashingResponse)(nil), "ethereum.slashing.ProposerSlashingResponse")
proto.RegisterType((*AttesterSlashingResponse)(nil), "ethereum.slashing.AttesterSlashingResponse")
proto.RegisterType((*MinMaxEpochSpan)(nil), "ethereum.slashing.MinMaxEpochSpan")
proto.RegisterType((*EpochSpanMap)(nil), "ethereum.slashing.EpochSpanMap")
proto.RegisterMapType((map[uint64]*MinMaxEpochSpan)(nil), "ethereum.slashing.EpochSpanMap.EpochSpanMapEntry")
}
func init() { proto.RegisterFile("proto/slashing/slashing.proto", fileDescriptor_da7e95107d0081b4) }
var fileDescriptor_da7e95107d0081b4 = []byte{
// 583 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xd1, 0x6e, 0xd3, 0x4a,
0x10, 0x95, 0x9b, 0xde, 0x5b, 0x3a, 0x09, 0x6d, 0xba, 0x88, 0xd6, 0x4a, 0x41, 0x54, 0x16, 0xa2,
0x01, 0x24, 0xa7, 0x0d, 0x2f, 0x15, 0x6f, 0xad, 0x88, 0xd4, 0x08, 0x22, 0x21, 0xb7, 0xa2, 0x12,
0x12, 0xb2, 0xd6, 0xf6, 0x10, 0x9b, 0x38, 0xbb, 0x8b, 0x77, 0x13, 0x25, 0x5f, 0xc1, 0x17, 0xf0,
0x47, 0x7c, 0x14, 0xf2, 0xda, 0x4e, 0xdc, 0xc4, 0x91, 0xca, 0x9b, 0xe7, 0xcc, 0x99, 0x39, 0x33,
0x27, 0x93, 0x85, 0xe7, 0x22, 0xe1, 0x8a, 0x77, 0x64, 0x4c, 0x65, 0x18, 0xb1, 0xe1, 0xe2, 0xc3,
0xd6, 0x38, 0x39, 0x40, 0x15, 0x62, 0x82, 0x93, 0xb1, 0x5d, 0x24, 0x5a, 0xc7, 0x43, 0xce, 0x87,
0x31, 0x76, 0x34, 0xc1, 0x9b, 0x7c, 0xef, 0xe0, 0x58, 0xa8, 0x79, 0xc6, 0x6f, 0xbd, 0x40, 0x15,
0x76, 0xa6, 0xe7, 0x34, 0x16, 0x21, 0x3d, 0xef, 0x78, 0x48, 0x7d, 0xce, 0x5c, 0x2f, 0xe6, 0xfe,
0x28, 0x23, 0x58, 0x3f, 0xe0, 0xc9, 0x17, 0x1a, 0x47, 0x01, 0x55, 0x3c, 0xe9, 0x7f, 0xb8, 0xe5,
0xfd, 0x60, 0x76, 0xa9, 0x14, 0x31, 0x61, 0x27, 0x62, 0x41, 0xe4, 0xa3, 0x34, 0x8d, 0x93, 0x5a,
0x7b, 0xdb, 0x29, 0x42, 0x72, 0x0c, 0xbb, 0x01, 0x55, 0xd4, 0x4d, 0x38, 0x57, 0xe6, 0xd6, 0x89,
0xd1, 0x6e, 0x38, 0x8f, 0x52, 0xc0, 0xe1, 0x5c, 0x91, 0x67, 0xb0, 0x2b, 0xa3, 0x21, 0xa3, 0x6a,
0x92, 0xa0, 0x59, 0xd3, 0xc9, 0x25, 0x60, 0xf9, 0x70, 0x54, 0xa1, 0xf5, 0x29, 0x92, 0x8a, 0x5c,
0x43, 0x3d, 0x17, 0x48, 0x43, 0xad, 0x59, 0xef, 0xbe, 0xb2, 0xd7, 0xb6, 0xb5, 0x2b, 0x1a, 0x38,
0xe5, 0x52, 0xeb, 0x97, 0x01, 0x47, 0x9f, 0x13, 0x2e, 0xb8, 0xc4, 0xe4, 0x26, 0xaf, 0x72, 0xf0,
0xe7, 0x04, 0xa5, 0x22, 0x1f, 0xa1, 0xa1, 0x77, 0x77, 0x43, 0xa4, 0x01, 0x26, 0xa6, 0x71, 0x62,
0xb4, 0xeb, 0xdd, 0xf6, 0x52, 0x06, 0x55, 0x68, 0x17, 0x6e, 0xd9, 0x57, 0xda, 0xad, 0xab, 0xb4,
0xe0, 0x5a, 0xf3, 0x9d, 0xba, 0xb7, 0x0c, 0xc8, 0x29, 0xec, 0x4f, 0x8b, 0x61, 0xdc, 0x88, 0x05,
0x38, 0xd3, 0x76, 0x6c, 0x3b, 0x7b, 0x0b, 0xb8, 0x9f, 0xa2, 0x96, 0x00, 0x73, 0x7d, 0x20, 0x29,
0x38, 0x93, 0x48, 0x6e, 0xe1, 0x40, 0xe4, 0x39, 0xb7, 0xd8, 0x31, 0xdf, 0xfe, 0x74, 0xc3, 0x58,
0x6b, 0xbd, 0x9a, 0x62, 0x05, 0x49, 0x15, 0x2f, 0x95, 0x42, 0xa9, 0xaa, 0x15, 0x69, 0x9e, 0x7b,
0xa8, 0xe2, 0x5a, 0xaf, 0x26, 0x5d, 0x41, 0xac, 0x6f, 0xb0, 0x3f, 0x88, 0xd8, 0x80, 0xce, 0x7a,
0x82, 0xfb, 0xe1, 0x8d, 0xa0, 0x8c, 0xbc, 0x84, 0xbd, 0x71, 0xc4, 0x5c, 0x4c, 0x01, 0x57, 0x0a,
0xca, 0xb4, 0xdd, 0x8f, 0x9d, 0xc6, 0x38, 0x62, 0xf7, 0x59, 0x74, 0x56, 0x66, 0x6d, 0xe5, 0xac,
0x52, 0x2f, 0xeb, 0x8f, 0x01, 0x8d, 0x45, 0x34, 0xa0, 0x82, 0xdc, 0xc1, 0xde, 0xb2, 0xc4, 0x1d,
0x53, 0x91, 0xaf, 0x70, 0x5e, 0x71, 0x32, 0xe5, 0xc2, 0x7b, 0x41, 0x8f, 0xa9, 0x64, 0xee, 0x34,
0xb0, 0x04, 0xb5, 0x7c, 0x38, 0x58, 0xa3, 0x90, 0x26, 0xd4, 0x46, 0x38, 0xd7, 0xf3, 0x6f, 0x3b,
0xe9, 0x27, 0xb9, 0x80, 0xff, 0xa6, 0x34, 0x9e, 0xa0, 0x9e, 0xb6, 0xde, 0xb5, 0x2a, 0x64, 0x57,
0xfc, 0x70, 0xb2, 0x82, 0xf7, 0x5b, 0x17, 0x46, 0xf7, 0x77, 0x0d, 0x76, 0xb4, 0x75, 0x98, 0x10,
0x01, 0x87, 0x7d, 0xa9, 0x03, 0xea, 0xc5, 0x98, 0x59, 0x4d, 0x55, 0xc4, 0x19, 0x79, 0xbd, 0xe1,
0xe7, 0xd0, 0x57, 0x85, 0x41, 0x89, 0xda, 0x7a, 0x5b, 0xa1, 0xbf, 0xf1, 0x02, 0x46, 0xd0, 0x2c,
0x29, 0xea, 0xfb, 0x26, 0x6f, 0x2a, 0x1a, 0x6c, 0xf8, 0x17, 0x55, 0x8a, 0x6d, 0x3c, 0xf0, 0x3b,
0x20, 0x0b, 0xa9, 0x8c, 0x44, 0x63, 0x49, 0x0e, 0xed, 0xec, 0xd1, 0xb2, 0x8b, 0x47, 0xcb, 0xee,
0xa5, 0x8f, 0x56, 0xeb, 0xa1, 0x37, 0x7f, 0x66, 0x90, 0xaf, 0xf0, 0xb4, 0xca, 0xb5, 0x7f, 0xef,
0xbd, 0xea, 0xd3, 0x99, 0xe1, 0xfd, 0xaf, 0x4b, 0xdf, 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x52,
0xc8, 0x82, 0x62, 0x8d, 0x05, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// SlasherClient is the client API for Slasher service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type SlasherClient interface {
IsSlashableAttestation(ctx context.Context, in *v1alpha1.IndexedAttestation, opts ...grpc.CallOption) (*AttesterSlashingResponse, error)
IsSlashableBlock(ctx context.Context, in *ProposerSlashingRequest, opts ...grpc.CallOption) (*ProposerSlashingResponse, error)
SlashableProposals(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (Slasher_SlashableProposalsClient, error)
SlashableAttestations(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (Slasher_SlashableAttestationsClient, error)
}
type slasherClient struct {
cc *grpc.ClientConn
}
func NewSlasherClient(cc *grpc.ClientConn) SlasherClient {
return &slasherClient{cc}
}
func (c *slasherClient) IsSlashableAttestation(ctx context.Context, in *v1alpha1.IndexedAttestation, opts ...grpc.CallOption) (*AttesterSlashingResponse, error) {
out := new(AttesterSlashingResponse)
err := c.cc.Invoke(ctx, "/ethereum.slashing.Slasher/IsSlashableAttestation", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *slasherClient) IsSlashableBlock(ctx context.Context, in *ProposerSlashingRequest, opts ...grpc.CallOption) (*ProposerSlashingResponse, error) {
out := new(ProposerSlashingResponse)
err := c.cc.Invoke(ctx, "/ethereum.slashing.Slasher/IsSlashableBlock", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *slasherClient) SlashableProposals(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (Slasher_SlashableProposalsClient, error) {
stream, err := c.cc.NewStream(ctx, &_Slasher_serviceDesc.Streams[0], "/ethereum.slashing.Slasher/SlashableProposals", opts...)
if err != nil {
return nil, err
}
x := &slasherSlashableProposalsClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Slasher_SlashableProposalsClient interface {
Recv() (*v1alpha1.ProposerSlashing, error)
grpc.ClientStream
}
type slasherSlashableProposalsClient struct {
grpc.ClientStream
}
func (x *slasherSlashableProposalsClient) Recv() (*v1alpha1.ProposerSlashing, error) {
m := new(v1alpha1.ProposerSlashing)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *slasherClient) SlashableAttestations(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (Slasher_SlashableAttestationsClient, error) {
stream, err := c.cc.NewStream(ctx, &_Slasher_serviceDesc.Streams[1], "/ethereum.slashing.Slasher/SlashableAttestations", opts...)
if err != nil {
return nil, err
}
x := &slasherSlashableAttestationsClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type Slasher_SlashableAttestationsClient interface {
Recv() (*v1alpha1.AttesterSlashing, error)
grpc.ClientStream
}
type slasherSlashableAttestationsClient struct {
grpc.ClientStream
}
func (x *slasherSlashableAttestationsClient) Recv() (*v1alpha1.AttesterSlashing, error) {
m := new(v1alpha1.AttesterSlashing)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// SlasherServer is the server API for Slasher service.
type SlasherServer interface {
IsSlashableAttestation(context.Context, *v1alpha1.IndexedAttestation) (*AttesterSlashingResponse, error)
IsSlashableBlock(context.Context, *ProposerSlashingRequest) (*ProposerSlashingResponse, error)
SlashableProposals(*empty.Empty, Slasher_SlashableProposalsServer) error
SlashableAttestations(*empty.Empty, Slasher_SlashableAttestationsServer) error
}
// UnimplementedSlasherServer can be embedded to have forward compatible implementations.
type UnimplementedSlasherServer struct {
}
func (*UnimplementedSlasherServer) IsSlashableAttestation(ctx context.Context, req *v1alpha1.IndexedAttestation) (*AttesterSlashingResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method IsSlashableAttestation not implemented")
}
func (*UnimplementedSlasherServer) IsSlashableBlock(ctx context.Context, req *ProposerSlashingRequest) (*ProposerSlashingResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method IsSlashableBlock not implemented")
}
func (*UnimplementedSlasherServer) SlashableProposals(req *empty.Empty, srv Slasher_SlashableProposalsServer) error {
return status.Errorf(codes.Unimplemented, "method SlashableProposals not implemented")
}
func (*UnimplementedSlasherServer) SlashableAttestations(req *empty.Empty, srv Slasher_SlashableAttestationsServer) error {
return status.Errorf(codes.Unimplemented, "method SlashableAttestations not implemented")
}
func RegisterSlasherServer(s *grpc.Server, srv SlasherServer) {
s.RegisterService(&_Slasher_serviceDesc, srv)
}
func _Slasher_IsSlashableAttestation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(v1alpha1.IndexedAttestation)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SlasherServer).IsSlashableAttestation(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ethereum.slashing.Slasher/IsSlashableAttestation",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SlasherServer).IsSlashableAttestation(ctx, req.(*v1alpha1.IndexedAttestation))
}
return interceptor(ctx, in, info, handler)
}
func _Slasher_IsSlashableBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProposerSlashingRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SlasherServer).IsSlashableBlock(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ethereum.slashing.Slasher/IsSlashableBlock",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SlasherServer).IsSlashableBlock(ctx, req.(*ProposerSlashingRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Slasher_SlashableProposals_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(empty.Empty)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(SlasherServer).SlashableProposals(m, &slasherSlashableProposalsServer{stream})
}
type Slasher_SlashableProposalsServer interface {
Send(*v1alpha1.ProposerSlashing) error
grpc.ServerStream
}
type slasherSlashableProposalsServer struct {
grpc.ServerStream
}
func (x *slasherSlashableProposalsServer) Send(m *v1alpha1.ProposerSlashing) error {
return x.ServerStream.SendMsg(m)
}
func _Slasher_SlashableAttestations_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(empty.Empty)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(SlasherServer).SlashableAttestations(m, &slasherSlashableAttestationsServer{stream})
}
type Slasher_SlashableAttestationsServer interface {
Send(*v1alpha1.AttesterSlashing) error
grpc.ServerStream
}
type slasherSlashableAttestationsServer struct {
grpc.ServerStream
}
func (x *slasherSlashableAttestationsServer) Send(m *v1alpha1.AttesterSlashing) error {
return x.ServerStream.SendMsg(m)
}
var _Slasher_serviceDesc = grpc.ServiceDesc{
ServiceName: "ethereum.slashing.Slasher",
HandlerType: (*SlasherServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "IsSlashableAttestation",
Handler: _Slasher_IsSlashableAttestation_Handler,
},
{
MethodName: "IsSlashableBlock",
Handler: _Slasher_IsSlashableBlock_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "SlashableProposals",
Handler: _Slasher_SlashableProposals_Handler,
ServerStreams: true,
},
{
StreamName: "SlashableAttestations",
Handler: _Slasher_SlashableAttestations_Handler,
ServerStreams: true,
},
},
Metadata: "proto/slashing/slashing.proto",
}

View File

@ -1,28 +1,28 @@
syntax = "proto3";
package ethereum.beacon.rpc.v1;
package ethereum.slashing;
import "google/protobuf/empty.proto";
import "eth/v1alpha1/beacon_block.proto";
// Slasher service API
//
//
// Slasher service provides an interface for validators and beacon chain server to query
// and subscribe for slashable events on the network as well as to make sure that the
// attestation or proposal they are going to submit to the network are not going to
// and subscribe for slashable events on the network as well as to make sure that the
// attestation or proposal they are going to submit to the network are not going to
// produce a slashable event.
service Slasher {
// Gets AttesterSlashing container if the attestation that
// Gets AttesterSlashing container if the attestation that
// was received produces a slashable event.
rpc IsSlashableAttestation(ethereum.eth.v1alpha1.IndexedAttestation) returns (AttesterSlashingResponse);
// Gets ProposerSlashing container if the block header that
// Gets ProposerSlashing container if the block header that
// was received produces a slashable event.
rpc IsSlashableBlock(ProposerSlashingRequest) returns (ProposerSlashingResponse);
// Subscription to receive all slashable proposer slashing events found by the watchtower.
rpc SlashableProposals(google.protobuf.Empty) returns (stream ethereum.eth.v1alpha1.ProposerSlashing);
// Subscription to receive all slashable attester slashing events found by the watchtower.
rpc SlashableAttestations(google.protobuf.Empty) returns (stream ethereum.eth.v1alpha1.AttesterSlashing);
}

View File

@ -14,7 +14,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/slasher/db",
visibility = ["//slasher:__subpackages__"],
deps = [
"//proto/beacon/rpc/v1:go_default_library",
"//proto/slashing:go_default_library",
"//shared/bytesutil:go_default_library",
"//shared/params:go_default_library",
"@com_github_boltdb_bolt//:go_default_library",
@ -37,7 +37,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//proto/beacon/rpc/v1:go_default_library",
"//proto/slashing:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
],

View File

@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
)
@ -24,8 +24,8 @@ func createIndexedAttestation(enc []byte) (*ethpb.IndexedAttestation, error) {
return protoIdxAtt, nil
}
func createValidatorIDsToIndexedAttestationList(enc []byte) (*pb.ValidatorIDToIdxAttList, error) {
protoIdxAtt := &pb.ValidatorIDToIdxAttList{}
func createValidatorIDsToIndexedAttestationList(enc []byte) (*slashpb.ValidatorIDToIdxAttList, error) {
protoIdxAtt := &slashpb.ValidatorIDToIdxAttList{}
err := proto.Unmarshal(enc, protoIdxAtt)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal encoding")
@ -158,7 +158,7 @@ func createIndexedAttestationIndicesFromData(idxAttestation *ethpb.IndexedAttest
if err != nil {
return errors.Wrap(err, "failed to hash indexed attestation data.")
}
protoIdxAtt := &pb.ValidatorIDToIdxAtt{
protoIdxAtt := &slashpb.ValidatorIDToIdxAtt{
Signature: idxAttestation.Signature,
Indices: indices,
DataRoot: dataRoot[:],
@ -203,7 +203,7 @@ func (db *Store) DeleteIndexedAttestation(idxAttestation *ethpb.IndexedAttestati
func removeIndexedAttestationIndicesFromData(idxAttestation *ethpb.IndexedAttestation, tx *bolt.Tx) error {
indices := append(idxAttestation.CustodyBit_0Indices, idxAttestation.CustodyBit_1Indices...)
dataRoot, err := ssz.HashTreeRoot(idxAttestation.Data)
protoIdxAtt := &pb.ValidatorIDToIdxAtt{
protoIdxAtt := &slashpb.ValidatorIDToIdxAtt{
Signature: idxAttestation.Signature,
Indices: indices,
DataRoot: dataRoot[:],

View File

@ -4,12 +4,12 @@ import (
"github.com/boltdb/bolt"
"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)
func createEpochSpanMap(enc []byte) (*ethpb.EpochSpanMap, error) {
epochSpanMap := &ethpb.EpochSpanMap{}
func createEpochSpanMap(enc []byte) (*slashpb.EpochSpanMap, error) {
epochSpanMap := &slashpb.EpochSpanMap{}
err := proto.Unmarshal(enc, epochSpanMap)
if err != nil {
return nil, errors.Wrap(err, "failed to unmarshal encoding")
@ -20,8 +20,8 @@ func createEpochSpanMap(enc []byte) (*ethpb.EpochSpanMap, error) {
// ValidatorSpansMap accepts validator index and returns the corresponding spans
// map for slashing detection.
// Returns nil if the span map for this validator index does not exist.
func (db *Store) ValidatorSpansMap(validatorIdx uint64) (*ethpb.EpochSpanMap, error) {
var sm *ethpb.EpochSpanMap
func (db *Store) ValidatorSpansMap(validatorIdx uint64) (*slashpb.EpochSpanMap, error) {
var sm *slashpb.EpochSpanMap
err := db.view(func(tx *bolt.Tx) error {
b := tx.Bucket(validatorsMinMaxSpanBucket)
enc := b.Get(bytesutil.Bytes4(validatorIdx))
@ -33,13 +33,13 @@ func (db *Store) ValidatorSpansMap(validatorIdx uint64) (*ethpb.EpochSpanMap, er
return nil
})
if sm.EpochSpanMap == nil {
sm.EpochSpanMap = make(map[uint64]*ethpb.MinMaxEpochSpan)
sm.EpochSpanMap = make(map[uint64]*slashpb.MinMaxEpochSpan)
}
return sm, err
}
// SaveValidatorSpansMap accepts a validator index and span map and writes it to disk.
func (db *Store) SaveValidatorSpansMap(validatorIdx uint64, spanMap *ethpb.EpochSpanMap) error {
func (db *Store) SaveValidatorSpansMap(validatorIdx uint64, spanMap *slashpb.EpochSpanMap) error {
err := db.batch(func(tx *bolt.Tx) error {
bucket := tx.Bucket(validatorsMinMaxSpanBucket)
key := bytesutil.Bytes4(validatorIdx)

View File

@ -5,12 +5,12 @@ import (
"testing"
"github.com/gogo/protobuf/proto"
ethpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
)
type spanMapTestStruct struct {
validatorIdx uint64
spanMap *ethpb.EpochSpanMap
spanMap *slashpb.EpochSpanMap
}
var spanTests []spanMapTestStruct
@ -19,8 +19,8 @@ func init() {
spanTests = []spanMapTestStruct{
{
validatorIdx: 1,
spanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
spanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 10, MaxEpochSpan: 20},
2: {MinEpochSpan: 11, MaxEpochSpan: 21},
3: {MinEpochSpan: 12, MaxEpochSpan: 22},
@ -29,8 +29,8 @@ func init() {
},
{
validatorIdx: 2,
spanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
spanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 10, MaxEpochSpan: 20},
2: {MinEpochSpan: 11, MaxEpochSpan: 21},
3: {MinEpochSpan: 12, MaxEpochSpan: 22},
@ -39,8 +39,8 @@ func init() {
},
{
validatorIdx: 3,
spanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
spanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 10, MaxEpochSpan: 20},
2: {MinEpochSpan: 11, MaxEpochSpan: 21},
3: {MinEpochSpan: 12, MaxEpochSpan: 22},
@ -59,7 +59,7 @@ func TestValidatorSpanMap_NilDB(t *testing.T) {
if err != nil {
t.Fatalf("Nil ValidatorSpansMap should not return error: %v", err)
}
if !reflect.DeepEqual(vsm.EpochSpanMap, map[uint64]*ethpb.MinMaxEpochSpan{}) {
if !reflect.DeepEqual(vsm.EpochSpanMap, map[uint64]*slashpb.MinMaxEpochSpan{}) {
t.Fatal("ValidatorSpansMap should return nil")
}
}
@ -111,7 +111,7 @@ func TestValidatorSpanMap_Delete(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(sm.EpochSpanMap, map[uint64]*ethpb.MinMaxEpochSpan{}) {
if !reflect.DeepEqual(sm.EpochSpanMap, map[uint64]*slashpb.MinMaxEpochSpan{}) {
t.Errorf("Expected validator span map to be deleted, received: %v", sm)
}
}

View File

@ -10,14 +10,14 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/core/helpers:go_default_library",
"//proto/beacon/rpc/v1:go_default_library",
"//proto/slashing:go_default_library",
"//shared/params:go_default_library",
"//slasher/db:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
"@org_golang_google_grpc//codes:go_default_library",
"@org_golang_google_grpc//status:go_default_library",
],
@ -32,7 +32,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//proto/beacon/rpc/v1:go_default_library",
"//proto/slashing:go_default_library",
"//shared/params:go_default_library",
"//slasher/db:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",

View File

@ -4,18 +4,18 @@ import (
"context"
"fmt"
ethpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/shared/params"
)
// Detector is a function type used to implement the slashable surrounding/surrounded
// vote detection methods.
type detectFn = func(attestationEpochSpan uint64, recorderEpochSpan *ethpb.MinMaxEpochSpan, sourceEpoch uint64) uint64
type detectFn = func(attestationEpochSpan uint64, recorderEpochSpan *slashpb.MinMaxEpochSpan, sourceEpoch uint64) uint64
// detectMax is a function for maxDetector used to detect surrounding attestations.
func detectMax(
attestationEpochSpan uint64,
recorderEpochSpan *ethpb.MinMaxEpochSpan,
recorderEpochSpan *slashpb.MinMaxEpochSpan,
attestationSourceEpoch uint64) uint64 {
maxSpan := uint64(recorderEpochSpan.MaxEpochSpan)
@ -27,7 +27,7 @@ func detectMax(
// detectMin is a function for minDetecter used to detect surrounded attestations.
func detectMin(attestationEpochSpan uint64,
recorderEpochSpan *ethpb.MinMaxEpochSpan,
recorderEpochSpan *slashpb.MinMaxEpochSpan,
attestationSourceEpoch uint64) uint64 {
minSpan := uint64(recorderEpochSpan.MinEpochSpan)
@ -49,8 +49,8 @@ func (ss *Server) DetectAndUpdateMaxEpochSpan(
source uint64,
target uint64,
validatorIdx uint64,
spanMap *ethpb.EpochSpanMap,
) (uint64, *ethpb.EpochSpanMap, error) {
spanMap *slashpb.EpochSpanMap,
) (uint64, *slashpb.EpochSpanMap, error) {
if target < source {
return 0, nil, fmt.Errorf(
"target: %d < source: %d ",
@ -68,7 +68,7 @@ func (ss *Server) DetectAndUpdateMaxEpochSpan(
for i := uint64(1); i < target-source; i++ {
val := uint32(span - i)
if _, ok := spanMap.EpochSpanMap[source+i]; !ok {
spanMap.EpochSpanMap[source+i] = &ethpb.MinMaxEpochSpan{}
spanMap.EpochSpanMap[source+i] = &slashpb.MinMaxEpochSpan{}
}
if spanMap.EpochSpanMap[source+i].MaxEpochSpan < val {
spanMap.EpochSpanMap[source+i].MaxEpochSpan = val
@ -94,8 +94,8 @@ func (ss *Server) DetectAndUpdateMinEpochSpan(
source uint64,
target uint64,
validatorIdx uint64,
spanMap *ethpb.EpochSpanMap,
) (uint64, *ethpb.EpochSpanMap, error) {
spanMap *slashpb.EpochSpanMap,
) (uint64, *slashpb.EpochSpanMap, error) {
if target < source {
return 0, nil, fmt.Errorf(
"target: %d < source: %d ",
@ -116,7 +116,7 @@ func (ss *Server) DetectAndUpdateMinEpochSpan(
for i := source - 1; i > 0; i-- {
val := uint32(target - (i))
if _, ok := spanMap.EpochSpanMap[i]; !ok {
spanMap.EpochSpanMap[i] = &ethpb.MinMaxEpochSpan{}
spanMap.EpochSpanMap[i] = &slashpb.MinMaxEpochSpan{}
}
if spanMap.EpochSpanMap[i].MinEpochSpan == 0 || spanMap.EpochSpanMap[i].MinEpochSpan > val {
spanMap.EpochSpanMap[i].MinEpochSpan = val
@ -134,9 +134,9 @@ func (ss *Server) DetectAndUpdateMinEpochSpan(
func (ss *Server) detectSlashingByEpochSpan(
source,
target uint64,
spanMap *ethpb.EpochSpanMap,
spanMap *slashpb.EpochSpanMap,
detector detectFn,
) (uint64, uint64, *ethpb.EpochSpanMap, error) {
) (uint64, uint64, *slashpb.EpochSpanMap, error) {
span := target - source
if span > params.BeaconConfig().WeakSubjectivityPeriod {
return 0, span, nil, fmt.Errorf("target: %d - source: %d > weakSubjectivityPeriod",

View File

@ -5,7 +5,7 @@ import (
"testing"
"github.com/gogo/protobuf/proto"
ethpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/slasher/db"
)
@ -15,7 +15,7 @@ type spanMapTestStruct struct {
sourceEpoch uint64
targetEpoch uint64
slashingTargetEpoch uint64
resultSpanMap *ethpb.EpochSpanMap
resultSpanMap *slashpb.EpochSpanMap
}
var spanTestsMax []spanMapTestStruct
@ -30,8 +30,8 @@ func init() {
sourceEpoch: 3,
targetEpoch: 6,
slashingTargetEpoch: 0,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
4: {MinEpochSpan: 0, MaxEpochSpan: 2},
5: {MinEpochSpan: 0, MaxEpochSpan: 1},
},
@ -42,8 +42,8 @@ func init() {
sourceEpoch: 8,
targetEpoch: 18,
slashingTargetEpoch: 0,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
4: {MinEpochSpan: 0, MaxEpochSpan: 2},
5: {MinEpochSpan: 0, MaxEpochSpan: 1},
9: {MinEpochSpan: 0, MaxEpochSpan: 9},
@ -63,8 +63,8 @@ func init() {
sourceEpoch: 4,
targetEpoch: 12,
slashingTargetEpoch: 0,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
4: {MinEpochSpan: 0, MaxEpochSpan: 2},
5: {MinEpochSpan: 0, MaxEpochSpan: 7},
6: {MinEpochSpan: 0, MaxEpochSpan: 6},
@ -87,8 +87,8 @@ func init() {
sourceEpoch: 10,
targetEpoch: 15,
slashingTargetEpoch: 18,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
4: {MinEpochSpan: 0, MaxEpochSpan: 2},
5: {MinEpochSpan: 0, MaxEpochSpan: 7},
6: {MinEpochSpan: 0, MaxEpochSpan: 6},
@ -114,8 +114,8 @@ func init() {
sourceEpoch: 4,
targetEpoch: 6,
slashingTargetEpoch: 0,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 5, MaxEpochSpan: 0},
2: {MinEpochSpan: 4, MaxEpochSpan: 0},
3: {MinEpochSpan: 3, MaxEpochSpan: 0},
@ -127,8 +127,8 @@ func init() {
sourceEpoch: 13,
targetEpoch: 18,
slashingTargetEpoch: 0,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 5, MaxEpochSpan: 0},
2: {MinEpochSpan: 4, MaxEpochSpan: 0},
3: {MinEpochSpan: 3, MaxEpochSpan: 0},
@ -149,8 +149,8 @@ func init() {
sourceEpoch: 11,
targetEpoch: 15,
slashingTargetEpoch: 0,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 5, MaxEpochSpan: 0},
2: {MinEpochSpan: 4, MaxEpochSpan: 0},
3: {MinEpochSpan: 3, MaxEpochSpan: 0},
@ -171,8 +171,8 @@ func init() {
sourceEpoch: 10,
targetEpoch: 20,
slashingTargetEpoch: 15,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
1: {MinEpochSpan: 5, MaxEpochSpan: 0},
2: {MinEpochSpan: 4, MaxEpochSpan: 0},
3: {MinEpochSpan: 3, MaxEpochSpan: 0},
@ -267,8 +267,8 @@ func TestServer_FailToUpdate(t *testing.T) {
sourceEpoch: 0,
slashingTargetEpoch: 0,
targetEpoch: params.BeaconConfig().WeakSubjectivityPeriod + 1,
resultSpanMap: &ethpb.EpochSpanMap{
EpochSpanMap: map[uint64]*ethpb.MinMaxEpochSpan{
resultSpanMap: &slashpb.EpochSpanMap{
EpochSpanMap: map[uint64]*slashpb.MinMaxEpochSpan{
4: {MinEpochSpan: 0, MaxEpochSpan: 2},
5: {MinEpochSpan: 0, MaxEpochSpan: 1},
},

View File

@ -6,12 +6,12 @@ import (
"sync"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
slashpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/slasher/db"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@ -110,13 +110,13 @@ func (ss *Server) IsSlashableBlock(ctx context.Context, psr *slashpb.ProposerSla
}
// SlashableProposals is a subscription to receive all slashable proposer slashing events found by the watchtower.
func (ss *Server) SlashableProposals(req *types.Empty, server slashpb.Slasher_SlashableProposalsServer) error {
func (ss *Server) SlashableProposals(req *empty.Empty, server slashpb.Slasher_SlashableProposalsServer) error {
//TODO(3133): implement stream provider for newly discovered listening to slashable proposals.
return status.Error(codes.Unimplemented, "not implemented")
}
// SlashableAttestations is a subscription to receive all slashable attester slashing events found by the watchtower.
func (ss *Server) SlashableAttestations(req *types.Empty, server slashpb.Slasher_SlashableAttestationsServer) error {
func (ss *Server) SlashableAttestations(req *empty.Empty, server slashpb.Slasher_SlashableAttestationsServer) error {
//TODO(3133): implement stream provider for newly discovered listening to slashable attestation.
return status.Error(codes.Unimplemented, "not implemented")
}

View File

@ -7,7 +7,7 @@ import (
"github.com/gogo/protobuf/proto"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
slashpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/slasher/db"
)

View File

@ -9,7 +9,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/slasher/service",
visibility = ["//visibility:public"],
deps = [
"//proto/beacon/rpc/v1:go_default_library",
"//proto/slashing:go_default_library",
"//shared/cmd:go_default_library",
"//shared/debug:go_default_library",
"//shared/params:go_default_library",

View File

@ -17,7 +17,7 @@ import (
grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
eth "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
slashpb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
slashpb "github.com/prysmaticlabs/prysm/proto/slashing"
"github.com/prysmaticlabs/prysm/shared/cmd"
"github.com/prysmaticlabs/prysm/shared/debug"
"github.com/prysmaticlabs/prysm/shared/version"