From 91d60ca8e7d048b446860db5492e7d0bd1d601cb Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 14:39:33 -0400 Subject: [PATCH 01/24] wip --- proto/pb/vm/vm.pb.go | 1078 +++++++++---------- proto/vm/vm.proto | 9 - snow/consensus/snowman/block.go | 4 +- snow/decidable.go | 33 + snow/engine/snowman/getter/getter.go | 27 +- snow/snowtest/{snowtest.go => context.go} | 0 snow/snowtest/decidable.go | 56 + snow/snowtest/status.go | 15 + vms/avm/block/executor/block.go | 51 +- vms/avm/block/executor/block_test.go | 107 -- vms/platformvm/block/executor/block.go | 37 - vms/platformvm/block/executor/block_test.go | 106 -- vms/platformvm/vm_regression_test.go | 25 - vms/platformvm/vm_test.go | 4 +- vms/proposervm/batched_vm.go | 12 - vms/proposervm/block.go | 4 - vms/proposervm/post_fork_block.go | 15 - vms/proposervm/post_fork_block_test.go | 15 +- vms/proposervm/post_fork_option.go | 18 +- vms/proposervm/pre_fork_block.go | 25 - vms/proposervm/vm.go | 36 +- vms/rpcchainvm/vm_client.go | 29 - vms/rpcchainvm/vm_server.go | 2 - 23 files changed, 649 insertions(+), 1059 deletions(-) create mode 100644 snow/decidable.go rename snow/snowtest/{snowtest.go => context.go} (100%) create mode 100644 snow/snowtest/decidable.go create mode 100644 snow/snowtest/status.go diff --git a/proto/pb/vm/vm.pb.go b/proto/pb/vm/vm.pb.go index 356f34d061ac..60d5f15d44fc 100644 --- a/proto/pb/vm/vm.pb.go +++ b/proto/pb/vm/vm.pb.go @@ -75,58 +75,6 @@ func (State) EnumDescriptor() ([]byte, []int) { return file_vm_vm_proto_rawDescGZIP(), []int{0} } -type Status int32 - -const ( - Status_STATUS_UNSPECIFIED Status = 0 - Status_STATUS_PROCESSING Status = 1 - Status_STATUS_REJECTED Status = 2 - Status_STATUS_ACCEPTED Status = 3 -) - -// Enum value maps for Status. -var ( - Status_name = map[int32]string{ - 0: "STATUS_UNSPECIFIED", - 1: "STATUS_PROCESSING", - 2: "STATUS_REJECTED", - 3: "STATUS_ACCEPTED", - } - Status_value = map[string]int32{ - "STATUS_UNSPECIFIED": 0, - "STATUS_PROCESSING": 1, - "STATUS_REJECTED": 2, - "STATUS_ACCEPTED": 3, - } -) - -func (x Status) Enum() *Status { - p := new(Status) - *p = x - return p -} - -func (x Status) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Status) Descriptor() protoreflect.EnumDescriptor { - return file_vm_vm_proto_enumTypes[1].Descriptor() -} - -func (Status) Type() protoreflect.EnumType { - return &file_vm_vm_proto_enumTypes[1] -} - -func (x Status) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Status.Descriptor instead. -func (Status) EnumDescriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{1} -} - type Error int32 const ( @@ -164,11 +112,11 @@ func (x Error) String() string { } func (Error) Descriptor() protoreflect.EnumDescriptor { - return file_vm_vm_proto_enumTypes[2].Descriptor() + return file_vm_vm_proto_enumTypes[1].Descriptor() } func (Error) Type() protoreflect.EnumType { - return &file_vm_vm_proto_enumTypes[2] + return &file_vm_vm_proto_enumTypes[1] } func (x Error) Number() protoreflect.EnumNumber { @@ -177,7 +125,7 @@ func (x Error) Number() protoreflect.EnumNumber { // Deprecated: Use Error.Descriptor instead. func (Error) EnumDescriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{2} + return file_vm_vm_proto_rawDescGZIP(), []int{1} } type StateSummaryAcceptResponse_Mode int32 @@ -216,11 +164,11 @@ func (x StateSummaryAcceptResponse_Mode) String() string { } func (StateSummaryAcceptResponse_Mode) Descriptor() protoreflect.EnumDescriptor { - return file_vm_vm_proto_enumTypes[3].Descriptor() + return file_vm_vm_proto_enumTypes[2].Descriptor() } func (StateSummaryAcceptResponse_Mode) Type() protoreflect.EnumType { - return &file_vm_vm_proto_enumTypes[3] + return &file_vm_vm_proto_enumTypes[2] } func (x StateSummaryAcceptResponse_Mode) Number() protoreflect.EnumNumber { @@ -886,7 +834,6 @@ type ParseBlockResponse struct { Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` ParentId []byte `protobuf:"bytes,2,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"` - Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=vm.Status" json:"status,omitempty"` Height uint64 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` VerifyWithContext bool `protobuf:"varint,6,opt,name=verify_with_context,json=verifyWithContext,proto3" json:"verify_with_context,omitempty"` @@ -938,13 +885,6 @@ func (x *ParseBlockResponse) GetParentId() []byte { return nil } -func (x *ParseBlockResponse) GetStatus() Status { - if x != nil { - return x.Status - } - return Status_STATUS_UNSPECIFIED -} - func (x *ParseBlockResponse) GetHeight() uint64 { if x != nil { return x.Height @@ -1020,7 +960,6 @@ type GetBlockResponse struct { ParentId []byte `protobuf:"bytes,1,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"` Bytes []byte `protobuf:"bytes,2,opt,name=bytes,proto3" json:"bytes,omitempty"` - Status Status `protobuf:"varint,3,opt,name=status,proto3,enum=vm.Status" json:"status,omitempty"` Height uint64 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // used to propagate database.ErrNotFound through RPC @@ -1074,13 +1013,6 @@ func (x *GetBlockResponse) GetBytes() []byte { return nil } -func (x *GetBlockResponse) GetStatus() Status { - if x != nil { - return x.Status - } - return Status_STATUS_UNSPECIFIED -} - func (x *GetBlockResponse) GetHeight() uint64 { if x != nil { return x.Height @@ -3046,385 +2978,374 @@ var file_vm_vm_proto_rawDesc = []byte{ 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x29, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, - 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0xe7, 0x01, 0x0a, 0x12, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, + 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0xc3, 0x01, 0x0a, 0x12, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x76, 0x6d, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, - 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, - 0x2e, 0x0a, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x63, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x76, 0x65, - 0x72, 0x69, 0x66, 0x79, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, - 0x21, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, - 0x69, 0x64, 0x22, 0x88, 0x02, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x76, 0x6d, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, - 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, - 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, - 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x12, 0x2e, 0x0a, - 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x78, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x76, 0x65, 0x72, 0x69, - 0x66, 0x79, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x26, 0x0a, - 0x14, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x68, 0x0a, 0x12, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, - 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, - 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x12, 0x29, 0x0a, 0x0e, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x0c, 0x70, 0x43, 0x68, - 0x61, 0x69, 0x6e, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x88, 0x01, 0x01, 0x42, 0x11, 0x0a, 0x0f, - 0x5f, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, - 0x4f, 0x0a, 0x13, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x22, 0x24, 0x0a, 0x12, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x24, 0x0a, 0x12, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x2a, 0x0a, 0x0e, - 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x2b, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x99, 0x01, 0x0a, 0x0d, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, - 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, - 0x36, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2e, 0x0a, 0x13, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, + 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x21, 0x0a, 0x0f, 0x47, + 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0xe4, + 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x38, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x64, - 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x91, 0x01, 0x0a, 0x13, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, - 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, - 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, - 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x64, 0x0a, 0x0e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, - 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, - 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x39, 0x0a, 0x0c, 0x41, - 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x6e, - 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, - 0x64, 0x65, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0xa5, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x6f, 0x73, 0x73, - 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, - 0x73, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, - 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x08, - 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, - 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x9d, - 0x01, 0x0a, 0x1d, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, - 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x09, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x70, - 0x0a, 0x18, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x52, 0x03, 0x65, 0x72, 0x72, 0x12, 0x2e, 0x0a, 0x13, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, + 0x77, 0x69, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x57, 0x69, 0x74, 0x68, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x26, 0x0a, 0x14, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x68, 0x0a, + 0x12, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x0e, 0x70, 0x5f, 0x63, + 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x48, 0x00, 0x52, 0x0c, 0x70, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x48, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x88, 0x01, 0x01, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x70, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x4f, 0x0a, 0x13, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, + 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x24, 0x0a, 0x12, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x22, 0x24, + 0x0a, 0x12, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x02, 0x69, 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, + 0x22, 0x2b, 0x0a, 0x0f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x99, 0x01, + 0x0a, 0x0d, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, + 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, + 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x91, 0x01, 0x0a, 0x13, 0x41, 0x70, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, + 0x67, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x09, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, + 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x64, 0x0a, + 0x0e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x12, + 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x39, 0x0a, 0x0c, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, + 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, + 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0xa5, + 0x01, 0x0a, 0x17, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x81, 0x01, 0x0a, 0x10, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x6f, - 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x12, 0x14, - 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x70, - 0x61, 0x74, 0x63, 0x68, 0x22, 0x2e, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, - 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, - 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, - 0x64, 0x65, 0x49, 0x64, 0x22, 0xb3, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, - 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, - 0x62, 0x6c, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, - 0x6b, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x73, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x61, 0x78, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x4e, 0x75, 0x6d, 0x12, 0x26, 0x0a, 0x0f, 0x6d, 0x61, 0x78, - 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x53, 0x69, 0x7a, - 0x65, 0x12, 0x37, 0x0a, 0x18, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, - 0x72, 0x65, 0x74, 0x72, 0x69, 0x76, 0x61, 0x6c, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x15, 0x6d, 0x61, 0x78, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, - 0x74, 0x72, 0x69, 0x76, 0x61, 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x14, 0x47, 0x65, - 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6c, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65, - 0x73, 0x22, 0x34, 0x0a, 0x18, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, - 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, - 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4f, 0x0a, 0x19, 0x42, 0x61, 0x74, 0x63, 0x68, - 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, - 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x33, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x50, 0x0a, - 0x1a, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x62, - 0x6c, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6b, - 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, - 0x5d, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x5f, 0x66, 0x61, 0x6d, 0x69, - 0x6c, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x69, 0x6f, 0x2e, - 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x52, 0x0e, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x22, 0x51, - 0x0a, 0x18, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, - 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, - 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, - 0x72, 0x22, 0x7f, 0x0a, 0x22, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, - 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, - 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, - 0x72, 0x72, 0x22, 0x78, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, - 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, - 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, - 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x30, 0x0a, 0x18, - 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, - 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x60, - 0x0a, 0x19, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, - 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, - 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, - 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, - 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x22, 0x5c, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, - 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, - 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, - 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, - 0x22, 0x31, 0x0a, 0x19, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, - 0x74, 0x65, 0x73, 0x22, 0xc5, 0x01, 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x23, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, - 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x03, 0x65, - 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x51, 0x0a, 0x04, 0x4d, 0x6f, 0x64, 0x65, - 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, - 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, - 0x4b, 0x49, 0x50, 0x50, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x4f, 0x44, 0x45, - 0x5f, 0x53, 0x54, 0x41, 0x54, 0x49, 0x43, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, - 0x45, 0x5f, 0x44, 0x59, 0x4e, 0x41, 0x4d, 0x49, 0x43, 0x10, 0x03, 0x2a, 0x65, 0x0a, 0x05, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x53, - 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, 0x49, - 0x4e, 0x47, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x42, 0x4f, - 0x4f, 0x54, 0x53, 0x54, 0x52, 0x41, 0x50, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, - 0x0f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x5f, 0x4f, 0x50, - 0x10, 0x03, 0x2a, 0x61, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, - 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, - 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, - 0x52, 0x4f, 0x43, 0x45, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, - 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, - 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, - 0x54, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x6b, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x15, - 0x0a, 0x11, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, - 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x52, 0x52, 0x4f, 0x52, - 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02, 0x12, 0x24, 0x0a, 0x20, - 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, - 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4d, 0x50, 0x4c, 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x45, 0x44, - 0x10, 0x03, 0x32, 0x86, 0x11, 0x0a, 0x02, 0x56, 0x4d, 0x12, 0x3b, 0x0a, 0x0a, 0x49, 0x6e, 0x69, - 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x49, 0x6e, 0x69, - 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x76, 0x6d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, - 0x08, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x44, 0x0a, 0x0e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x1a, 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, - 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x39, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x14, 0x2e, 0x76, - 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3f, 0x0a, 0x0c, 0x44, 0x69, - 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, + 0x73, 0x74, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x9d, 0x01, 0x0a, 0x1d, 0x43, 0x72, 0x6f, 0x73, 0x73, + 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, + 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x70, 0x0a, 0x18, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, + 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, + 0x73, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x1d, 0x0a, + 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x10, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, + 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, + 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, + 0x6a, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6d, 0x61, 0x6a, 0x6f, 0x72, + 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x05, 0x6d, 0x69, 0x6e, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x22, 0x2e, 0x0a, 0x13, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3b, 0x0a, 0x0a, 0x42, - 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x42, - 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x50, 0x61, 0x72, 0x73, - 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, - 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, - 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x0d, - 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x2e, - 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x22, 0xb3, 0x01, 0x0a, + 0x13, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x6c, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6b, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x6d, + 0x61, 0x78, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0c, 0x6d, 0x61, 0x78, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x4e, 0x75, + 0x6d, 0x12, 0x26, 0x0a, 0x0f, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x6d, 0x61, 0x78, + 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x72, 0x65, 0x74, 0x72, 0x69, 0x76, 0x61, 0x6c, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x15, 0x6d, 0x61, 0x78, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x74, 0x72, 0x69, 0x76, 0x61, 0x6c, 0x54, 0x69, + 0x6d, 0x65, 0x22, 0x35, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, + 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, + 0x6b, 0x73, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, + 0x62, 0x6c, 0x6b, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x34, 0x0a, 0x18, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x4f, 0x0a, 0x19, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x33, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, + 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x50, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x6c, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6b, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x5d, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x68, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x6d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x5f, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, + 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x52, 0x0e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, + 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x22, 0x51, 0x0a, 0x18, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, + 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x03, + 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x7f, 0x0a, 0x22, 0x47, 0x65, 0x74, + 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, + 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x78, 0x0a, 0x1b, 0x47, 0x65, + 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, + 0x03, 0x65, 0x72, 0x72, 0x22, 0x30, 0x0a, 0x18, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x60, 0x0a, 0x19, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1b, 0x0a, 0x03, 0x65, + 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x5c, 0x0a, 0x17, 0x47, 0x65, + 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, + 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x31, 0x0a, 0x19, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0xc5, 0x01, 0x0a, 0x1a, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, + 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, + 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, + 0x22, 0x51, 0x0a, 0x04, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x4f, 0x44, 0x45, + 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, + 0x0a, 0x0c, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x4b, 0x49, 0x50, 0x50, 0x45, 0x44, 0x10, 0x01, + 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x49, 0x43, 0x10, + 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x44, 0x59, 0x4e, 0x41, 0x4d, 0x49, + 0x43, 0x10, 0x03, 0x2a, 0x65, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x11, + 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, + 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, + 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, + 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x42, 0x4f, 0x4f, 0x54, 0x53, 0x54, 0x52, 0x41, 0x50, 0x50, + 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x4e, + 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x5f, 0x4f, 0x50, 0x10, 0x03, 0x2a, 0x6b, 0x0a, 0x05, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, + 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, + 0x02, 0x12, 0x24, 0x0a, 0x20, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, + 0x5f, 0x53, 0x59, 0x4e, 0x43, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4d, 0x50, 0x4c, 0x45, 0x4d, + 0x45, 0x4e, 0x54, 0x45, 0x44, 0x10, 0x03, 0x32, 0x86, 0x11, 0x0a, 0x02, 0x56, 0x4d, 0x12, 0x3b, + 0x0a, 0x0a, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, 0x15, 0x2e, 0x76, + 0x6d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, + 0x69, 0x7a, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x53, + 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, + 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x44, + 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, + 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, + 0x64, 0x12, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, - 0x34, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, - 0x0a, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x76, 0x6d, - 0x2e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, + 0x3f, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, + 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x12, 0x3b, 0x0a, 0x0a, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, + 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, + 0x0a, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, + 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, + 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x18, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x12, 0x34, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, - 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x48, 0x65, 0x61, 0x6c, + 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, + 0x76, 0x6d, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0a, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x11, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x39, 0x0a, 0x0b, 0x41, - 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x2e, 0x76, 0x6d, 0x2e, - 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x1a, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x35, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, - 0x73, 0x69, 0x70, 0x12, 0x10, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, - 0x69, 0x70, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x34, 0x0a, - 0x06, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, - 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x14, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, - 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x76, 0x6d, - 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x10, 0x41, + 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, + 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, + 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x12, 0x57, 0x0a, 0x1a, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, - 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x21, - 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, - 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, - 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x4d, 0x0a, 0x15, 0x43, 0x72, 0x6f, - 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, - 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x41, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, - 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, - 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x18, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, - 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x11, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, - 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, - 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, - 0x12, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x12, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x48, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, - 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, - 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, - 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x1a, - 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x12, 0x39, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x35, 0x0a, 0x09, 0x41, + 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x12, 0x10, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, + 0x70, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, - 0x74, 0x79, 0x1a, 0x26, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, - 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, - 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x13, 0x47, 0x65, - 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, - 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x76, 0x6d, 0x2e, 0x47, - 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, - 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x11, 0x50, 0x61, - 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, - 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, - 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, - 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, - 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x6d, - 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x74, 0x79, 0x12, 0x34, 0x0a, 0x06, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x14, 0x43, 0x72, 0x6f, 0x73, + 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x1b, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, + 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x57, 0x0a, 0x1a, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, + 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, + 0x6c, 0x65, 0x64, 0x12, 0x21, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, + 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, + 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x4d, + 0x0a, 0x15, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, + 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x41, 0x0a, + 0x0c, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x17, 0x2e, + 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, + 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x50, 0x0a, 0x11, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, + 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, + 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x53, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, + 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, + 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x5c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, + 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x53, 0x0a, 0x12, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, - 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x12, 0x1d, 0x2e, 0x76, - 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, - 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x6d, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, - 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x76, 0x61, 0x2d, 0x6c, 0x61, - 0x62, 0x73, 0x2f, 0x61, 0x76, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x67, 0x6f, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x26, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, + 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x4e, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, + 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x50, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1b, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, + 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x16, 0x2e, 0x76, + 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, + 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, + 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x12, 0x16, 0x2e, 0x76, + 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3d, 0x0a, 0x0b, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x16, 0x2e, 0x76, 0x6d, + 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x53, 0x0a, 0x12, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, + 0x74, 0x12, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, + 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1e, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, + 0x76, 0x61, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x61, 0x76, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x68, + 0x65, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x6d, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -3439,154 +3360,151 @@ func file_vm_vm_proto_rawDescGZIP() []byte { return file_vm_vm_proto_rawDescData } -var file_vm_vm_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_vm_vm_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_vm_vm_proto_msgTypes = make([]protoimpl.MessageInfo, 44) var file_vm_vm_proto_goTypes = []interface{}{ (State)(0), // 0: vm.State - (Status)(0), // 1: vm.Status - (Error)(0), // 2: vm.Error - (StateSummaryAcceptResponse_Mode)(0), // 3: vm.StateSummaryAcceptResponse.Mode - (*InitializeRequest)(nil), // 4: vm.InitializeRequest - (*InitializeResponse)(nil), // 5: vm.InitializeResponse - (*SetStateRequest)(nil), // 6: vm.SetStateRequest - (*SetStateResponse)(nil), // 7: vm.SetStateResponse - (*CreateHandlersResponse)(nil), // 8: vm.CreateHandlersResponse - (*Handler)(nil), // 9: vm.Handler - (*BuildBlockRequest)(nil), // 10: vm.BuildBlockRequest - (*BuildBlockResponse)(nil), // 11: vm.BuildBlockResponse - (*ParseBlockRequest)(nil), // 12: vm.ParseBlockRequest - (*ParseBlockResponse)(nil), // 13: vm.ParseBlockResponse - (*GetBlockRequest)(nil), // 14: vm.GetBlockRequest - (*GetBlockResponse)(nil), // 15: vm.GetBlockResponse - (*SetPreferenceRequest)(nil), // 16: vm.SetPreferenceRequest - (*BlockVerifyRequest)(nil), // 17: vm.BlockVerifyRequest - (*BlockVerifyResponse)(nil), // 18: vm.BlockVerifyResponse - (*BlockAcceptRequest)(nil), // 19: vm.BlockAcceptRequest - (*BlockRejectRequest)(nil), // 20: vm.BlockRejectRequest - (*HealthResponse)(nil), // 21: vm.HealthResponse - (*VersionResponse)(nil), // 22: vm.VersionResponse - (*AppRequestMsg)(nil), // 23: vm.AppRequestMsg - (*AppRequestFailedMsg)(nil), // 24: vm.AppRequestFailedMsg - (*AppResponseMsg)(nil), // 25: vm.AppResponseMsg - (*AppGossipMsg)(nil), // 26: vm.AppGossipMsg - (*CrossChainAppRequestMsg)(nil), // 27: vm.CrossChainAppRequestMsg - (*CrossChainAppRequestFailedMsg)(nil), // 28: vm.CrossChainAppRequestFailedMsg - (*CrossChainAppResponseMsg)(nil), // 29: vm.CrossChainAppResponseMsg - (*ConnectedRequest)(nil), // 30: vm.ConnectedRequest - (*DisconnectedRequest)(nil), // 31: vm.DisconnectedRequest - (*GetAncestorsRequest)(nil), // 32: vm.GetAncestorsRequest - (*GetAncestorsResponse)(nil), // 33: vm.GetAncestorsResponse - (*BatchedParseBlockRequest)(nil), // 34: vm.BatchedParseBlockRequest - (*BatchedParseBlockResponse)(nil), // 35: vm.BatchedParseBlockResponse - (*GetBlockIDAtHeightRequest)(nil), // 36: vm.GetBlockIDAtHeightRequest - (*GetBlockIDAtHeightResponse)(nil), // 37: vm.GetBlockIDAtHeightResponse - (*GatherResponse)(nil), // 38: vm.GatherResponse - (*StateSyncEnabledResponse)(nil), // 39: vm.StateSyncEnabledResponse - (*GetOngoingSyncStateSummaryResponse)(nil), // 40: vm.GetOngoingSyncStateSummaryResponse - (*GetLastStateSummaryResponse)(nil), // 41: vm.GetLastStateSummaryResponse - (*ParseStateSummaryRequest)(nil), // 42: vm.ParseStateSummaryRequest - (*ParseStateSummaryResponse)(nil), // 43: vm.ParseStateSummaryResponse - (*GetStateSummaryRequest)(nil), // 44: vm.GetStateSummaryRequest - (*GetStateSummaryResponse)(nil), // 45: vm.GetStateSummaryResponse - (*StateSummaryAcceptRequest)(nil), // 46: vm.StateSummaryAcceptRequest - (*StateSummaryAcceptResponse)(nil), // 47: vm.StateSummaryAcceptResponse - (*timestamppb.Timestamp)(nil), // 48: google.protobuf.Timestamp - (*_go.MetricFamily)(nil), // 49: io.prometheus.client.MetricFamily - (*emptypb.Empty)(nil), // 50: google.protobuf.Empty + (Error)(0), // 1: vm.Error + (StateSummaryAcceptResponse_Mode)(0), // 2: vm.StateSummaryAcceptResponse.Mode + (*InitializeRequest)(nil), // 3: vm.InitializeRequest + (*InitializeResponse)(nil), // 4: vm.InitializeResponse + (*SetStateRequest)(nil), // 5: vm.SetStateRequest + (*SetStateResponse)(nil), // 6: vm.SetStateResponse + (*CreateHandlersResponse)(nil), // 7: vm.CreateHandlersResponse + (*Handler)(nil), // 8: vm.Handler + (*BuildBlockRequest)(nil), // 9: vm.BuildBlockRequest + (*BuildBlockResponse)(nil), // 10: vm.BuildBlockResponse + (*ParseBlockRequest)(nil), // 11: vm.ParseBlockRequest + (*ParseBlockResponse)(nil), // 12: vm.ParseBlockResponse + (*GetBlockRequest)(nil), // 13: vm.GetBlockRequest + (*GetBlockResponse)(nil), // 14: vm.GetBlockResponse + (*SetPreferenceRequest)(nil), // 15: vm.SetPreferenceRequest + (*BlockVerifyRequest)(nil), // 16: vm.BlockVerifyRequest + (*BlockVerifyResponse)(nil), // 17: vm.BlockVerifyResponse + (*BlockAcceptRequest)(nil), // 18: vm.BlockAcceptRequest + (*BlockRejectRequest)(nil), // 19: vm.BlockRejectRequest + (*HealthResponse)(nil), // 20: vm.HealthResponse + (*VersionResponse)(nil), // 21: vm.VersionResponse + (*AppRequestMsg)(nil), // 22: vm.AppRequestMsg + (*AppRequestFailedMsg)(nil), // 23: vm.AppRequestFailedMsg + (*AppResponseMsg)(nil), // 24: vm.AppResponseMsg + (*AppGossipMsg)(nil), // 25: vm.AppGossipMsg + (*CrossChainAppRequestMsg)(nil), // 26: vm.CrossChainAppRequestMsg + (*CrossChainAppRequestFailedMsg)(nil), // 27: vm.CrossChainAppRequestFailedMsg + (*CrossChainAppResponseMsg)(nil), // 28: vm.CrossChainAppResponseMsg + (*ConnectedRequest)(nil), // 29: vm.ConnectedRequest + (*DisconnectedRequest)(nil), // 30: vm.DisconnectedRequest + (*GetAncestorsRequest)(nil), // 31: vm.GetAncestorsRequest + (*GetAncestorsResponse)(nil), // 32: vm.GetAncestorsResponse + (*BatchedParseBlockRequest)(nil), // 33: vm.BatchedParseBlockRequest + (*BatchedParseBlockResponse)(nil), // 34: vm.BatchedParseBlockResponse + (*GetBlockIDAtHeightRequest)(nil), // 35: vm.GetBlockIDAtHeightRequest + (*GetBlockIDAtHeightResponse)(nil), // 36: vm.GetBlockIDAtHeightResponse + (*GatherResponse)(nil), // 37: vm.GatherResponse + (*StateSyncEnabledResponse)(nil), // 38: vm.StateSyncEnabledResponse + (*GetOngoingSyncStateSummaryResponse)(nil), // 39: vm.GetOngoingSyncStateSummaryResponse + (*GetLastStateSummaryResponse)(nil), // 40: vm.GetLastStateSummaryResponse + (*ParseStateSummaryRequest)(nil), // 41: vm.ParseStateSummaryRequest + (*ParseStateSummaryResponse)(nil), // 42: vm.ParseStateSummaryResponse + (*GetStateSummaryRequest)(nil), // 43: vm.GetStateSummaryRequest + (*GetStateSummaryResponse)(nil), // 44: vm.GetStateSummaryResponse + (*StateSummaryAcceptRequest)(nil), // 45: vm.StateSummaryAcceptRequest + (*StateSummaryAcceptResponse)(nil), // 46: vm.StateSummaryAcceptResponse + (*timestamppb.Timestamp)(nil), // 47: google.protobuf.Timestamp + (*_go.MetricFamily)(nil), // 48: io.prometheus.client.MetricFamily + (*emptypb.Empty)(nil), // 49: google.protobuf.Empty } var file_vm_vm_proto_depIdxs = []int32{ - 48, // 0: vm.InitializeResponse.timestamp:type_name -> google.protobuf.Timestamp + 47, // 0: vm.InitializeResponse.timestamp:type_name -> google.protobuf.Timestamp 0, // 1: vm.SetStateRequest.state:type_name -> vm.State - 48, // 2: vm.SetStateResponse.timestamp:type_name -> google.protobuf.Timestamp - 9, // 3: vm.CreateHandlersResponse.handlers:type_name -> vm.Handler - 48, // 4: vm.BuildBlockResponse.timestamp:type_name -> google.protobuf.Timestamp - 1, // 5: vm.ParseBlockResponse.status:type_name -> vm.Status - 48, // 6: vm.ParseBlockResponse.timestamp:type_name -> google.protobuf.Timestamp - 1, // 7: vm.GetBlockResponse.status:type_name -> vm.Status - 48, // 8: vm.GetBlockResponse.timestamp:type_name -> google.protobuf.Timestamp - 2, // 9: vm.GetBlockResponse.err:type_name -> vm.Error - 48, // 10: vm.BlockVerifyResponse.timestamp:type_name -> google.protobuf.Timestamp - 48, // 11: vm.AppRequestMsg.deadline:type_name -> google.protobuf.Timestamp - 48, // 12: vm.CrossChainAppRequestMsg.deadline:type_name -> google.protobuf.Timestamp - 13, // 13: vm.BatchedParseBlockResponse.response:type_name -> vm.ParseBlockResponse - 2, // 14: vm.GetBlockIDAtHeightResponse.err:type_name -> vm.Error - 49, // 15: vm.GatherResponse.metric_families:type_name -> io.prometheus.client.MetricFamily - 2, // 16: vm.StateSyncEnabledResponse.err:type_name -> vm.Error - 2, // 17: vm.GetOngoingSyncStateSummaryResponse.err:type_name -> vm.Error - 2, // 18: vm.GetLastStateSummaryResponse.err:type_name -> vm.Error - 2, // 19: vm.ParseStateSummaryResponse.err:type_name -> vm.Error - 2, // 20: vm.GetStateSummaryResponse.err:type_name -> vm.Error - 3, // 21: vm.StateSummaryAcceptResponse.mode:type_name -> vm.StateSummaryAcceptResponse.Mode - 2, // 22: vm.StateSummaryAcceptResponse.err:type_name -> vm.Error - 4, // 23: vm.VM.Initialize:input_type -> vm.InitializeRequest - 6, // 24: vm.VM.SetState:input_type -> vm.SetStateRequest - 50, // 25: vm.VM.Shutdown:input_type -> google.protobuf.Empty - 50, // 26: vm.VM.CreateHandlers:input_type -> google.protobuf.Empty - 30, // 27: vm.VM.Connected:input_type -> vm.ConnectedRequest - 31, // 28: vm.VM.Disconnected:input_type -> vm.DisconnectedRequest - 10, // 29: vm.VM.BuildBlock:input_type -> vm.BuildBlockRequest - 12, // 30: vm.VM.ParseBlock:input_type -> vm.ParseBlockRequest - 14, // 31: vm.VM.GetBlock:input_type -> vm.GetBlockRequest - 16, // 32: vm.VM.SetPreference:input_type -> vm.SetPreferenceRequest - 50, // 33: vm.VM.Health:input_type -> google.protobuf.Empty - 50, // 34: vm.VM.Version:input_type -> google.protobuf.Empty - 23, // 35: vm.VM.AppRequest:input_type -> vm.AppRequestMsg - 24, // 36: vm.VM.AppRequestFailed:input_type -> vm.AppRequestFailedMsg - 25, // 37: vm.VM.AppResponse:input_type -> vm.AppResponseMsg - 26, // 38: vm.VM.AppGossip:input_type -> vm.AppGossipMsg - 50, // 39: vm.VM.Gather:input_type -> google.protobuf.Empty - 27, // 40: vm.VM.CrossChainAppRequest:input_type -> vm.CrossChainAppRequestMsg - 28, // 41: vm.VM.CrossChainAppRequestFailed:input_type -> vm.CrossChainAppRequestFailedMsg - 29, // 42: vm.VM.CrossChainAppResponse:input_type -> vm.CrossChainAppResponseMsg - 32, // 43: vm.VM.GetAncestors:input_type -> vm.GetAncestorsRequest - 34, // 44: vm.VM.BatchedParseBlock:input_type -> vm.BatchedParseBlockRequest - 36, // 45: vm.VM.GetBlockIDAtHeight:input_type -> vm.GetBlockIDAtHeightRequest - 50, // 46: vm.VM.StateSyncEnabled:input_type -> google.protobuf.Empty - 50, // 47: vm.VM.GetOngoingSyncStateSummary:input_type -> google.protobuf.Empty - 50, // 48: vm.VM.GetLastStateSummary:input_type -> google.protobuf.Empty - 42, // 49: vm.VM.ParseStateSummary:input_type -> vm.ParseStateSummaryRequest - 44, // 50: vm.VM.GetStateSummary:input_type -> vm.GetStateSummaryRequest - 17, // 51: vm.VM.BlockVerify:input_type -> vm.BlockVerifyRequest - 19, // 52: vm.VM.BlockAccept:input_type -> vm.BlockAcceptRequest - 20, // 53: vm.VM.BlockReject:input_type -> vm.BlockRejectRequest - 46, // 54: vm.VM.StateSummaryAccept:input_type -> vm.StateSummaryAcceptRequest - 5, // 55: vm.VM.Initialize:output_type -> vm.InitializeResponse - 7, // 56: vm.VM.SetState:output_type -> vm.SetStateResponse - 50, // 57: vm.VM.Shutdown:output_type -> google.protobuf.Empty - 8, // 58: vm.VM.CreateHandlers:output_type -> vm.CreateHandlersResponse - 50, // 59: vm.VM.Connected:output_type -> google.protobuf.Empty - 50, // 60: vm.VM.Disconnected:output_type -> google.protobuf.Empty - 11, // 61: vm.VM.BuildBlock:output_type -> vm.BuildBlockResponse - 13, // 62: vm.VM.ParseBlock:output_type -> vm.ParseBlockResponse - 15, // 63: vm.VM.GetBlock:output_type -> vm.GetBlockResponse - 50, // 64: vm.VM.SetPreference:output_type -> google.protobuf.Empty - 21, // 65: vm.VM.Health:output_type -> vm.HealthResponse - 22, // 66: vm.VM.Version:output_type -> vm.VersionResponse - 50, // 67: vm.VM.AppRequest:output_type -> google.protobuf.Empty - 50, // 68: vm.VM.AppRequestFailed:output_type -> google.protobuf.Empty - 50, // 69: vm.VM.AppResponse:output_type -> google.protobuf.Empty - 50, // 70: vm.VM.AppGossip:output_type -> google.protobuf.Empty - 38, // 71: vm.VM.Gather:output_type -> vm.GatherResponse - 50, // 72: vm.VM.CrossChainAppRequest:output_type -> google.protobuf.Empty - 50, // 73: vm.VM.CrossChainAppRequestFailed:output_type -> google.protobuf.Empty - 50, // 74: vm.VM.CrossChainAppResponse:output_type -> google.protobuf.Empty - 33, // 75: vm.VM.GetAncestors:output_type -> vm.GetAncestorsResponse - 35, // 76: vm.VM.BatchedParseBlock:output_type -> vm.BatchedParseBlockResponse - 37, // 77: vm.VM.GetBlockIDAtHeight:output_type -> vm.GetBlockIDAtHeightResponse - 39, // 78: vm.VM.StateSyncEnabled:output_type -> vm.StateSyncEnabledResponse - 40, // 79: vm.VM.GetOngoingSyncStateSummary:output_type -> vm.GetOngoingSyncStateSummaryResponse - 41, // 80: vm.VM.GetLastStateSummary:output_type -> vm.GetLastStateSummaryResponse - 43, // 81: vm.VM.ParseStateSummary:output_type -> vm.ParseStateSummaryResponse - 45, // 82: vm.VM.GetStateSummary:output_type -> vm.GetStateSummaryResponse - 18, // 83: vm.VM.BlockVerify:output_type -> vm.BlockVerifyResponse - 50, // 84: vm.VM.BlockAccept:output_type -> google.protobuf.Empty - 50, // 85: vm.VM.BlockReject:output_type -> google.protobuf.Empty - 47, // 86: vm.VM.StateSummaryAccept:output_type -> vm.StateSummaryAcceptResponse - 55, // [55:87] is the sub-list for method output_type - 23, // [23:55] is the sub-list for method input_type - 23, // [23:23] is the sub-list for extension type_name - 23, // [23:23] is the sub-list for extension extendee - 0, // [0:23] is the sub-list for field type_name + 47, // 2: vm.SetStateResponse.timestamp:type_name -> google.protobuf.Timestamp + 8, // 3: vm.CreateHandlersResponse.handlers:type_name -> vm.Handler + 47, // 4: vm.BuildBlockResponse.timestamp:type_name -> google.protobuf.Timestamp + 47, // 5: vm.ParseBlockResponse.timestamp:type_name -> google.protobuf.Timestamp + 47, // 6: vm.GetBlockResponse.timestamp:type_name -> google.protobuf.Timestamp + 1, // 7: vm.GetBlockResponse.err:type_name -> vm.Error + 47, // 8: vm.BlockVerifyResponse.timestamp:type_name -> google.protobuf.Timestamp + 47, // 9: vm.AppRequestMsg.deadline:type_name -> google.protobuf.Timestamp + 47, // 10: vm.CrossChainAppRequestMsg.deadline:type_name -> google.protobuf.Timestamp + 12, // 11: vm.BatchedParseBlockResponse.response:type_name -> vm.ParseBlockResponse + 1, // 12: vm.GetBlockIDAtHeightResponse.err:type_name -> vm.Error + 48, // 13: vm.GatherResponse.metric_families:type_name -> io.prometheus.client.MetricFamily + 1, // 14: vm.StateSyncEnabledResponse.err:type_name -> vm.Error + 1, // 15: vm.GetOngoingSyncStateSummaryResponse.err:type_name -> vm.Error + 1, // 16: vm.GetLastStateSummaryResponse.err:type_name -> vm.Error + 1, // 17: vm.ParseStateSummaryResponse.err:type_name -> vm.Error + 1, // 18: vm.GetStateSummaryResponse.err:type_name -> vm.Error + 2, // 19: vm.StateSummaryAcceptResponse.mode:type_name -> vm.StateSummaryAcceptResponse.Mode + 1, // 20: vm.StateSummaryAcceptResponse.err:type_name -> vm.Error + 3, // 21: vm.VM.Initialize:input_type -> vm.InitializeRequest + 5, // 22: vm.VM.SetState:input_type -> vm.SetStateRequest + 49, // 23: vm.VM.Shutdown:input_type -> google.protobuf.Empty + 49, // 24: vm.VM.CreateHandlers:input_type -> google.protobuf.Empty + 29, // 25: vm.VM.Connected:input_type -> vm.ConnectedRequest + 30, // 26: vm.VM.Disconnected:input_type -> vm.DisconnectedRequest + 9, // 27: vm.VM.BuildBlock:input_type -> vm.BuildBlockRequest + 11, // 28: vm.VM.ParseBlock:input_type -> vm.ParseBlockRequest + 13, // 29: vm.VM.GetBlock:input_type -> vm.GetBlockRequest + 15, // 30: vm.VM.SetPreference:input_type -> vm.SetPreferenceRequest + 49, // 31: vm.VM.Health:input_type -> google.protobuf.Empty + 49, // 32: vm.VM.Version:input_type -> google.protobuf.Empty + 22, // 33: vm.VM.AppRequest:input_type -> vm.AppRequestMsg + 23, // 34: vm.VM.AppRequestFailed:input_type -> vm.AppRequestFailedMsg + 24, // 35: vm.VM.AppResponse:input_type -> vm.AppResponseMsg + 25, // 36: vm.VM.AppGossip:input_type -> vm.AppGossipMsg + 49, // 37: vm.VM.Gather:input_type -> google.protobuf.Empty + 26, // 38: vm.VM.CrossChainAppRequest:input_type -> vm.CrossChainAppRequestMsg + 27, // 39: vm.VM.CrossChainAppRequestFailed:input_type -> vm.CrossChainAppRequestFailedMsg + 28, // 40: vm.VM.CrossChainAppResponse:input_type -> vm.CrossChainAppResponseMsg + 31, // 41: vm.VM.GetAncestors:input_type -> vm.GetAncestorsRequest + 33, // 42: vm.VM.BatchedParseBlock:input_type -> vm.BatchedParseBlockRequest + 35, // 43: vm.VM.GetBlockIDAtHeight:input_type -> vm.GetBlockIDAtHeightRequest + 49, // 44: vm.VM.StateSyncEnabled:input_type -> google.protobuf.Empty + 49, // 45: vm.VM.GetOngoingSyncStateSummary:input_type -> google.protobuf.Empty + 49, // 46: vm.VM.GetLastStateSummary:input_type -> google.protobuf.Empty + 41, // 47: vm.VM.ParseStateSummary:input_type -> vm.ParseStateSummaryRequest + 43, // 48: vm.VM.GetStateSummary:input_type -> vm.GetStateSummaryRequest + 16, // 49: vm.VM.BlockVerify:input_type -> vm.BlockVerifyRequest + 18, // 50: vm.VM.BlockAccept:input_type -> vm.BlockAcceptRequest + 19, // 51: vm.VM.BlockReject:input_type -> vm.BlockRejectRequest + 45, // 52: vm.VM.StateSummaryAccept:input_type -> vm.StateSummaryAcceptRequest + 4, // 53: vm.VM.Initialize:output_type -> vm.InitializeResponse + 6, // 54: vm.VM.SetState:output_type -> vm.SetStateResponse + 49, // 55: vm.VM.Shutdown:output_type -> google.protobuf.Empty + 7, // 56: vm.VM.CreateHandlers:output_type -> vm.CreateHandlersResponse + 49, // 57: vm.VM.Connected:output_type -> google.protobuf.Empty + 49, // 58: vm.VM.Disconnected:output_type -> google.protobuf.Empty + 10, // 59: vm.VM.BuildBlock:output_type -> vm.BuildBlockResponse + 12, // 60: vm.VM.ParseBlock:output_type -> vm.ParseBlockResponse + 14, // 61: vm.VM.GetBlock:output_type -> vm.GetBlockResponse + 49, // 62: vm.VM.SetPreference:output_type -> google.protobuf.Empty + 20, // 63: vm.VM.Health:output_type -> vm.HealthResponse + 21, // 64: vm.VM.Version:output_type -> vm.VersionResponse + 49, // 65: vm.VM.AppRequest:output_type -> google.protobuf.Empty + 49, // 66: vm.VM.AppRequestFailed:output_type -> google.protobuf.Empty + 49, // 67: vm.VM.AppResponse:output_type -> google.protobuf.Empty + 49, // 68: vm.VM.AppGossip:output_type -> google.protobuf.Empty + 37, // 69: vm.VM.Gather:output_type -> vm.GatherResponse + 49, // 70: vm.VM.CrossChainAppRequest:output_type -> google.protobuf.Empty + 49, // 71: vm.VM.CrossChainAppRequestFailed:output_type -> google.protobuf.Empty + 49, // 72: vm.VM.CrossChainAppResponse:output_type -> google.protobuf.Empty + 32, // 73: vm.VM.GetAncestors:output_type -> vm.GetAncestorsResponse + 34, // 74: vm.VM.BatchedParseBlock:output_type -> vm.BatchedParseBlockResponse + 36, // 75: vm.VM.GetBlockIDAtHeight:output_type -> vm.GetBlockIDAtHeightResponse + 38, // 76: vm.VM.StateSyncEnabled:output_type -> vm.StateSyncEnabledResponse + 39, // 77: vm.VM.GetOngoingSyncStateSummary:output_type -> vm.GetOngoingSyncStateSummaryResponse + 40, // 78: vm.VM.GetLastStateSummary:output_type -> vm.GetLastStateSummaryResponse + 42, // 79: vm.VM.ParseStateSummary:output_type -> vm.ParseStateSummaryResponse + 44, // 80: vm.VM.GetStateSummary:output_type -> vm.GetStateSummaryResponse + 17, // 81: vm.VM.BlockVerify:output_type -> vm.BlockVerifyResponse + 49, // 82: vm.VM.BlockAccept:output_type -> google.protobuf.Empty + 49, // 83: vm.VM.BlockReject:output_type -> google.protobuf.Empty + 46, // 84: vm.VM.StateSummaryAccept:output_type -> vm.StateSummaryAcceptResponse + 53, // [53:85] is the sub-list for method output_type + 21, // [21:53] is the sub-list for method input_type + 21, // [21:21] is the sub-list for extension type_name + 21, // [21:21] is the sub-list for extension extendee + 0, // [0:21] is the sub-list for field type_name } func init() { file_vm_vm_proto_init() } @@ -4131,7 +4049,7 @@ func file_vm_vm_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vm_vm_proto_rawDesc, - NumEnums: 4, + NumEnums: 3, NumMessages: 44, NumExtensions: 0, NumServices: 1, diff --git a/proto/vm/vm.proto b/proto/vm/vm.proto index 038744d4e2d5..11dd0429c8d6 100644 --- a/proto/vm/vm.proto +++ b/proto/vm/vm.proto @@ -88,13 +88,6 @@ enum State { STATE_NORMAL_OP = 3; } -enum Status { - STATUS_UNSPECIFIED = 0; - STATUS_PROCESSING = 1; - STATUS_REJECTED = 2; - STATUS_ACCEPTED = 3; -} - enum Error { // ERROR_UNSPECIFIED is used to indicate that no error occurred. ERROR_UNSPECIFIED = 0; @@ -177,7 +170,6 @@ message ParseBlockRequest { message ParseBlockResponse { bytes id = 1; bytes parent_id = 2; - Status status = 3; uint64 height = 4; google.protobuf.Timestamp timestamp = 5; bool verify_with_context = 6; @@ -190,7 +182,6 @@ message GetBlockRequest { message GetBlockResponse { bytes parent_id = 1; bytes bytes = 2; - Status status = 3; uint64 height = 4; google.protobuf.Timestamp timestamp = 5; // used to propagate database.ErrNotFound through RPC diff --git a/snow/consensus/snowman/block.go b/snow/consensus/snowman/block.go index c950ac3c29ee..4f2c851717cd 100644 --- a/snow/consensus/snowman/block.go +++ b/snow/consensus/snowman/block.go @@ -8,7 +8,7 @@ import ( "time" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" + "github.com/ava-labs/avalanchego/snow" ) // Block is a possible decision that dictates the next canonical block. @@ -22,7 +22,7 @@ import ( // If the status of the block is Accepted or Rejected; Parent, Verify, Accept, // and Reject will never be called. type Block interface { - choices.Decidable + snow.Decidable // Parent returns the ID of this block's parent. Parent() ids.ID diff --git a/snow/decidable.go b/snow/decidable.go new file mode 100644 index 000000000000..71665b883e5c --- /dev/null +++ b/snow/decidable.go @@ -0,0 +1,33 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package snow + +import ( + "context" + + "github.com/ava-labs/avalanchego/ids" +) + +// Decidable represents element that can be decided. +// +// Decidable objects are typically thought of as either transactions, blocks, or +// vertices. +type Decidable interface { + // ID returns a unique ID for this element. + // + // Typically, this is implemented by using a cryptographic hash of a + // binary representation of this element. An element should return the same + // IDs upon repeated calls. + ID() ids.ID + + // Accept this element. + // + // This element will be accepted by every correct node in the network. + Accept(context.Context) error + + // Reject this element. + // + // This element will not be accepted by any correct node in the network. + Reject(context.Context) error +} diff --git a/snow/engine/snowman/getter/getter.go b/snow/engine/snowman/getter/getter.go index b501aeef2680..7af3d3a2263e 100644 --- a/snow/engine/snowman/getter/getter.go +++ b/snow/engine/snowman/getter/getter.go @@ -11,7 +11,6 @@ import ( "go.uber.org/zap" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/utils/constants" @@ -148,10 +147,34 @@ func (gh *getter) GetAcceptedFrontier(ctx context.Context, nodeID ids.NodeID, re } func (gh *getter) GetAccepted(ctx context.Context, nodeID ids.NodeID, requestID uint32, containerIDs set.Set[ids.ID]) error { + lastAcceptedID, err := gh.vm.LastAccepted(ctx) + if err != nil { + return err + } + lastAccepted, err := gh.vm.GetBlock(ctx, lastAcceptedID) + if err != nil { + return err + } + lastAcceptedHeight := lastAccepted.Height() + acceptedIDs := make([]ids.ID, 0, containerIDs.Len()) for blkID := range containerIDs { blk, err := gh.vm.GetBlock(ctx, blkID) - if err == nil && blk.Status() == choices.Accepted { + if err != nil { + continue + } + + height := blk.Height() + if height > lastAcceptedHeight { + continue + } + + acceptedBlkID, err := gh.vm.GetBlockIDAtHeight(ctx, height) + if err != nil { + continue + } + + if blkID == acceptedBlkID { acceptedIDs = append(acceptedIDs, blkID) } } diff --git a/snow/snowtest/snowtest.go b/snow/snowtest/context.go similarity index 100% rename from snow/snowtest/snowtest.go rename to snow/snowtest/context.go diff --git a/snow/snowtest/decidable.go b/snow/snowtest/decidable.go new file mode 100644 index 000000000000..691cc90120bc --- /dev/null +++ b/snow/snowtest/decidable.go @@ -0,0 +1,56 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package snowtest + +import ( + "context" + "errors" + "fmt" + + "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow" +) + +var ( + _ snow.Decidable = (*Decidable)(nil) + + ErrInvalidStateTransition = errors.New("invalid state transition") +) + +type Decidable struct { + IDV ids.ID + AcceptV error + RejectV error + Status Status +} + +func (d *Decidable) ID() ids.ID { + return d.IDV +} + +func (d *Decidable) Accept(context.Context) error { + if d.Status == Rejected { + return fmt.Errorf("%w from %s to %s", + ErrInvalidStateTransition, + Rejected, + Accepted, + ) + } + + d.Status = Accepted + return d.AcceptV +} + +func (d *Decidable) Reject(context.Context) error { + if d.Status == Accepted { + return fmt.Errorf("%w from %s to %s", + ErrInvalidStateTransition, + Accepted, + Rejected, + ) + } + + d.Status = Rejected + return d.RejectV +} diff --git a/snow/snowtest/status.go b/snow/snowtest/status.go new file mode 100644 index 000000000000..2fe571271927 --- /dev/null +++ b/snow/snowtest/status.go @@ -0,0 +1,15 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package snowtest + +type Status uint32 + +// [Undecided] means the operation hasn't been decided yet +// [Accepted] means the operation was accepted +// [Rejected] means the operation will never be accepted +const ( + Undecided Status = iota + Accepted + Rejected +) diff --git a/vms/avm/block/executor/block.go b/vms/avm/block/executor/block.go index 8663f27ba123..109e6708b0bf 100644 --- a/vms/avm/block/executor/block.go +++ b/vms/avm/block/executor/block.go @@ -12,9 +12,7 @@ import ( "go.uber.org/zap" "github.com/ava-labs/avalanchego/chains/atomic" - "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/state" @@ -38,8 +36,7 @@ var ( // Exported for testing in avm package. type Block struct { block.Block - manager *manager - rejected bool + manager *manager } func (b *Block) Verify(context.Context) error { @@ -293,51 +290,5 @@ func (b *Block) Reject(context.Context) error { // If we added transactions to the mempool, we should be willing to build a // block. b.manager.mempool.RequestBuildBlock() - - b.rejected = true return nil } - -func (b *Block) Status() choices.Status { - // If this block's reference was rejected, we should report it as rejected. - // - // We don't persist the rejection, but that's fine. The consensus engine - // will hold the same reference to the block until it no longer needs it. - // After the consensus engine has released the reference to the block that - // was verified, it may get a new reference that isn't marked as rejected. - // The consensus engine may then try to issue the block, but will discover - // that it was rejected due to a conflicting block having been accepted. - if b.rejected { - return choices.Rejected - } - - blkID := b.ID() - // If this block is the last accepted block, we don't need to go to disk to - // check the status. - if b.manager.lastAccepted == blkID { - return choices.Accepted - } - // Check if the block is in memory. If so, it's processing. - if _, ok := b.manager.blkIDToState[blkID]; ok { - return choices.Processing - } - // Block isn't in memory. Check in the database. - _, err := b.manager.state.GetBlock(blkID) - switch err { - case nil: - return choices.Accepted - - case database.ErrNotFound: - // choices.Unknown means we don't have the bytes of the block. - // In this case, we do, so we return choices.Processing. - return choices.Processing - - default: - // TODO: correctly report this error to the consensus engine. - b.manager.backend.Ctx.Log.Error( - "dropping unhandled database error", - zap.Error(err), - ) - return choices.Processing - } -} diff --git a/vms/avm/block/executor/block_test.go b/vms/avm/block/executor/block_test.go index 8e72f4c21ebe..3f6c0a81b977 100644 --- a/vms/avm/block/executor/block_test.go +++ b/vms/avm/block/executor/block_test.go @@ -13,10 +13,8 @@ import ( "go.uber.org/mock/gomock" "github.com/ava-labs/avalanchego/chains/atomic" - "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" @@ -927,117 +925,12 @@ func TestBlockReject(t *testing.T) { b := tt.blockFunc(ctrl) require.NoError(b.Reject(context.Background())) - require.True(b.rejected) _, ok := b.manager.blkIDToState[b.ID()] require.False(ok) }) } } -func TestBlockStatus(t *testing.T) { - type test struct { - name string - blockFunc func(ctrl *gomock.Controller) *Block - expected choices.Status - } - tests := []test{ - { - name: "block is rejected", - blockFunc: func(*gomock.Controller) *Block { - return &Block{ - rejected: true, - } - }, - expected: choices.Rejected, - }, - { - name: "block is last accepted", - blockFunc: func(ctrl *gomock.Controller) *Block { - blockID := ids.GenerateTestID() - mockBlock := block.NewMockBlock(ctrl) - mockBlock.EXPECT().ID().Return(blockID).AnyTimes() - return &Block{ - Block: mockBlock, - manager: &manager{ - backend: defaultTestBackend(false, nil), - lastAccepted: blockID, - }, - } - }, - expected: choices.Accepted, - }, - { - name: "block is processing", - blockFunc: func(ctrl *gomock.Controller) *Block { - blockID := ids.GenerateTestID() - mockBlock := block.NewMockBlock(ctrl) - mockBlock.EXPECT().ID().Return(blockID).AnyTimes() - return &Block{ - Block: mockBlock, - manager: &manager{ - backend: defaultTestBackend(false, nil), - blkIDToState: map[ids.ID]*blockState{ - blockID: {}, - }, - }, - } - }, - expected: choices.Processing, - }, - { - name: "block is accepted but not last accepted", - blockFunc: func(ctrl *gomock.Controller) *Block { - blockID := ids.GenerateTestID() - mockBlock := block.NewMockBlock(ctrl) - mockBlock.EXPECT().ID().Return(blockID).AnyTimes() - - mockState := state.NewMockState(ctrl) - mockState.EXPECT().GetBlock(blockID).Return(nil, nil) - - return &Block{ - Block: mockBlock, - manager: &manager{ - backend: defaultTestBackend(false, nil), - blkIDToState: map[ids.ID]*blockState{}, - state: mockState, - }, - } - }, - expected: choices.Accepted, - }, - { - name: "block is unknown", - blockFunc: func(ctrl *gomock.Controller) *Block { - blockID := ids.GenerateTestID() - mockBlock := block.NewMockBlock(ctrl) - mockBlock.EXPECT().ID().Return(blockID).AnyTimes() - - mockState := state.NewMockState(ctrl) - mockState.EXPECT().GetBlock(blockID).Return(nil, database.ErrNotFound) - - return &Block{ - Block: mockBlock, - manager: &manager{ - backend: defaultTestBackend(false, nil), - blkIDToState: map[ids.ID]*blockState{}, - state: mockState, - }, - } - }, - expected: choices.Processing, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - ctrl := gomock.NewController(t) - - b := tt.blockFunc(ctrl) - require.Equal(tt.expected, b.Status()) - }) - } -} - func defaultTestBackend(bootstrapped bool, sharedMemory atomic.SharedMemory) *executor.Backend { return &executor.Backend{ Bootstrapped: bootstrapped, diff --git a/vms/platformvm/block/executor/block.go b/vms/platformvm/block/executor/block.go index 5cd5a02f709c..5248ab7e778f 100644 --- a/vms/platformvm/block/executor/block.go +++ b/vms/platformvm/block/executor/block.go @@ -7,10 +7,6 @@ import ( "context" "time" - "go.uber.org/zap" - - "github.com/ava-labs/avalanchego/database" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/vms/platformvm/block" ) @@ -44,39 +40,6 @@ func (b *Block) Reject(context.Context) error { return b.Visit(b.manager.rejector) } -func (b *Block) Status() choices.Status { - blkID := b.ID() - // If this block is an accepted Proposal block with no accepted children, it - // will be in [blkIDToState], but we should return accepted, not processing, - // so we do this check. - if b.manager.lastAccepted == blkID { - return choices.Accepted - } - // Check if the block is in memory. If so, it's processing. - if _, ok := b.manager.blkIDToState[blkID]; ok { - return choices.Processing - } - // Block isn't in memory. Check in the database. - _, err := b.manager.state.GetStatelessBlock(blkID) - switch err { - case nil: - return choices.Accepted - - case database.ErrNotFound: - // choices.Unknown means we don't have the bytes of the block. - // In this case, we do, so we return choices.Processing. - return choices.Processing - - default: - // TODO: correctly report this error to the consensus engine. - b.manager.ctx.Log.Error( - "dropping unhandled database error", - zap.Error(err), - ) - return choices.Processing - } -} - func (b *Block) Timestamp() time.Time { return b.manager.getTimestamp(b.ID()) } diff --git a/vms/platformvm/block/executor/block_test.go b/vms/platformvm/block/executor/block_test.go index 1215f9628e92..dfccc413e29b 100644 --- a/vms/platformvm/block/executor/block_test.go +++ b/vms/platformvm/block/executor/block_test.go @@ -13,7 +13,6 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/utils/constants" @@ -26,111 +25,6 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs/executor" ) -func TestStatus(t *testing.T) { - type test struct { - name string - blockF func(*gomock.Controller) *Block - expectedStatus choices.Status - } - - tests := []test{ - { - name: "last accepted", - blockF: func(ctrl *gomock.Controller) *Block { - blkID := ids.GenerateTestID() - statelessBlk := block.NewMockBlock(ctrl) - statelessBlk.EXPECT().ID().Return(blkID) - - manager := &manager{ - backend: &backend{ - lastAccepted: blkID, - }, - } - - return &Block{ - Block: statelessBlk, - manager: manager, - } - }, - expectedStatus: choices.Accepted, - }, - { - name: "processing", - blockF: func(ctrl *gomock.Controller) *Block { - blkID := ids.GenerateTestID() - statelessBlk := block.NewMockBlock(ctrl) - statelessBlk.EXPECT().ID().Return(blkID) - - manager := &manager{ - backend: &backend{ - blkIDToState: map[ids.ID]*blockState{ - blkID: {}, - }, - }, - } - return &Block{ - Block: statelessBlk, - manager: manager, - } - }, - expectedStatus: choices.Processing, - }, - { - name: "in database", - blockF: func(ctrl *gomock.Controller) *Block { - blkID := ids.GenerateTestID() - statelessBlk := block.NewMockBlock(ctrl) - statelessBlk.EXPECT().ID().Return(blkID) - - state := state.NewMockState(ctrl) - state.EXPECT().GetStatelessBlock(blkID).Return(statelessBlk, nil) - - manager := &manager{ - backend: &backend{ - state: state, - }, - } - return &Block{ - Block: statelessBlk, - manager: manager, - } - }, - expectedStatus: choices.Accepted, - }, - { - name: "not in map or database", - blockF: func(ctrl *gomock.Controller) *Block { - blkID := ids.GenerateTestID() - statelessBlk := block.NewMockBlock(ctrl) - statelessBlk.EXPECT().ID().Return(blkID) - - state := state.NewMockState(ctrl) - state.EXPECT().GetStatelessBlock(blkID).Return(nil, database.ErrNotFound) - - manager := &manager{ - backend: &backend{ - state: state, - }, - } - return &Block{ - Block: statelessBlk, - manager: manager, - } - }, - expectedStatus: choices.Processing, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - ctrl := gomock.NewController(t) - - blk := tt.blockF(ctrl) - require.Equal(t, tt.expectedStatus, blk.Status()) - }) - } -} - func TestBlockOptions(t *testing.T) { type test struct { name string diff --git a/vms/platformvm/vm_regression_test.go b/vms/platformvm/vm_regression_test.go index 629be17fe1ba..c505f9b1a9e1 100644 --- a/vms/platformvm/vm_regression_test.go +++ b/vms/platformvm/vm_regression_test.go @@ -22,7 +22,6 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/network/p2p/gossip" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/snowtest" @@ -713,11 +712,6 @@ func TestRejectedStateRegressionInvalidValidatorTimestamp(t *testing.T) { err = importBlk.Verify(context.Background()) require.ErrorIs(err, database.ErrNotFound) - // Because we no longer ever reject a block in verification, the status - // should remain as processing. - importBlkStatus := importBlk.Status() - require.Equal(choices.Processing, importBlkStatus) - // Populate the shared memory UTXO. m := atomic.NewMemory(prefixdb.New([]byte{5}, baseDB)) @@ -745,10 +739,6 @@ func TestRejectedStateRegressionInvalidValidatorTimestamp(t *testing.T) { // pass verification. require.NoError(importBlk.Verify(context.Background())) - // The status shouldn't have been changed during a successful verification. - importBlkStatus = importBlk.Status() - require.Equal(choices.Processing, importBlkStatus) - // Move chain time ahead to bring the new validator from the pending // validator set into the current validator set. vm.clock.Set(newValidatorStartTime) @@ -777,9 +767,6 @@ func TestRejectedStateRegressionInvalidValidatorTimestamp(t *testing.T) { } for _, blk := range allBlocks { require.NoError(blk.Accept(context.Background())) - - status := blk.Status() - require.Equal(choices.Accepted, status) } // Force a reload of the state from the database. @@ -961,11 +948,6 @@ func TestRejectedStateRegressionInvalidValidatorReward(t *testing.T) { err = importBlk.Verify(context.Background()) require.ErrorIs(err, database.ErrNotFound) - // Because we no longer ever reject a block in verification, the status - // should remain as processing. - importBlkStatus := importBlk.Status() - require.Equal(choices.Processing, importBlkStatus) - // Populate the shared memory UTXO. m := atomic.NewMemory(prefixdb.New([]byte{5}, baseDB)) @@ -993,10 +975,6 @@ func TestRejectedStateRegressionInvalidValidatorReward(t *testing.T) { // pass verification. require.NoError(importBlk.Verify(context.Background())) - // The status shouldn't have been changed during a successful verification. - importBlkStatus = importBlk.Status() - require.Equal(choices.Processing, importBlkStatus) - newValidatorStartTime1 := newValidatorStartTime0.Add(executor.SyncBound).Add(1 * time.Second) newValidatorEndTime1 := newValidatorStartTime1.Add(defaultMaxStakingDuration) @@ -1092,9 +1070,6 @@ func TestRejectedStateRegressionInvalidValidatorReward(t *testing.T) { } for _, blk := range allBlocks { require.NoError(blk.Accept(context.Background())) - - status := blk.Status() - require.Equal(choices.Accepted, status) } // Force a reload of the state from the database. diff --git a/vms/platformvm/vm_test.go b/vms/platformvm/vm_test.go index 24fa707a8e32..7585941faa01 100644 --- a/vms/platformvm/vm_test.go +++ b/vms/platformvm/vm_test.go @@ -21,7 +21,6 @@ import ( "github.com/ava-labs/avalanchego/message" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowball" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/engine/common/tracker" @@ -368,9 +367,10 @@ func TestGenesis(t *testing.T) { genesisBlockID, err := vm.LastAccepted(context.Background()) // lastAccepted should be ID of genesis block require.NoError(err) + // Ensure the genesis block can be retrieved genesisBlock, err := vm.manager.GetBlock(genesisBlockID) require.NoError(err) - require.Equal(choices.Accepted, genesisBlock.Status()) + require.NotNil(genesisBlock) genesisState, _ := defaultGenesis(t, vm.ctx.AVAXAssetID) // Ensure all the genesis UTXOs are there diff --git a/vms/proposervm/batched_vm.go b/vms/proposervm/batched_vm.go index 853c858e6bba..3a491dda904e 100644 --- a/vms/proposervm/batched_vm.go +++ b/vms/proposervm/batched_vm.go @@ -7,9 +7,7 @@ import ( "context" "time" - "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/utils/wrappers" @@ -129,14 +127,6 @@ func (vm *VM) BatchedParseBlock(ctx context.Context, blks [][]byte) ([]snowman.B for ; innerBlocksIndex < len(statelessBlockDescs); innerBlocksIndex++ { statelessBlockDesc := statelessBlockDescs[innerBlocksIndex] statelessBlk := statelessBlockDesc.block - blkID := statelessBlk.ID() - - _, status, err := vm.State.GetBlock(blkID) - if err == database.ErrNotFound { - status = choices.Processing - } else if err != nil { - return nil, err - } if statelessSignedBlock, ok := statelessBlk.(statelessblock.SignedBlock); ok { blocks[statelessBlockDesc.index] = &postForkBlock{ @@ -144,7 +134,6 @@ func (vm *VM) BatchedParseBlock(ctx context.Context, blks [][]byte) ([]snowman.B postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlks[innerBlocksIndex], - status: status, }, } } else { @@ -153,7 +142,6 @@ func (vm *VM) BatchedParseBlock(ctx context.Context, blks [][]byte) ([]snowman.B postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlks[innerBlocksIndex], - status: status, }, } } diff --git a/vms/proposervm/block.go b/vms/proposervm/block.go index d320a80543bc..6c0c2c7e14e7 100644 --- a/vms/proposervm/block.go +++ b/vms/proposervm/block.go @@ -13,7 +13,6 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/vms/proposervm/block" "github.com/ava-labs/avalanchego/vms/proposervm/proposer" @@ -65,7 +64,6 @@ type Block interface { type PostForkBlock interface { Block - setStatus(choices.Status) getStatelessBlk() block.Block setInnerBlk(snowman.Block) } @@ -74,7 +72,6 @@ type PostForkBlock interface { type postForkCommonComponents struct { vm *VM innerBlk snowman.Block - status choices.Status } // Return the inner block's height @@ -268,7 +265,6 @@ func (p *postForkCommonComponents) buildChild( postForkCommonComponents: postForkCommonComponents{ vm: p.vm, innerBlk: innerBlock, - status: choices.Processing, }, } diff --git a/vms/proposervm/post_fork_block.go b/vms/proposervm/post_fork_block.go index 2c875807eb79..c815144fd306 100644 --- a/vms/proposervm/post_fork_block.go +++ b/vms/proposervm/post_fork_block.go @@ -7,7 +7,6 @@ import ( "context" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -43,7 +42,6 @@ func (b *postForkBlock) Accept(ctx context.Context) error { func (b *postForkBlock) acceptOuterBlk() error { // Update in-memory references - b.status = choices.Accepted b.vm.lastAcceptedTime = b.Timestamp() return b.vm.acceptPostForkBlock(b) @@ -58,17 +56,9 @@ func (b *postForkBlock) acceptInnerBlk(ctx context.Context) error { func (b *postForkBlock) Reject(context.Context) error { // We do not reject the inner block here because it may be accepted later delete(b.vm.verifiedBlocks, b.ID()) - b.status = choices.Rejected return nil } -func (b *postForkBlock) Status() choices.Status { - if b.status == choices.Accepted && b.Height() > b.vm.lastAcceptedHeight { - return choices.Processing - } - return b.status -} - // Return this block's parent, or a *missing.Block if // we don't have the parent. func (b *postForkBlock) Parent() ids.ID { @@ -116,7 +106,6 @@ func (b *postForkBlock) Options(ctx context.Context) ([2]snowman.Block, error) { postForkCommonComponents: postForkCommonComponents{ vm: b.vm, innerBlk: innerOption, - status: innerOption.Status(), }, } } @@ -168,10 +157,6 @@ func (b *postForkBlock) pChainHeight(context.Context) (uint64, error) { return b.PChainHeight(), nil } -func (b *postForkBlock) setStatus(status choices.Status) { - b.status = status -} - func (b *postForkBlock) getStatelessBlk() block.Block { return b.SignedBlock } diff --git a/vms/proposervm/post_fork_block_test.go b/vms/proposervm/post_fork_block_test.go index 416fc087b101..462132f8446b 100644 --- a/vms/proposervm/post_fork_block_test.go +++ b/vms/proposervm/post_fork_block_test.go @@ -23,7 +23,10 @@ import ( "github.com/ava-labs/avalanchego/vms/proposervm/proposer" ) -var errDuplicateVerify = errors.New("duplicate verify") +var ( + errDuplicateVerify = errors.New("duplicate verify") + errUnexpectedBlockRejection = errors.New("unexpected block rejection") +) // ProposerBlock Option interface tests section func TestOracle_PostForkBlock_ImplementsInterface(t *testing.T) { @@ -74,7 +77,6 @@ func TestOracle_PostForkBlock_ImplementsInterface(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: innerOracleBlk, - status: choices.Processing, }, } @@ -139,7 +141,6 @@ func TestBlockVerify_PostForkBlock_PreDurango_ParentChecks(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: childCoreBlk, - status: choices.Processing, }, } @@ -229,7 +230,6 @@ func TestBlockVerify_PostForkBlock_PostDurango_ParentChecks(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: childCoreBlk, - status: choices.Processing, }, } @@ -351,7 +351,6 @@ func TestBlockVerify_PostForkBlock_TimestampChecks(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: childCoreBlk, - status: choices.Processing, }, } @@ -540,7 +539,6 @@ func TestBlockVerify_PostForkBlock_PChainHeightChecks(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: childCoreBlk, - status: choices.Processing, }, } @@ -724,7 +722,6 @@ func TestBlockVerify_PostForkBlockBuiltOnOption_PChainHeightChecks(t *testing.T) postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: childCoreBlk, - status: choices.Processing, }, } @@ -977,6 +974,7 @@ func TestBlockReject_PostForkBlock_InnerBlockIsNotRejected(t *testing.T) { }() coreBlk := snowmantest.BuildChild(snowmantest.Genesis) + coreBlk.RejectV = errUnexpectedBlockRejection coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { return coreBlk, nil } @@ -987,9 +985,6 @@ func TestBlockReject_PostForkBlock_InnerBlockIsNotRejected(t *testing.T) { proBlk := sb.(*postForkBlock) require.NoError(proBlk.Reject(context.Background())) - - require.Equal(choices.Rejected, proBlk.Status()) - require.NotEqual(choices.Rejected, proBlk.innerBlk.Status()) } func TestBlockVerify_PostForkBlock_ShouldBePostForkOption(t *testing.T) { diff --git a/vms/proposervm/post_fork_option.go b/vms/proposervm/post_fork_option.go index 93cfd2550ca6..8be839049f93 100644 --- a/vms/proposervm/post_fork_option.go +++ b/vms/proposervm/post_fork_option.go @@ -10,7 +10,6 @@ import ( "go.uber.org/zap" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -25,7 +24,7 @@ type postForkOption struct { } func (b *postForkOption) Timestamp() time.Time { - if b.Status() == choices.Accepted { + if b.Height() <= b.vm.lastAcceptedHeight { return b.vm.lastAcceptedTime } return b.timestamp @@ -39,9 +38,6 @@ func (b *postForkOption) Accept(ctx context.Context) error { } func (b *postForkOption) acceptOuterBlk() error { - // Update in-memory references - b.status = choices.Accepted - return b.vm.acceptPostForkBlock(b) } @@ -56,17 +52,9 @@ func (b *postForkOption) Reject(context.Context) error { // in the proposer block that causing this block to be rejected. delete(b.vm.verifiedBlocks, b.ID()) - b.status = choices.Rejected return nil } -func (b *postForkOption) Status() choices.Status { - if b.status == choices.Accepted && b.Height() > b.vm.lastAcceptedHeight { - return choices.Processing - } - return b.status -} - func (b *postForkOption) Parent() ids.ID { return b.ParentID() } @@ -134,10 +122,6 @@ func (b *postForkOption) pChainHeight(ctx context.Context) (uint64, error) { return parent.pChainHeight(ctx) } -func (b *postForkOption) setStatus(status choices.Status) { - b.status = status -} - func (b *postForkOption) getStatelessBlk() block.Block { return b.Block } diff --git a/vms/proposervm/pre_fork_block.go b/vms/proposervm/pre_fork_block.go index 737659cacc05..6610a9f4d823 100644 --- a/vms/proposervm/pre_fork_block.go +++ b/vms/proposervm/pre_fork_block.go @@ -11,9 +11,7 @@ import ( "go.uber.org/zap" - "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -44,28 +42,6 @@ func (b *preForkBlock) acceptInnerBlk(ctx context.Context) error { return b.Block.Accept(ctx) } -func (b *preForkBlock) Status() choices.Status { - forkHeight, err := b.vm.GetForkHeight() - if err == database.ErrNotFound { - return b.Block.Status() - } - if err != nil { - // TODO: Once `Status()` can return an error, we should return the error - // here. - b.vm.ctx.Log.Error("unexpected error looking up fork height", - zap.Error(err), - ) - return b.Block.Status() - } - - // The fork has occurred earlier than this block, so preForkBlocks are all - // invalid. - if b.Height() >= forkHeight { - return choices.Rejected - } - return b.Block.Status() -} - func (b *preForkBlock) Verify(ctx context.Context) error { parent, err := b.vm.getPreForkBlock(ctx, b.Block.Parent()) if err != nil { @@ -246,7 +222,6 @@ func (b *preForkBlock) buildChild(ctx context.Context) (Block, error) { postForkCommonComponents: postForkCommonComponents{ vm: b.vm, innerBlk: innerBlock, - status: choices.Processing, }, } diff --git a/vms/proposervm/vm.go b/vms/proposervm/vm.go index f5916fcf9f42..c5f890b56de2 100644 --- a/vms/proposervm/vm.go +++ b/vms/proposervm/vm.go @@ -532,16 +532,7 @@ func (vm *VM) parsePostForkBlock(ctx context.Context, b []byte) (PostForkBlock, return nil, err } - // if the block already exists, then make sure the status is set correctly blkID := statelessBlock.ID() - blk, err := vm.getPostForkBlock(ctx, blkID) - if err == nil { - return blk, nil - } - if err != database.ErrNotFound { - return nil, err - } - innerBlkBytes := statelessBlock.Block() innerBlk, err := vm.parseInnerBlock(ctx, blkID, innerBlkBytes) if err != nil { @@ -549,25 +540,22 @@ func (vm *VM) parsePostForkBlock(ctx context.Context, b []byte) (PostForkBlock, } if statelessSignedBlock, ok := statelessBlock.(statelessblock.SignedBlock); ok { - blk = &postForkBlock{ + return &postForkBlock{ SignedBlock: statelessSignedBlock, postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: choices.Processing, - }, - } - } else { - blk = &postForkOption{ - Block: statelessBlock, - postForkCommonComponents: postForkCommonComponents{ - vm: vm, - innerBlk: innerBlk, - status: choices.Processing, }, - } + }, nil } - return blk, nil + + return &postForkOption{ + Block: statelessBlock, + postForkCommonComponents: postForkCommonComponents{ + vm: vm, + innerBlk: innerBlk, + }, + }, nil } func (vm *VM) parsePreForkBlock(ctx context.Context, b []byte) (*preForkBlock, error) { @@ -591,7 +579,7 @@ func (vm *VM) getPostForkBlock(ctx context.Context, blkID ids.ID) (PostForkBlock return block, nil } - statelessBlock, status, err := vm.State.GetBlock(blkID) + statelessBlock, _, err := vm.State.GetBlock(blkID) if err != nil { return nil, err } @@ -608,7 +596,6 @@ func (vm *VM) getPostForkBlock(ctx context.Context, blkID ids.ID) (PostForkBlock postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: status, }, }, nil } @@ -617,7 +604,6 @@ func (vm *VM) getPostForkBlock(ctx context.Context, blkID ids.ID) (PostForkBlock postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: status, }, }, nil } diff --git a/vms/rpcchainvm/vm_client.go b/vms/rpcchainvm/vm_client.go index 6e6417725f11..7fe4e9b0f050 100644 --- a/vms/rpcchainvm/vm_client.go +++ b/vms/rpcchainvm/vm_client.go @@ -25,7 +25,6 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/ids/galiasreader" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/engine/common/appsender" @@ -223,7 +222,6 @@ func (vm *VMClient) Initialize( vm: vm, id: id, parentID: parentID, - status: choices.Accepted, bytes: resp.Bytes, height: resp.Height, time: time, @@ -326,7 +324,6 @@ func (vm *VMClient) SetState(ctx context.Context, state snow.State) error { vm: vm, id: id, parentID: parentID, - status: choices.Accepted, bytes: resp.Bytes, height: resp.Height, time: time, @@ -424,11 +421,6 @@ func (vm *VMClient) parseBlock(ctx context.Context, bytes []byte) (snowman.Block return nil, err } - status := choices.Status(resp.Status) - if err := status.Valid(); err != nil { - return nil, err - } - time, err := grpcutils.TimestampAsTime(resp.Timestamp) if err != nil { return nil, err @@ -437,7 +429,6 @@ func (vm *VMClient) parseBlock(ctx context.Context, bytes []byte) (snowman.Block vm: vm, id: id, parentID: parentID, - status: status, bytes: bytes, height: resp.Height, time: time, @@ -461,17 +452,11 @@ func (vm *VMClient) getBlock(ctx context.Context, blkID ids.ID) (snowman.Block, return nil, err } - status := choices.Status(resp.Status) - if err := status.Valid(); err != nil { - return nil, err - } - time, err := grpcutils.TimestampAsTime(resp.Timestamp) return &blockClient{ vm: vm, id: blkID, parentID: parentID, - status: status, bytes: resp.Bytes, height: resp.Height, time: time, @@ -640,11 +625,6 @@ func (vm *VMClient) batchedParseBlock(ctx context.Context, blksBytes [][]byte) ( return nil, err } - status := choices.Status(blkResp.Status) - if err := status.Valid(); err != nil { - return nil, err - } - time, err := grpcutils.TimestampAsTime(blkResp.Timestamp) if err != nil { return nil, err @@ -654,7 +634,6 @@ func (vm *VMClient) batchedParseBlock(ctx context.Context, blksBytes [][]byte) ( vm: vm, id: id, parentID: parentID, - status: status, bytes: blksBytes[idx], height: blkResp.Height, time: time, @@ -789,7 +768,6 @@ func (vm *VMClient) newBlockFromBuildBlock(resp *vmpb.BuildBlockResponse) (*bloc vm: vm, id: id, parentID: parentID, - status: choices.Processing, bytes: resp.Bytes, height: resp.Height, time: time, @@ -802,7 +780,6 @@ type blockClient struct { id ids.ID parentID ids.ID - status choices.Status bytes []byte height uint64 time time.Time @@ -814,7 +791,6 @@ func (b *blockClient) ID() ids.ID { } func (b *blockClient) Accept(ctx context.Context) error { - b.status = choices.Accepted _, err := b.vm.client.BlockAccept(ctx, &vmpb.BlockAcceptRequest{ Id: b.id[:], }) @@ -822,17 +798,12 @@ func (b *blockClient) Accept(ctx context.Context) error { } func (b *blockClient) Reject(ctx context.Context) error { - b.status = choices.Rejected _, err := b.vm.client.BlockReject(ctx, &vmpb.BlockRejectRequest{ Id: b.id[:], }) return err } -func (b *blockClient) Status() choices.Status { - return b.status -} - func (b *blockClient) Parent() ids.ID { return b.parentID } diff --git a/vms/rpcchainvm/vm_server.go b/vms/rpcchainvm/vm_server.go index b33fd3e5b5fe..577aa95b9d08 100644 --- a/vms/rpcchainvm/vm_server.go +++ b/vms/rpcchainvm/vm_server.go @@ -438,7 +438,6 @@ func (vm *VMServer) ParseBlock(ctx context.Context, req *vmpb.ParseBlockRequest) return &vmpb.ParseBlockResponse{ Id: blkID[:], ParentId: parentID[:], - Status: vmpb.Status(blk.Status()), Height: blk.Height(), Timestamp: grpcutils.TimestampFromTime(blk.Timestamp()), VerifyWithContext: verifyWithCtx, @@ -469,7 +468,6 @@ func (vm *VMServer) GetBlock(ctx context.Context, req *vmpb.GetBlockRequest) (*v return &vmpb.GetBlockResponse{ ParentId: parentID[:], Bytes: blk.Bytes(), - Status: vmpb.Status(blk.Status()), Height: blk.Height(), Timestamp: grpcutils.TimestampFromTime(blk.Timestamp()), VerifyWithContext: verifyWithCtx, From 847804e22d33954b1072927e74cf4212a91c7758 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 14:53:39 -0400 Subject: [PATCH 02/24] remove status from xsvm + some of proposervm --- vms/example/xsvm/chain/block.go | 46 ++++-------------------- vms/example/xsvm/chain/chain.go | 20 ++++++----- vms/proposervm/batched_vm.go | 2 +- vms/proposervm/state/block_state.go | 26 +++++++------- vms/proposervm/state/block_state_test.go | 13 +++---- vms/proposervm/vm.go | 5 ++- 6 files changed, 39 insertions(+), 73 deletions(-) diff --git a/vms/example/xsvm/chain/block.go b/vms/example/xsvm/chain/block.go index 8ab761d515f8..bac28c9317c0 100644 --- a/vms/example/xsvm/chain/block.go +++ b/vms/example/xsvm/chain/block.go @@ -12,11 +12,9 @@ import ( "github.com/ava-labs/avalanchego/database/versiondb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/example/xsvm/execute" - "github.com/ava-labs/avalanchego/vms/example/xsvm/state" smblock "github.com/ava-labs/avalanchego/snow/engine/snowman/block" xsblock "github.com/ava-labs/avalanchego/vms/example/xsvm/block" @@ -52,9 +50,8 @@ type block struct { chain *chain - id ids.ID - status choices.Status - bytes []byte + id ids.ID + bytes []byte state *versiondb.Database verifiedChildrenIDs set.Set[ids.ID] @@ -64,13 +61,6 @@ func (b *block) ID() ids.ID { return b.id } -func (b *block) Status() choices.Status { - if !b.status.Decided() { - b.status = b.calculateStatus() - } - return b.status -} - func (b *block) Parent() ids.ID { return b.ParentID } @@ -108,14 +98,13 @@ func (b *block) Accept(context.Context) error { } } - b.status = choices.Accepted - b.chain.lastAccepted = b.id + b.chain.lastAcceptedID = b.id + b.chain.lastAcceptedHeight = b.Height() delete(b.chain.verifiedBlocks, b.ParentID) return nil } func (b *block) Reject(context.Context) error { - b.status = choices.Rejected delete(b.chain.verifiedBlocks, b.id) // TODO: push transactions back into the mempool @@ -178,12 +167,12 @@ func (b *block) VerifyWithContext(ctx context.Context, blockContext *smblock.Con } func (b *block) State() (database.Database, error) { - if b.id == b.chain.lastAccepted { + if b.id == b.chain.lastAcceptedID { return b.chain.acceptedState, nil } // States of accepted blocks other than the lastAccepted are undefined. - if b.Status() == choices.Accepted { + if b.Height() <= b.chain.lastAcceptedHeight { return nil, errMissingState } @@ -194,26 +183,3 @@ func (b *block) State() (database.Database, error) { return b.state, nil } - -func (b *block) calculateStatus() choices.Status { - if b.chain.lastAccepted == b.id { - return choices.Accepted - } - if _, ok := b.chain.verifiedBlocks[b.id]; ok { - return choices.Processing - } - - _, err := state.GetBlock(b.chain.acceptedState, b.id) - switch { - case err == nil: - return choices.Accepted - - case errors.Is(err, database.ErrNotFound): - // This block hasn't been verified yet. - return choices.Processing - - default: - // TODO: correctly report this error to the consensus engine. - return choices.Processing - } -} diff --git a/vms/example/xsvm/chain/chain.go b/vms/example/xsvm/chain/chain.go index 7fc60261d159..c2d8055b2eab 100644 --- a/vms/example/xsvm/chain/chain.go +++ b/vms/example/xsvm/chain/chain.go @@ -7,7 +7,6 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/vms/example/xsvm/state" xsblock "github.com/ava-labs/avalanchego/vms/example/xsvm/block" @@ -32,8 +31,9 @@ type chain struct { // chain state as driven by the consensus engine chainState snow.State - lastAccepted ids.ID - verifiedBlocks map[ids.ID]*block + lastAcceptedID ids.ID + lastAcceptedHeight uint64 + verifiedBlocks map[ids.ID]*block } func New(ctx *snow.Context, db database.Database) (Chain, error) { @@ -46,12 +46,17 @@ func New(ctx *snow.Context, db database.Database) (Chain, error) { } c := &chain{ - chainContext: ctx, - acceptedState: db, - lastAccepted: lastAcceptedID, + chainContext: ctx, + acceptedState: db, + lastAcceptedID: lastAcceptedID, } lastAccepted, err := c.getBlock(lastAcceptedID) + if err != nil { + return nil, err + } + + c.lastAcceptedHeight = lastAccepted.Height() c.verifiedBlocks = map[ids.ID]*block{ lastAcceptedID: lastAccepted, } @@ -59,7 +64,7 @@ func New(ctx *snow.Context, db database.Database) (Chain, error) { } func (c *chain) LastAccepted() ids.ID { - return c.lastAccepted + return c.lastAcceptedID } func (c *chain) SetChainState(state snow.State) { @@ -111,7 +116,6 @@ func (c *chain) getBlock(blkID ids.ID) (*block, error) { Stateless: stateless, chain: c, id: blkID, - status: choices.Accepted, bytes: blkBytes, }, nil } diff --git a/vms/proposervm/batched_vm.go b/vms/proposervm/batched_vm.go index 3a491dda904e..d9512a95ce5e 100644 --- a/vms/proposervm/batched_vm.go +++ b/vms/proposervm/batched_vm.go @@ -159,6 +159,6 @@ func (vm *VM) getStatelessBlk(blkID ids.ID) (statelessblock.Block, error) { if currentBlk, exists := vm.verifiedBlocks[blkID]; exists { return currentBlk.getStatelessBlk(), nil } - statelessBlock, _, err := vm.State.GetBlock(blkID) + statelessBlock, err := vm.State.GetBlock(blkID) return statelessBlock, err } diff --git a/vms/proposervm/state/block_state.go b/vms/proposervm/state/block_state.go index 8e888332e9c2..82f1cf0e5a9e 100644 --- a/vms/proposervm/state/block_state.go +++ b/vms/proposervm/state/block_state.go @@ -29,8 +29,8 @@ var ( ) type BlockState interface { - GetBlock(blkID ids.ID) (block.Block, choices.Status, error) - PutBlock(blk block.Block, status choices.Status) error + GetBlock(blkID ids.ID) (block.Block, error) + PutBlock(blk block.Block) error DeleteBlock(blkID ids.ID) error } @@ -82,47 +82,47 @@ func NewMeteredBlockState(db database.Database, namespace string, metrics promet }, err } -func (s *blockState) GetBlock(blkID ids.ID) (block.Block, choices.Status, error) { +func (s *blockState) GetBlock(blkID ids.ID) (block.Block, error) { if blk, found := s.blkCache.Get(blkID); found { if blk == nil { - return nil, choices.Unknown, database.ErrNotFound + return nil, database.ErrNotFound } - return blk.block, blk.Status, nil + return blk.block, nil } blkWrapperBytes, err := s.db.Get(blkID[:]) if err == database.ErrNotFound { s.blkCache.Put(blkID, nil) - return nil, choices.Unknown, database.ErrNotFound + return nil, database.ErrNotFound } if err != nil { - return nil, choices.Unknown, err + return nil, err } blkWrapper := blockWrapper{} parsedVersion, err := Codec.Unmarshal(blkWrapperBytes, &blkWrapper) if err != nil { - return nil, choices.Unknown, err + return nil, err } if parsedVersion != CodecVersion { - return nil, choices.Unknown, errBlockWrongVersion + return nil, errBlockWrongVersion } // The key was in the database blk, err := block.ParseWithoutVerification(blkWrapper.Block) if err != nil { - return nil, choices.Unknown, err + return nil, err } blkWrapper.block = blk s.blkCache.Put(blkID, &blkWrapper) - return blk, blkWrapper.Status, nil + return blk, nil } -func (s *blockState) PutBlock(blk block.Block, status choices.Status) error { +func (s *blockState) PutBlock(blk block.Block) error { blkWrapper := blockWrapper{ Block: blk.Bytes(), - Status: status, + Status: choices.Accepted, block: blk, } diff --git a/vms/proposervm/state/block_state_test.go b/vms/proposervm/state/block_state_test.go index 33a43c5febae..a04d2ca553e8 100644 --- a/vms/proposervm/state/block_state_test.go +++ b/vms/proposervm/state/block_state_test.go @@ -14,7 +14,6 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/staking" "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -44,22 +43,20 @@ func testBlockState(require *require.Assertions, bs BlockState) { ) require.NoError(err) - _, _, err = bs.GetBlock(b.ID()) + _, err = bs.GetBlock(b.ID()) require.Equal(database.ErrNotFound, err) - _, _, err = bs.GetBlock(b.ID()) + _, err = bs.GetBlock(b.ID()) require.Equal(database.ErrNotFound, err) - require.NoError(bs.PutBlock(b, choices.Accepted)) + require.NoError(bs.PutBlock(b)) - fetchedBlock, fetchedStatus, err := bs.GetBlock(b.ID()) + fetchedBlock, err := bs.GetBlock(b.ID()) require.NoError(err) - require.Equal(choices.Accepted, fetchedStatus) require.Equal(b.Bytes(), fetchedBlock.Bytes()) - fetchedBlock, fetchedStatus, err = bs.GetBlock(b.ID()) + fetchedBlock, err = bs.GetBlock(b.ID()) require.NoError(err) - require.Equal(choices.Accepted, fetchedStatus) require.Equal(b.Bytes(), fetchedBlock.Bytes()) } diff --git a/vms/proposervm/vm.go b/vms/proposervm/vm.go index c5f890b56de2..969c3f2ec673 100644 --- a/vms/proposervm/vm.go +++ b/vms/proposervm/vm.go @@ -19,7 +19,6 @@ import ( "github.com/ava-labs/avalanchego/database/versiondb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" @@ -579,7 +578,7 @@ func (vm *VM) getPostForkBlock(ctx context.Context, blkID ids.ID) (PostForkBlock return block, nil } - statelessBlock, _, err := vm.State.GetBlock(blkID) + statelessBlock, err := vm.State.GetBlock(blkID) if err != nil { return nil, err } @@ -627,7 +626,7 @@ func (vm *VM) acceptPostForkBlock(blk PostForkBlock) error { if err := vm.State.SetLastAccepted(blkID); err != nil { return err } - if err := vm.State.PutBlock(blk.getStatelessBlk(), choices.Accepted); err != nil { + if err := vm.State.PutBlock(blk.getStatelessBlk()); err != nil { return err } if err := vm.updateHeightIndex(height, blkID); err != nil { From c8f12b3dbed988a498adec64f4a03e383cdce11d Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Sun, 30 Jun 2024 16:37:20 -0400 Subject: [PATCH 03/24] Remove Status call from chain state --- vms/components/chain/state.go | 26 +----- vms/components/chain/state_test.go | 122 ++++++++++++++++------------- vms/rpcchainvm/vm_client.go | 1 + 3 files changed, 69 insertions(+), 80 deletions(-) diff --git a/vms/components/chain/state.go b/vms/components/chain/state.go index 6ada30e73eee..2ff118ae2cda 100644 --- a/vms/components/chain/state.go +++ b/vms/components/chain/state.go @@ -78,28 +78,15 @@ type Config struct { GetBlockIDAtHeight func(context.Context, uint64) (ids.ID, error) } -// Block is an interface wrapping the normal snowman.Block interface to be used in -// association with passing in a non-nil function to GetBlockIDAtHeight -type Block interface { - snowman.Block - - SetStatus(choices.Status) -} - // produceGetStatus creates a getStatus function that infers the status of a block by using a function // passed in from the VM that gets the block ID at a specific height. It is assumed that for any height // less than or equal to the last accepted block, getBlockIDAtHeight returns the accepted blockID at // the requested height. func produceGetStatus(s *State, getBlockIDAtHeight func(context.Context, uint64) (ids.ID, error)) func(context.Context, snowman.Block) (choices.Status, error) { return func(ctx context.Context, blk snowman.Block) (choices.Status, error) { - internalBlk, ok := blk.(Block) - if !ok { - return choices.Unknown, fmt.Errorf("expected block to match chain Block interface but found block of type %T", blk) - } lastAcceptedHeight := s.lastAcceptedBlock.Height() - blkHeight := internalBlk.Height() + blkHeight := blk.Height() if blkHeight > lastAcceptedHeight { - internalBlk.SetStatus(choices.Processing) return choices.Processing, nil } @@ -107,16 +94,13 @@ func produceGetStatus(s *State, getBlockIDAtHeight func(context.Context, uint64) switch err { case nil: if acceptedID == blk.ID() { - internalBlk.SetStatus(choices.Accepted) return choices.Accepted, nil } - internalBlk.SetStatus(choices.Rejected) return choices.Rejected, nil case database.ErrNotFound: // Not found can happen if chain history is missing. In this case, // the block may have been accepted or rejected, it isn't possible // to know here. - internalBlk.SetStatus(choices.Processing) return choices.Processing, nil default: return choices.Unknown, fmt.Errorf("%w: failed to get accepted blkID at height %d", err, blkHeight) @@ -131,13 +115,7 @@ func (s *State) initialize(config *Config) { s.buildBlockWithContext = config.BuildBlockWithContext s.unmarshalBlock = config.UnmarshalBlock s.batchedUnmarshalBlock = config.BatchedUnmarshalBlock - if config.GetBlockIDAtHeight == nil { - s.getStatus = func(_ context.Context, blk snowman.Block) (choices.Status, error) { - return blk.Status(), nil - } - } else { - s.getStatus = produceGetStatus(s, config.GetBlockIDAtHeight) - } + s.getStatus = produceGetStatus(s, config.GetBlockIDAtHeight) s.lastAcceptedBlock = &BlockWrapper{ Block: config.LastAcceptedBlock, state: s, diff --git a/vms/components/chain/state_test.go b/vms/components/chain/state_test.go index e4376be502aa..bd8619c020e0 100644 --- a/vms/components/chain/state_test.go +++ b/vms/components/chain/state_test.go @@ -123,7 +123,6 @@ func checkProcessingBlock(t *testing.T, s *State, blk snowman.Block) { require.NoError(err) require.Equal(blk.ID(), parsedBlk.ID()) require.Equal(blk.Bytes(), parsedBlk.Bytes()) - require.Equal(choices.Processing, parsedBlk.Status()) require.Equal(blk, parsedBlk) getBlk, err := s.GetBlock(context.Background(), blk.ID()) @@ -133,16 +132,24 @@ func checkProcessingBlock(t *testing.T, s *State, blk snowman.Block) { // checkDecidedBlock asserts that [blk] is returned with the correct status by ParseBlock // and GetBlock. +// expectedStatus should be either Accepted or Rejected. func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus choices.Status, cached bool) { require := require.New(t) require.IsType(&BlockWrapper{}, blk) + if cached { + _, ok := s.decidedBlocks.Get(blk.ID()) + require.True(ok) + } + parsedBlk, err := s.ParseBlock(context.Background(), blk.Bytes()) require.NoError(err) require.Equal(blk.ID(), parsedBlk.ID()) require.Equal(blk.Bytes(), parsedBlk.Bytes()) - require.Equal(expectedStatus, parsedBlk.Status()) + + _, ok := s.decidedBlocks.Get(blk.ID()) + require.True(ok) // If the block should be in the cache, assert that the returned block is identical to [blk] if cached { @@ -153,7 +160,6 @@ func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus require.NoError(err) require.Equal(blk.ID(), getBlk.ID()) require.Equal(blk.Bytes(), getBlk.Bytes()) - require.Equal(expectedStatus, getBlk.Status()) // Since ParseBlock should have triggered a cache hit, assert that the block is identical // to the parsed block. @@ -183,10 +189,10 @@ func TestState(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -268,10 +274,10 @@ func TestBuildBlock(t *testing.T) { } chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -307,10 +313,10 @@ func TestStateDecideBlock(t *testing.T) { badRejectBlk.RejectV = errReject getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -360,10 +366,10 @@ func TestStateParent(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -401,10 +407,10 @@ func TestGetBlockInternal(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -440,10 +446,10 @@ func TestGetBlockError(t *testing.T) { return blk, nil } chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: wrappedGetBlock, UnmarshalBlock: parseBlock, @@ -470,10 +476,10 @@ func TestParseBlockError(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -492,10 +498,10 @@ func TestBuildBlockError(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -518,10 +524,10 @@ func TestMeteredCache(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) config := &Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -605,11 +611,15 @@ func TestSetLastAcceptedBlock(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - LastAcceptedBlock: genesisBlock, - GetBlock: getBlock, - UnmarshalBlock: parseBlock, - BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, + LastAcceptedBlock: genesisBlock, + GetBlock: getBlock, + UnmarshalBlock: parseBlock, + BuildBlock: cantBuildBlock, + GetBlockIDAtHeight: getCanonicalBlockID, }) lastAcceptedID, err := chainState.LastAccepted(context.Background()) require.NoError(err) @@ -652,10 +662,10 @@ func TestSetLastAcceptedBlockWithProcessingBlocksErrors(t *testing.T) { } chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -688,10 +698,10 @@ func TestStateParseTransitivelyAcceptedBlock(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: blk2, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -714,10 +724,10 @@ func TestIsProcessing(t *testing.T) { getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 2, - MissingCacheSize: 2, - UnverifiedCacheSize: 2, - BytesToIDCacheSize: 2, + DecidedCacheSize: 256, + MissingCacheSize: 256, + UnverifiedCacheSize: 256, + BytesToIDCacheSize: 256, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, diff --git a/vms/rpcchainvm/vm_client.go b/vms/rpcchainvm/vm_client.go index 7fe4e9b0f050..190a748b59ef 100644 --- a/vms/rpcchainvm/vm_client.go +++ b/vms/rpcchainvm/vm_client.go @@ -240,6 +240,7 @@ func (vm *VMClient) Initialize( BatchedUnmarshalBlock: vm.batchedParseBlock, BuildBlock: vm.buildBlock, BuildBlockWithContext: vm.buildBlockWithContext, + GetBlockIDAtHeight: vm.GetBlockIDAtHeight, }, ) return err From 7c09e1fdae82f369cf4b8195ee7234b9cec6b8d7 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Sun, 30 Jun 2024 16:49:09 -0400 Subject: [PATCH 04/24] Remove GetBlockIDAtHeight --- vms/components/chain/state.go | 47 ++---------------------- vms/components/chain/state_test.go | 58 ++++++++---------------------- vms/rpcchainvm/vm_client.go | 1 - 3 files changed, 17 insertions(+), 89 deletions(-) diff --git a/vms/components/chain/state.go b/vms/components/chain/state.go index 2ff118ae2cda..0fa80f2295d6 100644 --- a/vms/components/chain/state.go +++ b/vms/components/chain/state.go @@ -14,7 +14,6 @@ import ( "github.com/ava-labs/avalanchego/cache/metercacher" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/utils/constants" @@ -46,9 +45,6 @@ type State struct { // If nil, [BuildBlockWithContext] returns [BuildBlock]. buildBlockWithContext func(context.Context, *block.Context) (snowman.Block, error) - // getStatus returns the status of the block - getStatus func(context.Context, snowman.Block) (choices.Status, error) - // verifiedBlocks is a map of blocks that have been verified and are // therefore currently in consensus. verifiedBlocks map[ids.ID]*BlockWrapper @@ -75,37 +71,6 @@ type Config struct { BatchedUnmarshalBlock func(context.Context, [][]byte) ([]snowman.Block, error) BuildBlock func(context.Context) (snowman.Block, error) BuildBlockWithContext func(context.Context, *block.Context) (snowman.Block, error) - GetBlockIDAtHeight func(context.Context, uint64) (ids.ID, error) -} - -// produceGetStatus creates a getStatus function that infers the status of a block by using a function -// passed in from the VM that gets the block ID at a specific height. It is assumed that for any height -// less than or equal to the last accepted block, getBlockIDAtHeight returns the accepted blockID at -// the requested height. -func produceGetStatus(s *State, getBlockIDAtHeight func(context.Context, uint64) (ids.ID, error)) func(context.Context, snowman.Block) (choices.Status, error) { - return func(ctx context.Context, blk snowman.Block) (choices.Status, error) { - lastAcceptedHeight := s.lastAcceptedBlock.Height() - blkHeight := blk.Height() - if blkHeight > lastAcceptedHeight { - return choices.Processing, nil - } - - acceptedID, err := getBlockIDAtHeight(ctx, blkHeight) - switch err { - case nil: - if acceptedID == blk.ID() { - return choices.Accepted, nil - } - return choices.Rejected, nil - case database.ErrNotFound: - // Not found can happen if chain history is missing. In this case, - // the block may have been accepted or rejected, it isn't possible - // to know here. - return choices.Processing, nil - default: - return choices.Unknown, fmt.Errorf("%w: failed to get accepted blkID at height %d", err, blkHeight) - } - } } func (s *State) initialize(config *Config) { @@ -115,7 +80,6 @@ func (s *State) initialize(config *Config) { s.buildBlockWithContext = config.BuildBlockWithContext s.unmarshalBlock = config.UnmarshalBlock s.batchedUnmarshalBlock = config.BatchedUnmarshalBlock - s.getStatus = produceGetStatus(s, config.GetBlockIDAtHeight) s.lastAcceptedBlock = &BlockWrapper{ Block: config.LastAcceptedBlock, state: s, @@ -464,17 +428,10 @@ func (s *State) addBlockOutsideConsensus(ctx context.Context, blk snowman.Block) } blkID := blk.ID() - status, err := s.getStatus(ctx, blk) - if err != nil { - return nil, fmt.Errorf("could not get block status for %s due to %w", blkID, err) - } - switch status { - case choices.Accepted, choices.Rejected: + if blk.Height() <= s.lastAcceptedBlock.Height() { s.decidedBlocks.Put(blkID, wrappedBlk) - case choices.Processing: + } else { s.unverifiedBlocks.Put(blkID, wrappedBlk) - default: - return nil, fmt.Errorf("found unexpected status for blk %s: %s", blkID, status) } return wrappedBlk, nil diff --git a/vms/components/chain/state_test.go b/vms/components/chain/state_test.go index bd8619c020e0..6402ec06bbc5 100644 --- a/vms/components/chain/state_test.go +++ b/vms/components/chain/state_test.go @@ -60,7 +60,6 @@ func NewTestBlocks(numBlocks uint64) []*snowmantest.Block { func createInternalBlockFuncs(blks []*snowmantest.Block) ( func(ctx context.Context, blkID ids.ID) (snowman.Block, error), func(ctx context.Context, b []byte) (snowman.Block, error), - func(ctx context.Context, height uint64) (ids.ID, error), ) { blkMap := make(map[ids.ID]*snowmantest.Block) blkBytesMap := make(map[string]*snowmantest.Block) @@ -91,21 +90,8 @@ func createInternalBlockFuncs(blks []*snowmantest.Block) ( return blk, nil } - getAcceptedBlockIDAtHeight := func(_ context.Context, height uint64) (ids.ID, error) { - for _, blk := range blks { - if blk.Height() != height { - continue - } - - if blk.Status() == choices.Accepted { - return blk.ID(), nil - } - } - - return ids.ID{}, database.ErrNotFound - } - return getBlock, parseBlk, getAcceptedBlockIDAtHeight + return getBlock, parseBlk } func cantBuildBlock(context.Context) (snowman.Block, error) { @@ -187,7 +173,7 @@ func TestState(t *testing.T) { blk3 := snowmantest.BuildChild(blk1) testBlks = append(testBlks, blk3) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -197,7 +183,6 @@ func TestState(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) lastAccepted, err := chainState.LastAccepted(context.Background()) @@ -266,7 +251,7 @@ func TestBuildBlock(t *testing.T) { genesisBlock.SetStatus(choices.Accepted) blk1 := testBlks[1] - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) buildBlock := func(context.Context) (snowman.Block, error) { // Once the block is built, mark it as processing blk1.SetStatus(choices.Processing) @@ -282,7 +267,6 @@ func TestBuildBlock(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: buildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) builtBlk, err := chainState.BuildBlock(context.Background()) @@ -311,7 +295,7 @@ func TestStateDecideBlock(t *testing.T) { badVerifyBlk.VerifyV = errVerify badRejectBlk := testBlks[3] badRejectBlk.RejectV = errReject - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -321,7 +305,6 @@ func TestStateDecideBlock(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) // Parse badVerifyBlk (which should fail verification) @@ -364,7 +347,7 @@ func TestStateParent(t *testing.T) { blk1 := testBlks[1] blk2 := testBlks[2] - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -374,7 +357,6 @@ func TestStateParent(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) parsedBlk2, err := chainState.ParseBlock(context.Background(), blk2.Bytes()) @@ -405,7 +387,7 @@ func TestGetBlockInternal(t *testing.T) { genesisBlock := testBlks[0] genesisBlock.SetStatus(choices.Accepted) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -415,7 +397,6 @@ func TestGetBlockInternal(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) genesisBlockInternal := chainState.LastAcceptedBlockInternal() @@ -437,7 +418,7 @@ func TestGetBlockError(t *testing.T) { genesisBlock.SetStatus(choices.Accepted) blk1 := testBlks[1] - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) wrappedGetBlock := func(ctx context.Context, id ids.ID) (snowman.Block, error) { blk, err := getBlock(ctx, id) if err != nil { @@ -454,7 +435,6 @@ func TestGetBlockError(t *testing.T) { GetBlock: wrappedGetBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) _, err := chainState.GetBlock(context.Background(), blk1.ID()) @@ -474,7 +454,7 @@ func TestParseBlockError(t *testing.T) { genesisBlock := testBlks[0] genesisBlock.SetStatus(choices.Accepted) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -484,7 +464,6 @@ func TestParseBlockError(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) _, err := chainState.ParseBlock(context.Background(), []byte{255}) @@ -496,7 +475,7 @@ func TestBuildBlockError(t *testing.T) { genesisBlock := testBlks[0] genesisBlock.SetStatus(choices.Accepted) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -506,7 +485,6 @@ func TestBuildBlockError(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) _, err := chainState.BuildBlock(context.Background()) @@ -522,7 +500,7 @@ func TestMeteredCache(t *testing.T) { genesisBlock := testBlks[0] genesisBlock.SetStatus(choices.Accepted) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) config := &Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -532,7 +510,6 @@ func TestMeteredCache(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, } _, err := NewMeteredState(registry, config) require.NoError(err) @@ -550,7 +527,7 @@ func TestStateBytesToIDCache(t *testing.T) { blk1 := testBlks[1] blk2 := testBlks[2] - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) buildBlock := func(context.Context) (snowman.Block, error) { require.FailNow("shouldn't have been called") return nil, nil @@ -565,7 +542,6 @@ func TestStateBytesToIDCache(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: buildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) // Shouldn't have blk1 ID to start with @@ -609,7 +585,7 @@ func TestSetLastAcceptedBlock(t *testing.T) { // note we do not need to parse postSetBlk1 so it is omitted here testBlks = append(testBlks, postSetBlk2) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -619,7 +595,6 @@ func TestSetLastAcceptedBlock(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) lastAcceptedID, err := chainState.LastAccepted(context.Background()) require.NoError(err) @@ -654,7 +629,7 @@ func TestSetLastAcceptedBlockWithProcessingBlocksErrors(t *testing.T) { blk1 := testBlks[1] resetBlk := testBlks[4] - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) buildBlock := func(context.Context) (snowman.Block, error) { // Once the block is built, mark it as processing blk1.SetStatus(choices.Processing) @@ -670,7 +645,6 @@ func TestSetLastAcceptedBlockWithProcessingBlocksErrors(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: buildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) builtBlk, err := chainState.BuildBlock(context.Background()) @@ -696,7 +670,7 @@ func TestStateParseTransitivelyAcceptedBlock(t *testing.T) { blk2 := testBlks[2] blk2.SetStatus(choices.Accepted) - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -706,7 +680,6 @@ func TestStateParseTransitivelyAcceptedBlock(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) parsedBlk1, err := chainState.ParseBlock(context.Background(), blk1.Bytes()) @@ -722,7 +695,7 @@ func TestIsProcessing(t *testing.T) { genesisBlock.SetStatus(choices.Accepted) blk1 := testBlks[1] - getBlock, parseBlock, getCanonicalBlockID := createInternalBlockFuncs(testBlks) + getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ DecidedCacheSize: 256, MissingCacheSize: 256, @@ -732,7 +705,6 @@ func TestIsProcessing(t *testing.T) { GetBlock: getBlock, UnmarshalBlock: parseBlock, BuildBlock: cantBuildBlock, - GetBlockIDAtHeight: getCanonicalBlockID, }) // Parse blk1 diff --git a/vms/rpcchainvm/vm_client.go b/vms/rpcchainvm/vm_client.go index 190a748b59ef..7fe4e9b0f050 100644 --- a/vms/rpcchainvm/vm_client.go +++ b/vms/rpcchainvm/vm_client.go @@ -240,7 +240,6 @@ func (vm *VMClient) Initialize( BatchedUnmarshalBlock: vm.batchedParseBlock, BuildBlock: vm.buildBlock, BuildBlockWithContext: vm.buildBlockWithContext, - GetBlockIDAtHeight: vm.GetBlockIDAtHeight, }, ) return err From eff75228bf02b06141f67b3658af11aa177d5735 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 16:49:15 -0400 Subject: [PATCH 05/24] Remove status from the proposervm --- snow/consensus/snowman/snowmantest/engine.go | 29 +++ .../snowman/snowmantest/mock_block.go | 15 -- .../snowman/bootstrap/bootstrapper_test.go | 23 +-- snow/engine/snowman/transitive_test.go | 95 ++++------ vms/proposervm/batched_vm_test.go | 6 +- vms/proposervm/mock_post_fork_block.go | 27 --- vms/proposervm/post_fork_block_test.go | 18 +- vms/proposervm/post_fork_option_test.go | 49 ++--- vms/proposervm/pre_fork_block_test.go | 24 ++- vms/proposervm/state/mock_state.go | 16 +- vms/proposervm/state_syncable_vm_test.go | 12 +- vms/proposervm/vm_byzantine_test.go | 171 +----------------- vms/proposervm/vm_test.go | 133 ++++---------- 13 files changed, 164 insertions(+), 454 deletions(-) create mode 100644 snow/consensus/snowman/snowmantest/engine.go diff --git a/snow/consensus/snowman/snowmantest/engine.go b/snow/consensus/snowman/snowmantest/engine.go new file mode 100644 index 000000000000..705dd0fd46dd --- /dev/null +++ b/snow/consensus/snowman/snowmantest/engine.go @@ -0,0 +1,29 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package snowmantest + +import ( + "context" + + "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow/choices" +) + +func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, error) { + return func(_ context.Context) (ids.ID, error) { + var ( + highestHeight uint64 + highestID ids.ID + ) + for _, blks := range blks { + for _, blk := range blks { + if blk.Status() == choices.Accepted && blk.Height() >= highestHeight { + highestHeight = blk.Height() + highestID = blk.ID() + } + } + } + return highestID, nil + } +} diff --git a/snow/consensus/snowman/snowmantest/mock_block.go b/snow/consensus/snowman/snowmantest/mock_block.go index 4c1a4ae7beec..233e979e3a86 100644 --- a/snow/consensus/snowman/snowmantest/mock_block.go +++ b/snow/consensus/snowman/snowmantest/mock_block.go @@ -15,7 +15,6 @@ import ( time "time" ids "github.com/ava-labs/avalanchego/ids" - choices "github.com/ava-labs/avalanchego/snow/choices" gomock "go.uber.org/mock/gomock" ) @@ -126,20 +125,6 @@ func (mr *MockBlockMockRecorder) Reject(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reject", reflect.TypeOf((*MockBlock)(nil).Reject), arg0) } -// Status mocks base method. -func (m *MockBlock) Status() choices.Status { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Status") - ret0, _ := ret[0].(choices.Status) - return ret0 -} - -// Status indicates an expected call of Status. -func (mr *MockBlockMockRecorder) Status() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Status", reflect.TypeOf((*MockBlock)(nil).Status)) -} - // Timestamp mocks base method. func (m *MockBlock) Timestamp() time.Time { m.ctrl.T.Helper() diff --git a/snow/engine/snowman/bootstrap/bootstrapper_test.go b/snow/engine/snowman/bootstrap/bootstrapper_test.go index 5577f62fa81d..1473294a9949 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper_test.go +++ b/snow/engine/snowman/bootstrap/bootstrapper_test.go @@ -155,9 +155,9 @@ func TestBootstrapperStartsOnlyIfEnoughStakeIsConnected(t *testing.T) { } vm.CantLastAccepted = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, blkID) return snowmantest.Genesis, nil @@ -775,20 +775,9 @@ func TestBootstrapperRollbackOnSetState(t *testing.T) { func initializeVMWithBlockchain(vm *block.TestVM, blocks []*snowmantest.Block) { vm.CantSetState = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - var ( - lastAcceptedID ids.ID - lastAcceptedHeight uint64 - ) - for _, blk := range blocks { - height := blk.Height() - if blk.Status() == choices.Accepted && height >= lastAcceptedHeight { - lastAcceptedID = blk.ID() - lastAcceptedHeight = height - } - } - return lastAcceptedID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + blocks, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { for _, blk := range blocks { if blk.Status() == choices.Accepted && blk.ID() == blkID { diff --git a/snow/engine/snowman/transitive_test.go b/snow/engine/snowman/transitive_test.go index 310a472b8009..8fdab1afc177 100644 --- a/snow/engine/snowman/transitive_test.go +++ b/snow/engine/snowman/transitive_test.go @@ -65,22 +65,6 @@ func MakeParseBlockF(blks ...[]*snowmantest.Block) func(context.Context, []byte) } } -func MakeLastAcceptedBlockF(defaultBlk *snowmantest.Block, blks ...[]*snowmantest.Block) func(context.Context) (ids.ID, error) { - return func(_ context.Context) (ids.ID, error) { - highestHeight := defaultBlk.Height() - highestID := defaultBlk.ID() - for _, blkSet := range blks { - for _, blk := range blkSet { - if blk.Status() == choices.Accepted && blk.Height() > highestHeight { - highestHeight = blk.Height() - highestID = blk.ID() - } - } - } - return highestID, nil - } -} - func setup(t *testing.T, config Config) (ids.NodeID, validators.Manager, *common.SenderTest, *block.TestVM, *Transitive) { require := require.New(t) @@ -112,10 +96,9 @@ func setup(t *testing.T, config Config) (ids.NodeID, validators.Manager, *common vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } - + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: @@ -356,9 +339,9 @@ func TestEngineMultipleQuery(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, blkID) return snowmantest.Genesis, nil @@ -680,9 +663,9 @@ func TestVoteCanceling(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, id ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, id) return snowmantest.Genesis, nil @@ -743,9 +726,9 @@ func TestEngineNoQuery(t *testing.T) { vm := &block.TestVM{} vm.T = t - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { if blkID == snowmantest.GenesisID { @@ -783,9 +766,9 @@ func TestEngineNoRepollQuery(t *testing.T) { vm := &block.TestVM{} vm.T = t - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { if blkID == snowmantest.GenesisID { @@ -1234,9 +1217,9 @@ func TestEngineGossip(t *testing.T) { nodeID, _, sender, vm, te := setup(t, DefaultConfig(t)) - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, blkID) return snowmantest.Genesis, nil @@ -1430,9 +1413,9 @@ func TestEngineAggressivePolling(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, blkID) return snowmantest.Genesis, nil @@ -1518,9 +1501,9 @@ func TestEngineDoubleChit(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, id ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, id) return snowmantest.Genesis, nil @@ -1604,9 +1587,9 @@ func TestEngineBuildBlockLimit(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, blkID) return snowmantest.Genesis, nil @@ -2189,9 +2172,9 @@ func TestEngineApplyAcceptedFrontierInQueryFailed(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, id ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, id) return snowmantest.Genesis, nil @@ -2283,9 +2266,9 @@ func TestEngineRepollsMisconfiguredSubnet(t *testing.T) { vm.CantSetState = false vm.CantSetPreference = false - vm.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) vm.GetBlockF = func(_ context.Context, id ids.ID) (snowman.Block, error) { require.Equal(snowmantest.GenesisID, id) return snowmantest.Genesis, nil @@ -2451,8 +2434,8 @@ func TestEngineVoteStallRegression(t *testing.T) { SetPreferenceF: func(context.Context, ids.ID) error { return nil }, - LastAcceptedF: MakeLastAcceptedBlockF( - snowmantest.Genesis, + LastAcceptedF: snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, acceptedChain, ), } @@ -2667,8 +2650,8 @@ func TestEngineEarlyTerminateVoterRegression(t *testing.T) { SetPreferenceF: func(context.Context, ids.ID) error { return nil }, - LastAcceptedF: MakeLastAcceptedBlockF( - snowmantest.Genesis, + LastAcceptedF: snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, chain, ), } @@ -2819,8 +2802,8 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) { SetPreferenceF: func(context.Context, ids.ID) error { return nil }, - LastAcceptedF: MakeLastAcceptedBlockF( - snowmantest.Genesis, + LastAcceptedF: snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, acceptedChain, rejectedChain, ), diff --git a/vms/proposervm/batched_vm_test.go b/vms/proposervm/batched_vm_test.go index be134823c894..458aad628f1c 100644 --- a/vms/proposervm/batched_vm_test.go +++ b/vms/proposervm/batched_vm_test.go @@ -839,9 +839,9 @@ func initTestRemoteProposerVM( ) error { return nil } - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: diff --git a/vms/proposervm/mock_post_fork_block.go b/vms/proposervm/mock_post_fork_block.go index ab449b6363bf..7957a91b457d 100644 --- a/vms/proposervm/mock_post_fork_block.go +++ b/vms/proposervm/mock_post_fork_block.go @@ -15,7 +15,6 @@ import ( time "time" ids "github.com/ava-labs/avalanchego/ids" - choices "github.com/ava-labs/avalanchego/snow/choices" snowman "github.com/ava-labs/avalanchego/snow/consensus/snowman" block "github.com/ava-labs/avalanchego/vms/proposervm/block" gomock "go.uber.org/mock/gomock" @@ -128,20 +127,6 @@ func (mr *MockPostForkBlockMockRecorder) Reject(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reject", reflect.TypeOf((*MockPostForkBlock)(nil).Reject), arg0) } -// Status mocks base method. -func (m *MockPostForkBlock) Status() choices.Status { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Status") - ret0, _ := ret[0].(choices.Status) - return ret0 -} - -// Status indicates an expected call of Status. -func (mr *MockPostForkBlockMockRecorder) Status() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Status", reflect.TypeOf((*MockPostForkBlock)(nil).Status)) -} - // Timestamp mocks base method. func (m *MockPostForkBlock) Timestamp() time.Time { m.ctrl.T.Helper() @@ -268,18 +253,6 @@ func (mr *MockPostForkBlockMockRecorder) setInnerBlk(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setInnerBlk", reflect.TypeOf((*MockPostForkBlock)(nil).setInnerBlk), arg0) } -// setStatus mocks base method. -func (m *MockPostForkBlock) setStatus(arg0 choices.Status) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "setStatus", arg0) -} - -// setStatus indicates an expected call of setStatus. -func (mr *MockPostForkBlockMockRecorder) setStatus(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "setStatus", reflect.TypeOf((*MockPostForkBlock)(nil).setStatus), arg0) -} - // verifyPostForkChild mocks base method. func (m *MockPostForkBlock) verifyPostForkChild(arg0 context.Context, arg1 *postForkBlock) error { m.ctrl.T.Helper() diff --git a/vms/proposervm/post_fork_block_test.go b/vms/proposervm/post_fork_block_test.go index 462132f8446b..f59463a77049 100644 --- a/vms/proposervm/post_fork_block_test.go +++ b/vms/proposervm/post_fork_block_test.go @@ -56,7 +56,7 @@ func TestOracle_PostForkBlock_ImplementsInterface(t *testing.T) { innerTestBlock := snowmantest.BuildChild(snowmantest.Genesis) innerOracleBlk := &TestOptionsBlock{ Block: *innerTestBlock, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(innerTestBlock), snowmantest.BuildChild(innerTestBlock), }, @@ -657,7 +657,7 @@ func TestBlockVerify_PostForkBlockBuiltOnOption_PChainHeightChecks(t *testing.T) Block: *innerTestBlock, } preferredOracleBlkChild := snowmantest.BuildChild(innerTestBlock) - oracleCoreBlk.opts = [2]snowman.Block{ + oracleCoreBlk.opts = [2]*snowmantest.Block{ preferredOracleBlkChild, snowmantest.BuildChild(innerTestBlock), } @@ -907,12 +907,12 @@ func TestBlockAccept_PostForkBlock_SetsLastAcceptedBlock(t *testing.T) { // test require.NoError(builtBlk.Accept(context.Background())) - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - if coreBlk.Status() == choices.Accepted { - return coreBlk.ID(), nil - } - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{ + snowmantest.Genesis, + coreBlk, + }, + ) acceptedID, err := proVM.LastAccepted(context.Background()) require.NoError(err) require.Equal(builtBlk.ID(), acceptedID) @@ -1003,7 +1003,7 @@ func TestBlockVerify_PostForkBlock_ShouldBePostForkOption(t *testing.T) { coreTestBlk := snowmantest.BuildChild(snowmantest.Genesis) oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(coreTestBlk), snowmantest.BuildChild(coreTestBlk), }, diff --git a/vms/proposervm/post_fork_option_test.go b/vms/proposervm/post_fork_option_test.go index 43b7d5f5b90f..30ee4ea91c54 100644 --- a/vms/proposervm/post_fork_option_test.go +++ b/vms/proposervm/post_fork_option_test.go @@ -26,12 +26,12 @@ var _ snowman.OracleBlock = (*TestOptionsBlock)(nil) type TestOptionsBlock struct { snowmantest.Block - opts [2]snowman.Block + opts [2]*snowmantest.Block optsErr error } func (tob TestOptionsBlock) Options(context.Context) ([2]snowman.Block, error) { - return tob.opts, tob.optsErr + return [2]snowman.Block{tob.opts[0], tob.opts[1]}, tob.optsErr } // ProposerBlock.Verify tests section @@ -52,7 +52,7 @@ func TestBlockVerify_PostForkOption_ParentChecks(t *testing.T) { preferredBlk := snowmantest.BuildChild(coreTestBlk) oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ preferredBlk, snowmantest.BuildChild(coreTestBlk), }, @@ -142,7 +142,7 @@ func TestBlockVerify_PostForkOption_CoreBlockVerifyIsCalledOnce(t *testing.T) { coreOpt1 := snowmantest.BuildChild(coreTestBlk) oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ coreOpt0, coreOpt1, }, @@ -222,7 +222,7 @@ func TestBlockAccept_PostForkOption_SetsLastAcceptedBlock(t *testing.T) { coreTestBlk := snowmantest.BuildChild(snowmantest.Genesis) oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(coreTestBlk), snowmantest.BuildChild(coreTestBlk), }, @@ -266,12 +266,13 @@ func TestBlockAccept_PostForkOption_SetsLastAcceptedBlock(t *testing.T) { // accept oracle block require.NoError(parentBlk.Accept(context.Background())) - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - if oracleCoreBlk.Status() == choices.Accepted { - return oracleCoreBlk.ID(), nil - } - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{ + snowmantest.Genesis, + &oracleCoreBlk.Block, + }, + oracleCoreBlk.opts[:], + ) acceptedID, err := proVM.LastAccepted(context.Background()) require.NoError(err) require.Equal(parentBlk.ID(), acceptedID) @@ -284,12 +285,6 @@ func TestBlockAccept_PostForkOption_SetsLastAcceptedBlock(t *testing.T) { require.NoError(opts[0].Accept(context.Background())) - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - if oracleCoreBlk.opts[0].Status() == choices.Accepted { - return oracleCoreBlk.opts[0].ID(), nil - } - return oracleCoreBlk.ID(), nil - } acceptedID, err = proVM.LastAccepted(context.Background()) require.NoError(err) require.Equal(opts[0].ID(), acceptedID) @@ -312,7 +307,7 @@ func TestBlockReject_InnerBlockIsNotRejected(t *testing.T) { coreTestBlk := snowmantest.BuildChild(snowmantest.Genesis) oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(coreTestBlk), snowmantest.BuildChild(coreTestBlk), }, @@ -355,12 +350,7 @@ func TestBlockReject_InnerBlockIsNotRejected(t *testing.T) { // reject oracle block require.NoError(builtBlk.Reject(context.Background())) - require.IsType(&postForkBlock{}, builtBlk) - proBlk := builtBlk.(*postForkBlock) - - require.Equal(choices.Rejected, proBlk.Status()) - - require.NotEqual(choices.Rejected, proBlk.innerBlk.Status()) + require.NotEqual(choices.Rejected, oracleCoreBlk.Status()) // reject an option require.IsType(&postForkBlock{}, builtBlk) @@ -369,12 +359,7 @@ func TestBlockReject_InnerBlockIsNotRejected(t *testing.T) { require.NoError(err) require.NoError(opts[0].Reject(context.Background())) - require.IsType(&postForkOption{}, opts[0]) - proOpt := opts[0].(*postForkOption) - - require.Equal(choices.Rejected, proOpt.Status()) - - require.NotEqual(choices.Rejected, proOpt.innerBlk.Status()) + require.NotEqual(choices.Rejected, oracleCoreBlk.opts[0].Status()) } func TestBlockVerify_PostForkOption_ParentIsNotOracleWithError(t *testing.T) { @@ -463,7 +448,7 @@ func TestOptionTimestampValidity(t *testing.T) { coreTestBlk := snowmantest.BuildChild(snowmantest.Genesis) coreOracleBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(coreTestBlk), snowmantest.BuildChild(coreTestBlk), }, @@ -617,7 +602,7 @@ func TestOptionTimestampValidity(t *testing.T) { statefulOptionBlock, err := proVM.ParseBlock(context.Background(), option.Bytes()) require.NoError(err) - require.Equal(choices.Accepted, statefulOptionBlock.Status()) + require.LessOrEqual(statefulOptionBlock.Height(), proVM.lastAcceptedHeight) coreVM.GetBlockF = func(context.Context, ids.ID) (snowman.Block, error) { require.FailNow("called GetBlock when unable to handle the error") diff --git a/vms/proposervm/pre_fork_block_test.go b/vms/proposervm/pre_fork_block_test.go index 892209781e8c..ce12575ef321 100644 --- a/vms/proposervm/pre_fork_block_test.go +++ b/vms/proposervm/pre_fork_block_test.go @@ -65,7 +65,7 @@ func TestOracle_PreForkBlkCanBuiltOnPreForkOption(t *testing.T) { preferredTestBlk := snowmantest.BuildChild(coreTestBlk) oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ preferredTestBlk, snowmantest.BuildChild(coreTestBlk), }, @@ -139,7 +139,7 @@ func TestOracle_PostForkBlkCanBuiltOnPreForkOption(t *testing.T) { oracleCoreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ preferredBlk, unpreferredBlk, }, @@ -294,7 +294,6 @@ func TestBlockVerify_BlocksBuiltOnPreForkGenesis(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: coreBlk, - status: choices.Processing, }, } @@ -439,12 +438,12 @@ func TestBlockAccept_PreFork_SetsLastAcceptedBlock(t *testing.T) { // test require.NoError(builtBlk.Accept(context.Background())) - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - if coreBlk.Status() == choices.Accepted { - return coreBlk.ID(), nil - } - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{ + snowmantest.Genesis, + coreBlk, + }, + ) acceptedID, err := proVM.LastAccepted(context.Background()) require.NoError(err) require.Equal(builtBlk.ID(), acceptedID) @@ -474,8 +473,7 @@ func TestBlockReject_PreForkBlock_InnerBlockIsRejected(t *testing.T) { proBlk := sb.(*preForkBlock) require.NoError(proBlk.Reject(context.Background())) - require.Equal(choices.Rejected, proBlk.Status()) - require.Equal(choices.Rejected, proBlk.Block.Status()) + require.Equal(choices.Rejected, coreBlk.Status()) } func TestBlockVerify_ForkBlockIsOracleBlock(t *testing.T) { @@ -497,7 +495,7 @@ func TestBlockVerify_ForkBlockIsOracleBlock(t *testing.T) { coreTestBlk.TimestampV = postActivationTime coreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(coreTestBlk), snowmantest.BuildChild(coreTestBlk), }, @@ -567,7 +565,7 @@ func TestBlockVerify_ForkBlockIsOracleBlockButChildrenAreSigned(t *testing.T) { coreTestBlk.TimestampV = postActivationTime coreBlk := &TestOptionsBlock{ Block: *coreTestBlk, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(coreTestBlk), snowmantest.BuildChild(coreTestBlk), }, diff --git a/vms/proposervm/state/mock_state.go b/vms/proposervm/state/mock_state.go index ce28025a93e9..e01ab01d93aa 100644 --- a/vms/proposervm/state/mock_state.go +++ b/vms/proposervm/state/mock_state.go @@ -13,7 +13,6 @@ import ( reflect "reflect" ids "github.com/ava-labs/avalanchego/ids" - choices "github.com/ava-labs/avalanchego/snow/choices" block "github.com/ava-labs/avalanchego/vms/proposervm/block" gomock "go.uber.org/mock/gomock" ) @@ -84,13 +83,12 @@ func (mr *MockStateMockRecorder) DeleteLastAccepted() *gomock.Call { } // GetBlock mocks base method. -func (m *MockState) GetBlock(arg0 ids.ID) (block.Block, choices.Status, error) { +func (m *MockState) GetBlock(arg0 ids.ID) (block.Block, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBlock", arg0) ret0, _ := ret[0].(block.Block) - ret1, _ := ret[1].(choices.Status) - ret2, _ := ret[2].(error) - return ret0, ret1, ret2 + ret1, _ := ret[1].(error) + return ret0, ret1 } // GetBlock indicates an expected call of GetBlock. @@ -160,17 +158,17 @@ func (mr *MockStateMockRecorder) GetMinimumHeight() *gomock.Call { } // PutBlock mocks base method. -func (m *MockState) PutBlock(arg0 block.Block, arg1 choices.Status) error { +func (m *MockState) PutBlock(arg0 block.Block) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "PutBlock", arg0, arg1) + ret := m.ctrl.Call(m, "PutBlock", arg0) ret0, _ := ret[0].(error) return ret0 } // PutBlock indicates an expected call of PutBlock. -func (mr *MockStateMockRecorder) PutBlock(arg0, arg1 any) *gomock.Call { +func (mr *MockStateMockRecorder) PutBlock(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutBlock", reflect.TypeOf((*MockState)(nil).PutBlock), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutBlock", reflect.TypeOf((*MockState)(nil).PutBlock), arg0) } // SetBlockIDAtHeight mocks base method. diff --git a/vms/proposervm/state_syncable_vm_test.go b/vms/proposervm/state_syncable_vm_test.go index 479c311b5fed..2327384fc04f 100644 --- a/vms/proposervm/state_syncable_vm_test.go +++ b/vms/proposervm/state_syncable_vm_test.go @@ -16,7 +16,6 @@ import ( "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/common" @@ -48,9 +47,9 @@ func helperBuildStateSyncTestObjects(t *testing.T) (*fullVM, *VM) { ) error { return nil } - innerVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + innerVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) innerVM.GetBlockF = func(context.Context, ids.ID) (snowman.Block, error) { return snowmantest.Genesis, nil } @@ -187,7 +186,6 @@ func TestStateSyncGetOngoingSyncStateSummary(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: choices.Accepted, }, } require.NoError(vm.acceptPostForkBlock(proBlk)) @@ -271,7 +269,6 @@ func TestStateSyncGetLastStateSummary(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: choices.Accepted, }, } require.NoError(vm.acceptPostForkBlock(proBlk)) @@ -358,7 +355,6 @@ func TestStateSyncGetStateSummary(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: choices.Accepted, }, } require.NoError(vm.acceptPostForkBlock(proBlk)) @@ -430,7 +426,6 @@ func TestParseStateSummary(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: choices.Accepted, }, } require.NoError(vm.acceptPostForkBlock(proBlk)) @@ -563,7 +558,6 @@ func TestStateSummaryAcceptOlderBlock(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: vm, innerBlk: innerBlk, - status: choices.Accepted, }, } require.NoError(vm.acceptPostForkBlock(proBlk)) diff --git a/vms/proposervm/vm_byzantine_test.go b/vms/proposervm/vm_byzantine_test.go index d4997781cdd4..cccdd755586b 100644 --- a/vms/proposervm/vm_byzantine_test.go +++ b/vms/proposervm/vm_byzantine_test.go @@ -14,7 +14,6 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/validators" @@ -74,166 +73,6 @@ func TestInvalidByzantineProposerParent(t *testing.T) { require.ErrorIs(err, errUnknownBlock) } -// Ensure that a byzantine node issuing an invalid PreForkBlock (Y or Z) when -// the parent block (X) is issued into a PostForkBlock (A) will be marked as -// invalid correctly. -// -// G -// / | -// A - X -// / \ -// Y Z -func TestInvalidByzantineProposerOracleParent(t *testing.T) { - require := require.New(t) - - var ( - activationTime = time.Unix(0, 0) - durangoTime = activationTime - ) - coreVM, _, proVM, _ := initTestProposerVM(t, activationTime, durangoTime, 0) - proVM.Set(snowmantest.GenesisTimestamp) - defer func() { - require.NoError(proVM.Shutdown(context.Background())) - }() - - xTestBlock := snowmantest.BuildChild(snowmantest.Genesis) - xBlock := &TestOptionsBlock{ - Block: *xTestBlock, - opts: [2]snowman.Block{ - snowmantest.BuildChild(xTestBlock), - snowmantest.BuildChild(xTestBlock), - }, - } - - coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { - return xBlock, nil - } - coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - switch blkID { - case snowmantest.GenesisID: - return snowmantest.Genesis, nil - case xBlock.ID(): - return xBlock, nil - case xBlock.opts[0].ID(): - return xBlock.opts[0], nil - case xBlock.opts[1].ID(): - return xBlock.opts[1], nil - default: - return nil, database.ErrNotFound - } - } - coreVM.ParseBlockF = func(_ context.Context, b []byte) (snowman.Block, error) { - switch { - case bytes.Equal(b, snowmantest.GenesisBytes): - return snowmantest.Genesis, nil - case bytes.Equal(b, xBlock.Bytes()): - return xBlock, nil - case bytes.Equal(b, xBlock.opts[0].Bytes()): - return xBlock.opts[0], nil - case bytes.Equal(b, xBlock.opts[1].Bytes()): - return xBlock.opts[1], nil - default: - return nil, errUnknownBlock - } - } - - aBlockIntf, err := proVM.BuildBlock(context.Background()) - require.NoError(err) - - require.IsType(&postForkBlock{}, aBlockIntf) - aBlock := aBlockIntf.(*postForkBlock) - opts, err := aBlock.Options(context.Background()) - require.NoError(err) - - require.NoError(aBlock.Verify(context.Background())) - require.NoError(opts[0].Verify(context.Background())) - require.NoError(opts[1].Verify(context.Background())) - - wrappedXBlock, err := proVM.ParseBlock(context.Background(), xBlock.Bytes()) - require.NoError(err) - - err = wrappedXBlock.Verify(context.Background()) - require.ErrorIs(err, errUnexpectedBlockType) - - require.NoError(aBlock.Accept(context.Background())) - - // Because the wrappedXBlock never passed verification and is now rejected, - // the consensus engine will never verify any of its children. - require.Equal(choices.Rejected, wrappedXBlock.Status()) -} - -// Ensure that a byzantine node issuing an invalid PostForkBlock (B) when the -// parent block (X) is issued into a PostForkBlock (A) will be marked as invalid -// correctly. -// -// G -// / | -// A - X -// / | -// B - Y -func TestInvalidByzantineProposerPreForkParent(t *testing.T) { - require := require.New(t) - - var ( - activationTime = time.Unix(0, 0) - durangoTime = activationTime - ) - coreVM, _, proVM, _ := initTestProposerVM(t, activationTime, durangoTime, 0) - defer func() { - require.NoError(proVM.Shutdown(context.Background())) - }() - - xBlock := snowmantest.BuildChild(snowmantest.Genesis) - coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { - return xBlock, nil - } - - yBlock := snowmantest.BuildChild(xBlock) - coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - switch blkID { - case snowmantest.GenesisID: - return snowmantest.Genesis, nil - case xBlock.ID(): - return xBlock, nil - case yBlock.ID(): - return yBlock, nil - default: - return nil, errUnknownBlock - } - } - coreVM.ParseBlockF = func(_ context.Context, blockBytes []byte) (snowman.Block, error) { - switch { - case bytes.Equal(blockBytes, snowmantest.GenesisBytes): - return snowmantest.Genesis, nil - case bytes.Equal(blockBytes, xBlock.Bytes()): - return xBlock, nil - case bytes.Equal(blockBytes, yBlock.Bytes()): - return yBlock, nil - default: - return nil, errUnknownBlock - } - } - - aBlock, err := proVM.BuildBlock(context.Background()) - require.NoError(err) - coreVM.BuildBlockF = nil - - require.NoError(aBlock.Verify(context.Background())) - - wrappedXBlock, err := proVM.ParseBlock(context.Background(), xBlock.Bytes()) - require.NoError(err) - - // If there wasn't an error parsing - verify must return an error - err = wrappedXBlock.Verify(context.Background()) - require.ErrorIs(err, errUnexpectedBlockType) - - require.NoError(aBlock.Accept(context.Background())) - - // Because the wrappedXBlock never passed verification and is now rejected, - // the consensus engine will never verify any of its children. - require.Equal(choices.Rejected, wrappedXBlock.Status()) -} - // Ensure that a byzantine node issuing an invalid OptionBlock (B) which // contains core block (Y) whose parent (G) doesn't match (B)'s parent (A)'s // inner block (X) will be marked as invalid correctly. @@ -258,7 +97,7 @@ func TestBlockVerify_PostForkOption_FaultyParent(t *testing.T) { xBlock := &TestOptionsBlock{ Block: *snowmantest.BuildChild(snowmantest.Genesis), - opts: [2]snowman.Block{ // valid blocks should reference xBlock + opts: [2]*snowmantest.Block{ // valid blocks should reference xBlock snowmantest.BuildChild(snowmantest.Genesis), snowmantest.BuildChild(snowmantest.Genesis), }, @@ -339,7 +178,7 @@ func TestBlockVerify_InvalidPostForkOption(t *testing.T) { xTestBlock := snowmantest.BuildChild(snowmantest.Genesis) xBlock := &TestOptionsBlock{ Block: *xTestBlock, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(xTestBlock), snowmantest.BuildChild(xTestBlock), }, @@ -365,7 +204,6 @@ func TestBlockVerify_InvalidPostForkOption(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: yBlock, - status: choices.Processing, }, } @@ -383,7 +221,6 @@ func TestBlockVerify_InvalidPostForkOption(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: xInnerOption, - status: xInnerOption.Status(), }, } @@ -410,7 +247,6 @@ func TestBlockVerify_InvalidPostForkOption(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: xInnerOption, - status: xInnerOption.Status(), }, } @@ -421,7 +257,7 @@ func TestBlockVerify_InvalidPostForkOption(t *testing.T) { zTestBlock := snowmantest.BuildChild(snowmantest.Genesis) zBlock := &TestOptionsBlock{ Block: *zTestBlock, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(zTestBlock), snowmantest.BuildChild(zTestBlock), }, @@ -447,7 +283,6 @@ func TestBlockVerify_InvalidPostForkOption(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: xInnerOption, - status: xInnerOption.Status(), }, } diff --git a/vms/proposervm/vm_test.go b/vms/proposervm/vm_test.go index a2536375d48c..e5f331b86104 100644 --- a/vms/proposervm/vm_test.go +++ b/vms/proposervm/vm_test.go @@ -103,9 +103,9 @@ func initTestProposerVM( ) error { return nil } - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: @@ -496,7 +496,6 @@ func TestCoreBlockFailureCauseProposerBlockParseFailure(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: innerBlk, - status: choices.Processing, }, } @@ -541,7 +540,6 @@ func TestTwoProBlocksWrappingSameCoreBlockCanBeParsed(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: innerBlk, - status: choices.Processing, }, } @@ -560,7 +558,6 @@ func TestTwoProBlocksWrappingSameCoreBlockCanBeParsed(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: innerBlk, - status: choices.Processing, }, } @@ -630,7 +627,6 @@ func TestTwoProBlocksWithSameParentCanBothVerify(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: netcoreBlk, - status: choices.Processing, }, } @@ -784,9 +780,9 @@ func TestExpiredBuildBlock(t *testing.T) { coreVM := &block.TestVM{} coreVM.T = t - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: @@ -1081,9 +1077,9 @@ func TestInnerVMRollback(t *testing.T) { coreVM := &block.TestVM{} coreVM.T = t - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: @@ -1182,19 +1178,20 @@ func TestInnerVMRollback(t *testing.T) { proVM.Clock.Set(statelessBlock.Timestamp()) - parsedBlock, err := proVM.ParseBlock(context.Background(), statelessBlock.Bytes()) + lastAcceptedID, err := proVM.GetLastAccepted() require.NoError(err) + require.Equal(snowmantest.GenesisID, lastAcceptedID) - require.Equal(choices.Processing, parsedBlock.Status()) + parsedBlock, err := proVM.ParseBlock(context.Background(), statelessBlock.Bytes()) + require.NoError(err) require.NoError(parsedBlock.Verify(context.Background())) require.NoError(proVM.SetPreference(context.Background(), parsedBlock.ID())) require.NoError(parsedBlock.Accept(context.Background())) - fetchedBlock, err := proVM.GetBlock(context.Background(), parsedBlock.ID()) + lastAcceptedID, err = proVM.GetLastAccepted() require.NoError(err) - - require.Equal(choices.Accepted, fetchedBlock.Status()) + require.Equal(parsedBlock.ID(), lastAcceptedID) // Restart the node and have the inner VM rollback state. require.NoError(proVM.Shutdown(context.Background())) @@ -1229,15 +1226,9 @@ func TestInnerVMRollback(t *testing.T) { require.NoError(proVM.Shutdown(context.Background())) }() - lastAcceptedID, err := proVM.LastAccepted(context.Background()) + lastAcceptedID, err = proVM.LastAccepted(context.Background()) require.NoError(err) - require.Equal(snowmantest.GenesisID, lastAcceptedID) - - parsedBlock, err = proVM.ParseBlock(context.Background(), statelessBlock.Bytes()) - require.NoError(err) - - require.Equal(choices.Processing, parsedBlock.Status()) } func TestBuildBlockDuringWindow(t *testing.T) { @@ -1368,7 +1359,6 @@ func TestTwoForks_OneIsAccepted(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: yBlock, - status: choices.Processing, }, } @@ -1437,7 +1427,6 @@ func TestTooFarAdvanced(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: yBlock, - status: choices.Processing, }, } @@ -1458,7 +1447,6 @@ func TestTooFarAdvanced(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: yBlock, - status: choices.Processing, }, } @@ -1469,14 +1457,14 @@ func TestTooFarAdvanced(t *testing.T) { // Ensure that Accepting a PostForkOption (B) causes both the other option and // the core block in the other option to be rejected. // -// G -// | -// A(X) -// /====\ -// B(...) C(...) +// G +// | +// A(X) +// / \ +// B(Y) C(Z) // -// B(...) is B(X.opts[0]) -// B(...) is C(X.opts[1]) +// Y is X.opts[0] +// Z is X.opts[1] func TestTwoOptions_OneIsAccepted(t *testing.T) { require := require.New(t) @@ -1492,7 +1480,7 @@ func TestTwoOptions_OneIsAccepted(t *testing.T) { xTestBlock := snowmantest.BuildChild(snowmantest.Genesis) xBlock := &TestOptionsBlock{ Block: *xTestBlock, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(xTestBlock), snowmantest.BuildChild(xTestBlock), }, @@ -1503,30 +1491,24 @@ func TestTwoOptions_OneIsAccepted(t *testing.T) { } aBlockIntf, err := proVM.BuildBlock(context.Background()) require.NoError(err) - require.IsType(&postForkBlock{}, aBlockIntf) aBlock := aBlockIntf.(*postForkBlock) opts, err := aBlock.Options(context.Background()) require.NoError(err) - require.NoError(aBlock.Verify(context.Background())) bBlock := opts[0] - require.NoError(bBlock.Verify(context.Background())) cBlock := opts[1] + + require.NoError(aBlock.Verify(context.Background())) + require.NoError(bBlock.Verify(context.Background())) require.NoError(cBlock.Verify(context.Background())) require.NoError(aBlock.Accept(context.Background())) - require.NoError(bBlock.Accept(context.Background())) // the other pre-fork option should be rejected require.Equal(choices.Rejected, xBlock.opts[1].Status()) - - // the other post-fork option should also be rejected - require.NoError(cBlock.Reject(context.Background())) - - require.Equal(choices.Rejected, cBlock.Status()) } // Ensure that given the chance, built blocks will reference a lagged P-chain @@ -1583,9 +1565,9 @@ func TestRejectedHeightNotIndexed(t *testing.T) { ) error { return nil } - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: @@ -1707,7 +1689,6 @@ func TestRejectedHeightNotIndexed(t *testing.T) { postForkCommonComponents: postForkCommonComponents{ vm: proVM, innerBlk: yBlock, - status: choices.Processing, }, } @@ -1755,9 +1736,9 @@ func TestRejectedOptionHeightNotIndexed(t *testing.T) { ) error { return nil } - coreVM.LastAcceptedF = func(context.Context) (ids.ID, error) { - return snowmantest.GenesisID, nil - } + coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ) coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { switch blkID { case snowmantest.GenesisID: @@ -1854,7 +1835,7 @@ func TestRejectedOptionHeightNotIndexed(t *testing.T) { xTestBlock := snowmantest.BuildChild(snowmantest.Genesis) xBlock := &TestOptionsBlock{ Block: *xTestBlock, - opts: [2]snowman.Block{ + opts: [2]*snowmantest.Block{ snowmantest.BuildChild(xTestBlock), snowmantest.BuildChild(xTestBlock), }, @@ -2055,56 +2036,16 @@ func TestVMInnerBlkCacheDeduplicationRegression(t *testing.T) { require.NoError(aBlock.Accept(context.Background())) require.NoError(bBlock.Reject(context.Background())) - require.Equal( - choices.Accepted, - aBlock.(*postForkBlock).innerBlk.Status(), - ) + require.Equal(choices.Accepted, xBlock.Status()) - require.Equal( - choices.Accepted, - bBlock.(*postForkBlock).innerBlk.Status(), - ) + require.Equal(choices.Accepted, xBlockCopy.Status()) cachedXBlock, ok := proVM.innerBlkCache.Get(bBlock.ID()) require.True(ok) require.Equal( choices.Accepted, - cachedXBlock.Status(), - ) -} - -func TestVMInnerBlkMarkedAcceptedRegression(t *testing.T) { - require := require.New(t) - var ( - activationTime = time.Unix(0, 0) - durangoTime = activationTime + cachedXBlock.(*snowmantest.Block).Status(), ) - coreVM, _, proVM, _ := initTestProposerVM(t, activationTime, durangoTime, 0) - defer func() { - require.NoError(proVM.Shutdown(context.Background())) - }() - - // create an inner block and wrap it in an postForkBlock. - innerBlock := snowmantest.BuildChild(snowmantest.Genesis) - - coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { - return innerBlock, nil - } - outerBlock, err := proVM.BuildBlock(context.Background()) - require.NoError(err) - coreVM.BuildBlockF = nil - - require.NoError(outerBlock.Verify(context.Background())) - require.NoError(outerBlock.Accept(context.Background())) - - coreVM.GetBlockF = func(_ context.Context, id ids.ID) (snowman.Block, error) { - require.Equal(innerBlock.ID(), id) - return innerBlock, nil - } - - wrappedInnerBlock, err := proVM.GetBlock(context.Background(), innerBlock.ID()) - require.NoError(err) - require.Equal(choices.Rejected, wrappedInnerBlock.Status()) } type blockWithVerifyContext struct { From 902db687c17866dff51c44d8c192f5e7b7129813 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 16:51:02 -0400 Subject: [PATCH 06/24] merged --- vms/rpcchainvm/batched_vm_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vms/rpcchainvm/batched_vm_test.go b/vms/rpcchainvm/batched_vm_test.go index b24c0699e597..f3d060191f9f 100644 --- a/vms/rpcchainvm/batched_vm_test.go +++ b/vms/rpcchainvm/batched_vm_test.go @@ -13,7 +13,6 @@ import ( "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/snowtest" @@ -28,9 +27,6 @@ var ( blkID1 = ids.ID{1} blkID2 = ids.ID{2} - status1 = choices.Accepted - status2 = choices.Processing - time1 = time.Unix(1, 0) time2 = time.Unix(2, 0) ) @@ -59,7 +55,6 @@ func batchedParseBlockCachingTestPlugin(t *testing.T, loadExpectations bool) blo vm.EXPECT().ParseBlock(gomock.Any(), blkBytes1).Return(blk1, nil).Times(1), blk1.EXPECT().ID().Return(blkID1).Times(1), blk1.EXPECT().Parent().Return(blkID0).Times(1), - blk1.EXPECT().Status().Return(status1).Times(1), blk1.EXPECT().Height().Return(uint64(1)).Times(1), blk1.EXPECT().Timestamp().Return(time1).Times(1), @@ -67,7 +62,6 @@ func batchedParseBlockCachingTestPlugin(t *testing.T, loadExpectations bool) blo vm.EXPECT().ParseBlock(gomock.Any(), blkBytes2).Return(blk2, nil).Times(1), blk2.EXPECT().ID().Return(blkID2).Times(1), blk2.EXPECT().Parent().Return(blkID1).Times(1), - blk2.EXPECT().Status().Return(status2).Times(1), blk2.EXPECT().Height().Return(uint64(2)).Times(1), blk2.EXPECT().Timestamp().Return(time2).Times(1), ) From 7593a1d6cbf5308123d10ec9fb0e84390980ebda Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 17:27:41 -0400 Subject: [PATCH 07/24] cleanup --- snow/consensus/snowman/consensus_test.go | 101 +++++++++--------- snow/consensus/snowman/metrics.go | 5 +- snow/consensus/snowman/network_test.go | 19 ++-- snow/consensus/snowman/snowmantest/block.go | 16 +-- snow/consensus/snowman/snowmantest/engine.go | 10 +- snow/consensus/snowman/snowmantest/require.go | 16 +++ .../snowman/bootstrap/bootstrapper_test.go | 37 +++---- snow/engine/snowman/bootstrap/storage_test.go | 6 +- snow/engine/snowman/transitive_test.go | 76 +++++++------ snow/snowtest/status.go | 2 +- vms/components/chain/state_test.go | 62 +++++------ vms/proposervm/post_fork_block_test.go | 4 +- vms/proposervm/post_fork_option_test.go | 6 +- vms/proposervm/pre_fork_block_test.go | 4 +- vms/proposervm/tree/tree_test.go | 14 +-- vms/proposervm/vm_test.go | 18 ++-- vms/rpcchainvm/state_syncable_vm_test.go | 13 ++- 17 files changed, 208 insertions(+), 201 deletions(-) create mode 100644 snow/consensus/snowman/snowmantest/require.go diff --git a/snow/consensus/snowman/consensus_test.go b/snow/consensus/snowman/consensus_test.go index 1de19a0b2df4..bbeda976698b 100644 --- a/snow/consensus/snowman/consensus_test.go +++ b/snow/consensus/snowman/consensus_test.go @@ -17,7 +17,6 @@ import ( "gonum.org/v1/gonum/mathext/prng" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowball" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/snowtest" @@ -251,9 +250,9 @@ func AddOnUnknownParentTest(t *testing.T, factory Factory) { )) block := &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.GenerateTestID(), - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: ids.GenerateTestID(), + Status: snowtest.Undecided, }, ParentV: ids.GenerateTestID(), HeightV: snowmantest.GenesisHeight + 2, @@ -289,7 +288,7 @@ func StatusOrProcessingPreviouslyAcceptedTest(t *testing.T, factory Factory) { snowmantest.GenesisTimestamp, )) - require.Equal(choices.Accepted, snowmantest.Genesis.Status()) + require.Equal(snowtest.Accepted, snowmantest.Genesis.Status) require.False(sm.Processing(snowmantest.Genesis.ID())) require.True(sm.IsPreferred(snowmantest.Genesis.ID())) @@ -326,7 +325,7 @@ func StatusOrProcessingPreviouslyRejectedTest(t *testing.T, factory Factory) { block := snowmantest.BuildChild(snowmantest.Genesis) require.NoError(block.Reject(context.Background())) - require.Equal(choices.Rejected, block.Status()) + require.Equal(snowtest.Rejected, block.Status) require.False(sm.Processing(block.ID())) require.False(sm.IsPreferred(block.ID())) @@ -361,7 +360,7 @@ func StatusOrProcessingUnissuedTest(t *testing.T, factory Factory) { block := snowmantest.BuildChild(snowmantest.Genesis) - require.Equal(choices.Processing, block.Status()) + require.Equal(snowtest.Undecided, block.Status) require.False(sm.Processing(block.ID())) require.False(sm.IsPreferred(block.ID())) @@ -397,7 +396,7 @@ func StatusOrProcessingIssuedTest(t *testing.T, factory Factory) { block := snowmantest.BuildChild(snowmantest.Genesis) require.NoError(sm.Add(block)) - require.Equal(choices.Processing, block.Status()) + require.Equal(snowtest.Undecided, block.Status) require.True(sm.Processing(block.ID())) require.True(sm.IsPreferred(block.ID())) @@ -439,12 +438,12 @@ func RecordPollAcceptSingleBlockTest(t *testing.T, factory Factory) { require.NoError(sm.RecordPoll(context.Background(), votes)) require.Equal(block.ID(), sm.Preference()) require.Equal(1, sm.NumProcessing()) - require.Equal(choices.Processing, block.Status()) + require.Equal(snowtest.Undecided, block.Status) require.NoError(sm.RecordPoll(context.Background(), votes)) require.Equal(block.ID(), sm.Preference()) require.Zero(sm.NumProcessing()) - require.Equal(choices.Accepted, block.Status()) + require.Equal(snowtest.Accepted, block.Status) } func RecordPollAcceptAndRejectTest(t *testing.T, factory Factory) { @@ -483,14 +482,14 @@ func RecordPollAcceptAndRejectTest(t *testing.T, factory Factory) { require.NoError(sm.RecordPoll(context.Background(), votes)) require.Equal(firstBlock.ID(), sm.Preference()) require.Equal(2, sm.NumProcessing()) - require.Equal(choices.Processing, firstBlock.Status()) - require.Equal(choices.Processing, secondBlock.Status()) + require.Equal(snowtest.Undecided, firstBlock.Status) + require.Equal(snowtest.Undecided, secondBlock.Status) require.NoError(sm.RecordPoll(context.Background(), votes)) require.Equal(firstBlock.ID(), sm.Preference()) require.Zero(sm.NumProcessing()) - require.Equal(choices.Accepted, firstBlock.Status()) - require.Equal(choices.Rejected, secondBlock.Status()) + require.Equal(snowtest.Accepted, firstBlock.Status) + require.Equal(snowtest.Rejected, secondBlock.Status) } func RecordPollSplitVoteNoChangeTest(t *testing.T, factory Factory) { @@ -628,9 +627,9 @@ func RecordPollRejectTransitivelyTest(t *testing.T, factory Factory) { require.Zero(sm.NumProcessing()) require.Equal(block0.ID(), sm.Preference()) - require.Equal(choices.Accepted, block0.Status()) - require.Equal(choices.Rejected, block1.Status()) - require.Equal(choices.Rejected, block2.Status()) + require.Equal(snowtest.Accepted, block0.Status) + require.Equal(snowtest.Rejected, block1.Status) + require.Equal(snowtest.Rejected, block2.Status) } func RecordPollTransitivelyResetConfidenceTest(t *testing.T, factory Factory) { @@ -697,10 +696,10 @@ func RecordPollTransitivelyResetConfidenceTest(t *testing.T, factory Factory) { require.NoError(sm.RecordPoll(context.Background(), votesFor3)) require.Zero(sm.NumProcessing()) require.Equal(block3.ID(), sm.Preference()) - require.Equal(choices.Rejected, block0.Status()) - require.Equal(choices.Accepted, block1.Status()) - require.Equal(choices.Rejected, block2.Status()) - require.Equal(choices.Accepted, block3.Status()) + require.Equal(snowtest.Rejected, block0.Status) + require.Equal(snowtest.Accepted, block1.Status) + require.Equal(snowtest.Rejected, block2.Status) + require.Equal(snowtest.Accepted, block3.Status) } func RecordPollInvalidVoteTest(t *testing.T, factory Factory) { @@ -803,11 +802,11 @@ func RecordPollTransitiveVotingTest(t *testing.T, factory Factory) { require.Equal(4, sm.NumProcessing()) require.Equal(block2.ID(), sm.Preference()) - require.Equal(choices.Accepted, block0.Status()) - require.Equal(choices.Processing, block1.Status()) - require.Equal(choices.Processing, block2.Status()) - require.Equal(choices.Processing, block3.Status()) - require.Equal(choices.Processing, block4.Status()) + require.Equal(snowtest.Accepted, block0.Status) + require.Equal(snowtest.Undecided, block1.Status) + require.Equal(snowtest.Undecided, block2.Status) + require.Equal(snowtest.Undecided, block3.Status) + require.Equal(snowtest.Undecided, block4.Status) dep2_2_2 := bag.Of(block2.ID(), block2.ID(), block2.ID()) require.NoError(sm.RecordPoll(context.Background(), dep2_2_2)) @@ -818,11 +817,11 @@ func RecordPollTransitiveVotingTest(t *testing.T, factory Factory) { require.Zero(sm.NumProcessing()) require.Equal(block2.ID(), sm.Preference()) - require.Equal(choices.Accepted, block0.Status()) - require.Equal(choices.Accepted, block1.Status()) - require.Equal(choices.Accepted, block2.Status()) - require.Equal(choices.Rejected, block3.Status()) - require.Equal(choices.Rejected, block4.Status()) + require.Equal(snowtest.Accepted, block0.Status) + require.Equal(snowtest.Accepted, block1.Status) + require.Equal(snowtest.Accepted, block2.Status) + require.Equal(snowtest.Rejected, block3.Status) + require.Equal(snowtest.Rejected, block4.Status) } func RecordPollDivergedVotingWithNoConflictingBitTest(t *testing.T, factory Factory) { @@ -850,25 +849,25 @@ func RecordPollDivergedVotingWithNoConflictingBitTest(t *testing.T, factory Fact )) block0 := &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.ID{0x06}, // 0110 - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: ids.ID{0x06}, // 0110 + Status: snowtest.Undecided, }, ParentV: snowmantest.GenesisID, HeightV: snowmantest.GenesisHeight + 1, } block1 := &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.ID{0x08}, // 0001 - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: ids.ID{0x08}, // 0001 + Status: snowtest.Undecided, }, ParentV: snowmantest.GenesisID, HeightV: snowmantest.GenesisHeight + 1, } block2 := &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.ID{0x01}, // 1000 - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: ids.ID{0x01}, // 1000 + Status: snowtest.Undecided, }, ParentV: snowmantest.GenesisID, HeightV: snowmantest.GenesisHeight + 1, @@ -896,10 +895,10 @@ func RecordPollDivergedVotingWithNoConflictingBitTest(t *testing.T, factory Fact require.NoError(sm.Add(block3)) require.Equal(block0.ID(), sm.Preference()) - require.Equal(choices.Processing, block0.Status(), "should not be decided yet") - require.Equal(choices.Processing, block1.Status(), "should not be decided yet") - require.Equal(choices.Processing, block2.Status(), "should not be decided yet") - require.Equal(choices.Processing, block3.Status(), "should not be decided yet") + require.Equal(snowtest.Undecided, block0.Status, "should not be decided yet") + require.Equal(snowtest.Undecided, block1.Status, "should not be decided yet") + require.Equal(snowtest.Undecided, block2.Status, "should not be decided yet") + require.Equal(snowtest.Undecided, block3.Status, "should not be decided yet") // Current graph structure: // G @@ -921,10 +920,10 @@ func RecordPollDivergedVotingWithNoConflictingBitTest(t *testing.T, factory Fact require.NoError(sm.RecordPoll(context.Background(), votes3)) require.Equal(4, sm.NumProcessing()) - require.Equal(choices.Processing, block0.Status()) - require.Equal(choices.Processing, block1.Status()) - require.Equal(choices.Processing, block2.Status()) - require.Equal(choices.Processing, block3.Status()) + require.Equal(snowtest.Undecided, block0.Status) + require.Equal(snowtest.Undecided, block1.Status) + require.Equal(snowtest.Undecided, block2.Status) + require.Equal(snowtest.Undecided, block3.Status) } func RecordPollChangePreferredChainTest(t *testing.T, factory Factory) { @@ -1462,7 +1461,7 @@ func RecordPollRegressionCalculateInDegreeIndegreeCalculation(t *testing.T, fact votes.AddCount(blk2.ID(), 1) votes.AddCount(blk3.ID(), 2) require.NoError(sm.RecordPoll(context.Background(), votes)) - require.Equal(choices.Accepted, blk1.Status()) - require.Equal(choices.Accepted, blk2.Status()) - require.Equal(choices.Accepted, blk3.Status()) + require.Equal(snowtest.Accepted, blk1.Status) + require.Equal(snowtest.Accepted, blk2.Status) + require.Equal(snowtest.Accepted, blk3.Status) } diff --git a/snow/consensus/snowman/metrics.go b/snow/consensus/snowman/metrics.go index bab57e5c371d..72409063f044 100644 --- a/snow/consensus/snowman/metrics.go +++ b/snow/consensus/snowman/metrics.go @@ -10,7 +10,6 @@ import ( "go.uber.org/zap" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/utils/linked" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/metric" @@ -184,7 +183,7 @@ func (m *metrics) Accepted( if !ok { m.log.Error("unable to measure latency", zap.Stringer("blkID", blkID), - zap.Stringer("status", choices.Accepted), + zap.String("status", "accepted"), ) return } @@ -210,7 +209,7 @@ func (m *metrics) Rejected(blkID ids.ID, pollNumber uint64, blockSize int) { if !ok { m.log.Error("unable to measure latency", zap.Stringer("blkID", blkID), - zap.Stringer("status", choices.Rejected), + zap.String("status", "rejected"), ) return } diff --git a/snow/consensus/snowman/network_test.go b/snow/consensus/snowman/network_test.go index 8c302ed5c7c6..27c9f411ae96 100644 --- a/snow/consensus/snowman/network_test.go +++ b/snow/consensus/snowman/network_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowball" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/snowtest" @@ -28,9 +27,9 @@ func NewNetwork(params snowball.Parameters, numColors int, rngSource sampler.Sou n := &Network{ params: params, colors: []*snowmantest.Block{{ - TestDecidable: choices.TestDecidable{ - IDV: ids.Empty.Prefix(rngSource.Uint64()), - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: ids.Empty.Prefix(rngSource.Uint64()), + Status: snowtest.Undecided, }, ParentV: snowmantest.GenesisID, HeightV: snowmantest.GenesisHeight + 1, @@ -44,9 +43,9 @@ func NewNetwork(params snowball.Parameters, numColors int, rngSource sampler.Sou dependencyInd, _ := s.Next() dependency := n.colors[dependencyInd] n.colors = append(n.colors, &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.Empty.Prefix(rngSource.Uint64()), - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: ids.Empty.Prefix(rngSource.Uint64()), + Status: snowtest.Undecided, }, ParentV: dependency.IDV, HeightV: dependency.HeightV + 1, @@ -82,9 +81,9 @@ func (n *Network) AddNode(t testing.TB, sm Consensus) error { myDep = blk.Parent() } myBlock := &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: blk.ID(), - StatusV: blk.Status(), + Decidable: snowtest.Decidable{ + IDV: blk.ID(), + Status: blk.Status, }, ParentV: myDep, HeightV: blk.Height(), diff --git a/snow/consensus/snowman/snowmantest/block.go b/snow/consensus/snowman/snowmantest/block.go index d77ee9759136..4dba3d0cc697 100644 --- a/snow/consensus/snowman/snowmantest/block.go +++ b/snow/consensus/snowman/snowmantest/block.go @@ -9,7 +9,7 @@ import ( "time" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/utils" ) @@ -30,9 +30,9 @@ var ( func BuildChild(parent *Block) *Block { blkID := ids.GenerateTestID() return &Block{ - TestDecidable: choices.TestDecidable{ - IDV: blkID, - StatusV: choices.Processing, + Decidable: snowtest.Decidable{ + IDV: blkID, + Status: snowtest.Undecided, }, ParentV: parent.ID(), HeightV: parent.Height() + 1, @@ -47,9 +47,9 @@ func BuildChain(length int) []*Block { } genesis := &Block{ - TestDecidable: choices.TestDecidable{ - IDV: GenesisID, - StatusV: choices.Accepted, + Decidable: snowtest.Decidable{ + IDV: GenesisID, + Status: snowtest.Accepted, }, HeightV: GenesisHeight, TimestampV: GenesisTimestamp, @@ -68,7 +68,7 @@ func BuildDescendants(parent *Block, length int) []*Block { } type Block struct { - choices.TestDecidable + snowtest.Decidable ParentV ids.ID HeightV uint64 diff --git a/snow/consensus/snowman/snowmantest/engine.go b/snow/consensus/snowman/snowmantest/engine.go index 705dd0fd46dd..0ff2d8f3a374 100644 --- a/snow/consensus/snowman/snowmantest/engine.go +++ b/snow/consensus/snowman/snowmantest/engine.go @@ -7,7 +7,7 @@ import ( "context" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" + "github.com/ava-labs/avalanchego/snow/snowtest" ) func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, error) { @@ -18,8 +18,12 @@ func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, err ) for _, blks := range blks { for _, blk := range blks { - if blk.Status() == choices.Accepted && blk.Height() >= highestHeight { - highestHeight = blk.Height() + if blk.Status != snowtest.Accepted { + continue + } + + if height := blk.Height(); height >= highestHeight { + highestHeight = height highestID = blk.ID() } } diff --git a/snow/consensus/snowman/snowmantest/require.go b/snow/consensus/snowman/snowmantest/require.go new file mode 100644 index 000000000000..7b942740dfd1 --- /dev/null +++ b/snow/consensus/snowman/snowmantest/require.go @@ -0,0 +1,16 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package snowmantest + +import ( + "github.com/stretchr/testify/require" + + "github.com/ava-labs/avalanchego/snow/snowtest" +) + +func RequireStatusIs(require *require.Assertions, status snowtest.Status, blks ...*Block) { + for i, blk := range blks { + require.Equal(status, blk.Status, i) + } +} diff --git a/snow/engine/snowman/bootstrap/bootstrapper_test.go b/snow/engine/snowman/bootstrap/bootstrapper_test.go index 1473294a9949..325b7d2221de 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper_test.go +++ b/snow/engine/snowman/bootstrap/bootstrapper_test.go @@ -18,7 +18,6 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/network/p2p" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/common" @@ -276,7 +275,7 @@ func TestBootstrapperUnknownByzantineResponse(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, requestID, blocksToBytes(blks[1:2]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) require.NoError(bs.startSyncing(context.Background(), blocksToIDs(blks[1:2]))) require.Equal(snow.NormalOp, config.Ctx.State.Get().State) @@ -325,7 +324,7 @@ func TestBootstrapperPartialFetch(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, requestID, blocksToBytes(blks[1:2]))) // respond with blk1 require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) require.NoError(bs.startSyncing(context.Background(), blocksToIDs(blks[3:4]))) require.Equal(snow.NormalOp, config.Ctx.State.Get().State) @@ -377,7 +376,7 @@ func TestBootstrapperEmptyResponse(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), requestedNodeID, requestID, blocksToBytes(blks[1:2]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) } // There are multiple needed blocks and Ancestors returns all at once @@ -420,7 +419,7 @@ func TestBootstrapperAncestors(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, requestID, blocksToBytes(blks))) // respond with all the blocks require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) require.NoError(bs.startSyncing(context.Background(), blocksToIDs(blks[3:4]))) require.Equal(snow.NormalOp, config.Ctx.State.Get().State) @@ -462,7 +461,7 @@ func TestBootstrapperFinalized(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, reqIDBlk2, blocksToBytes(blks[1:3]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) require.NoError(bs.startSyncing(context.Background(), blocksToIDs(blks[2:3]))) require.Equal(snow.NormalOp, config.Ctx.State.Get().State) @@ -518,12 +517,12 @@ func TestRestartBootstrapping(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, blk1RequestID, blocksToBytes(blks[1:2]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - require.Equal(choices.Accepted, blks[0].Status()) - requireStatusIs(require, blks[1:], choices.Processing) + require.Equal(snowtest.Accepted, blks[0].Status) + snowmantest.RequireStatusIs(require, snowtest.Undecided, blks[1:]...) require.NoError(bs.Ancestors(context.Background(), peerID, blk4RequestID, blocksToBytes(blks[4:5]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) require.NoError(bs.startSyncing(context.Background(), blocksToIDs(blks[4:5]))) require.Equal(snow.NormalOp, config.Ctx.State.Get().State) @@ -537,7 +536,7 @@ func TestBootstrapOldBlockAfterStateSync(t *testing.T) { blks := snowmantest.BuildChain(2) initializeVMWithBlockchain(vm, blks) - blks[0].StatusV = choices.Processing + blks[0].Status = snowtest.Undecided require.NoError(blks[1].Accept(context.Background())) bs, err := New( @@ -568,8 +567,8 @@ func TestBootstrapOldBlockAfterStateSync(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, reqID, blocksToBytes(blks[0:1]))) require.Equal(snow.NormalOp, config.Ctx.State.Get().State) - require.Equal(choices.Processing, blks[0].Status()) - require.Equal(choices.Accepted, blks[1].Status()) + require.Equal(snowtest.Undecided, blks[0].Status) + require.Equal(snowtest.Accepted, blks[1].Status) } func TestBootstrapContinueAfterHalt(t *testing.T) { @@ -736,7 +735,7 @@ func TestBootstrapperReceiveStaleAncestorsMessage(t *testing.T) { require.NoError(bs.Ancestors(context.Background(), peerID, reqIDBlk2, blocksToBytes(blks[1:3]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) - requireStatusIs(require, blks, choices.Accepted) + snowmantest.RequireStatusIs(require, snowtest.Accepted, blks...) require.NoError(bs.Ancestors(context.Background(), peerID, reqIDBlk1, blocksToBytes(blks[1:2]))) require.Equal(snow.Bootstrapping, config.Ctx.State.Get().State) @@ -750,7 +749,7 @@ func TestBootstrapperRollbackOnSetState(t *testing.T) { blks := snowmantest.BuildChain(2) initializeVMWithBlockchain(vm, blks) - blks[1].StatusV = choices.Accepted + blks[1].Status = snowtest.Accepted bs, err := New( config, @@ -765,7 +764,7 @@ func TestBootstrapperRollbackOnSetState(t *testing.T) { require.NoError(err) vm.SetStateF = func(context.Context, snow.State) error { - blks[1].StatusV = choices.Processing + blks[1].Status = snowtest.Undecided return nil } @@ -780,7 +779,7 @@ func initializeVMWithBlockchain(vm *block.TestVM, blocks []*snowmantest.Block) { ) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { for _, blk := range blocks { - if blk.Status() == choices.Accepted && blk.ID() == blkID { + if blk.Status == snowtest.Accepted && blk.ID() == blkID { return blk, nil } } @@ -796,12 +795,6 @@ func initializeVMWithBlockchain(vm *block.TestVM, blocks []*snowmantest.Block) { } } -func requireStatusIs(require *require.Assertions, blocks []*snowmantest.Block, status choices.Status) { - for i, blk := range blocks { - require.Equal(status, blk.Status(), i) - } -} - func blocksToIDs(blocks []*snowmantest.Block) []ids.ID { blkIDs := make([]ids.ID, len(blocks)) for i, blk := range blocks { diff --git a/snow/engine/snowman/bootstrap/storage_test.go b/snow/engine/snowman/bootstrap/storage_test.go index a4373f3bbfdf..44ac1621226d 100644 --- a/snow/engine/snowman/bootstrap/storage_test.go +++ b/snow/engine/snowman/bootstrap/storage_test.go @@ -13,12 +13,12 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/engine/snowman/bootstrap/interval" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" ) @@ -277,10 +277,10 @@ func TestExecute(t *testing.T) { test.lastAcceptedHeight, )) for _, height := range test.expectedProcessingHeights { - require.Equal(choices.Processing, blocks[height].Status()) + require.Equal(snowtest.Undecided, blocks[height].Status) } for _, height := range test.expectedAcceptedHeights { - require.Equal(choices.Accepted, blocks[height].Status()) + require.Equal(snowtest.Accepted, blocks[height].Status) } if test.haltable.Halted() { diff --git a/snow/engine/snowman/transitive_test.go b/snow/engine/snowman/transitive_test.go index 8fdab1afc177..0428ddcaa5bb 100644 --- a/snow/engine/snowman/transitive_test.go +++ b/snow/engine/snowman/transitive_test.go @@ -18,7 +18,6 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowball" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" @@ -296,8 +295,8 @@ func TestEngineQuery(t *testing.T) { // apply the votes received during the poll for [parent]. Applying the votes // should cause both [parent] and [child] to be accepted. require.NoError(engine.Put(context.Background(), getRequest.NodeID, getRequest.RequestID, child.Bytes())) - require.Equal(choices.Accepted, parent.Status()) - require.Equal(choices.Accepted, child.Status()) + require.Equal(snowtest.Accepted, parent.Status) + require.Equal(snowtest.Accepted, child.Status) require.Zero(engine.blocked.NumDependencies()) } @@ -443,7 +442,7 @@ func TestEngineMultipleQuery(t *testing.T) { // Should be dropped because the query was already filled require.NoError(te.Chits(context.Background(), vdr2, *queryRequestID, blk0.ID(), blk0.ID(), blk0.ID())) - require.Equal(choices.Accepted, blk1.Status()) + require.Equal(snowtest.Accepted, blk1.Status) require.Zero(te.blocked.NumDependencies()) } @@ -1118,9 +1117,9 @@ func TestEngineBlockingChitResponse(t *testing.T) { getRequest.RequestID, missingBlk.Bytes(), )) - require.Equal(choices.Accepted, missingBlk.Status()) - require.Equal(choices.Accepted, blockingBlk.Status()) - require.Equal(choices.Rejected, issuedBlk.Status()) + require.Equal(snowtest.Accepted, missingBlk.Status) + require.Equal(snowtest.Accepted, blockingBlk.Status) + require.Equal(snowtest.Rejected, issuedBlk.Status) } func TestEngineRetryFetch(t *testing.T) { @@ -1209,7 +1208,7 @@ func TestEngineUndeclaredDependencyDeadlock(t *testing.T) { )) require.NoError(te.Chits(context.Background(), vdr, *reqID, invalidBlkID, invalidBlkID, invalidBlkID)) - require.Equal(choices.Accepted, validBlk.Status()) + require.Equal(snowtest.Accepted, validBlk.Status) } func TestEngineGossip(t *testing.T) { @@ -1548,16 +1547,16 @@ func TestEngineDoubleChit(t *testing.T) { return nil, errUnknownBlock } - require.Equal(choices.Processing, blk.Status()) + require.Equal(snowtest.Undecided, blk.Status) require.NoError(te.Chits(context.Background(), vdr0, *queryRequestID, blk.ID(), blk.ID(), blk.ID())) - require.Equal(choices.Processing, blk.Status()) + require.Equal(snowtest.Undecided, blk.Status) require.NoError(te.Chits(context.Background(), vdr0, *queryRequestID, blk.ID(), blk.ID(), blk.ID())) - require.Equal(choices.Processing, blk.Status()) + require.Equal(snowtest.Undecided, blk.Status) require.NoError(te.Chits(context.Background(), vdr1, *queryRequestID, blk.ID(), blk.ID(), blk.ID())) - require.Equal(choices.Accepted, blk.Status()) + require.Equal(snowtest.Accepted, blk.Status) } func TestEngineBuildBlockLimit(t *testing.T) { @@ -1695,7 +1694,7 @@ func TestEngineDropRejectedBlockOnReceipt(t *testing.T) { // Vote for [acceptedBlk] and cause it to be accepted. require.NoError(te.Chits(context.Background(), nodeID, queryRequestIDs[0], acceptedBlk.ID(), acceptedBlk.ID(), acceptedBlk.ID())) require.Len(queryRequestIDs, 1) // Shouldn't have caused another query - require.Equal(choices.Accepted, acceptedBlk.Status()) + require.Equal(snowtest.Accepted, acceptedBlk.Status) // Attempt to issue rejectedChain[1] to the engine. This should be dropped // because the engine knows it has rejected it's parent rejectedChain[0]. @@ -1866,8 +1865,8 @@ func TestEngineBubbleVotesThroughInvalidBlock(t *testing.T) { require.NoError(te.Put(context.Background(), *reqVdr, *sendReqID, blk2.Bytes())) // The vote should be bubbled through [blk2], such that [blk1] gets marked as Accepted. - require.Equal(choices.Accepted, blk1.Status()) - require.Equal(choices.Processing, blk2.Status()) + require.Equal(snowtest.Accepted, blk1.Status) + require.Equal(snowtest.Undecided, blk2.Status) // Now that [blk1] has been marked as Accepted, [blk2] can pass verification. blk2.VerifyV = nil @@ -1900,7 +1899,7 @@ func TestEngineBubbleVotesThroughInvalidBlock(t *testing.T) { // After a single vote for [blk2], it should be marked as accepted. require.NoError(te.Chits(context.Background(), vdr, *queryRequestID, blk2.ID(), blk1.ID(), blk2.ID())) - require.Equal(choices.Accepted, blk2.Status()) + require.Equal(snowtest.Accepted, blk2.Status) } // Test that in the following scenario, if block B fails verification, votes @@ -2023,7 +2022,7 @@ func TestEngineBubbleVotesThroughInvalidChain(t *testing.T) { // The vote should be bubbled through [blk3] and [blk2] such that [blk1] // gets marked as Accepted. - require.Equal(choices.Accepted, blk1.Status()) + require.Equal(snowtest.Accepted, blk1.Status) } func TestEngineBuildBlockWithCachedNonVerifiedParent(t *testing.T) { @@ -2121,8 +2120,8 @@ func TestEngineBuildBlockWithCachedNonVerifiedParent(t *testing.T) { // Assert that the blocks' statuses are correct. // The evicted [parentBlkA] shouldn't be changed. - require.Equal(choices.Processing, parentBlkA.Status()) - require.Equal(choices.Accepted, parentBlkB.Status()) + require.Equal(snowtest.Undecided, parentBlkA.Status) + require.Equal(snowtest.Accepted, parentBlkB.Status) vm.BuildBlockF = func(context.Context) (snowman.Block, error) { return childBlk, nil @@ -2215,7 +2214,7 @@ func TestEngineApplyAcceptedFrontierInQueryFailed(t *testing.T) { return nil, errUnknownBlock } - require.Equal(choices.Processing, blk.Status()) + require.Equal(snowtest.Undecided, blk.Status) sender.SendPullQueryF = func(_ context.Context, inVdrs set.Set[ids.NodeID], requestID uint32, blkID ids.ID, requestedHeight uint64) { *queryRequestID = requestID @@ -2226,11 +2225,11 @@ func TestEngineApplyAcceptedFrontierInQueryFailed(t *testing.T) { require.NoError(te.Chits(context.Background(), vdr, *queryRequestID, blk.ID(), blk.ID(), blk.ID())) - require.Equal(choices.Processing, blk.Status()) + require.Equal(snowtest.Undecided, blk.Status) require.NoError(te.QueryFailed(context.Background(), vdr, *queryRequestID)) - require.Equal(choices.Accepted, blk.Status()) + require.Equal(snowtest.Accepted, blk.Status) } func TestEngineRepollsMisconfiguredSubnet(t *testing.T) { @@ -2330,7 +2329,7 @@ func TestEngineRepollsMisconfiguredSubnet(t *testing.T) { // Voting for the block that was issued during the period when the validator // set was misconfigured should result in it being accepted successfully. require.NoError(te.Chits(context.Background(), vdr, queryRequestID, blk.ID(), blk.ID(), blk.ID())) - require.Equal(choices.Accepted, blk.Status()) + require.Equal(snowtest.Accepted, blk.Status) } // Full blockchain structure: @@ -2578,10 +2577,10 @@ func TestEngineVoteStallRegression(t *testing.T) { getBlock3Request.RequestID, rejectedChain[0].Bytes(), )) - require.Equal(choices.Accepted, acceptedChain[0].Status()) - require.Equal(choices.Accepted, acceptedChain[1].Status()) - require.Equal(choices.Processing, acceptedChain[2].Status()) - require.Equal(choices.Rejected, rejectedChain[0].Status()) + require.Equal(snowtest.Accepted, acceptedChain[0].Status) + require.Equal(snowtest.Accepted, acceptedChain[1].Status) + require.Equal(snowtest.Undecided, acceptedChain[2].Status) + require.Equal(snowtest.Rejected, rejectedChain[0].Status) // Then engine should issue as many queries as needed to confirm block 2. for i := 2; i < len(pollRequestIDs); i++ { @@ -2596,10 +2595,10 @@ func TestEngineVoteStallRegression(t *testing.T) { )) } } - require.Equal(choices.Accepted, acceptedChain[0].Status()) - require.Equal(choices.Accepted, acceptedChain[1].Status()) - require.Equal(choices.Accepted, acceptedChain[2].Status()) - require.Equal(choices.Rejected, rejectedChain[0].Status()) + require.Equal(snowtest.Accepted, acceptedChain[0].Status) + require.Equal(snowtest.Accepted, acceptedChain[1].Status) + require.Equal(snowtest.Accepted, acceptedChain[2].Status) + require.Equal(snowtest.Rejected, rejectedChain[0].Status) } // When a voter is registered with multiple dependencies, the engine must not @@ -2726,11 +2725,10 @@ func TestEngineEarlyTerminateVoterRegression(t *testing.T) { // Because Put added a new preferred block to the chain, a new poll will be // created. require.Len(pollRequestIDs, 2) - require.Equal(choices.Accepted, chain[0].Status()) - require.Equal(choices.Accepted, chain[1].Status()) - // Block 2 still hasn't been issued, so it's status should remain - // Processing. - require.Equal(choices.Processing, chain[2].Status()) + require.Equal(snowtest.Accepted, chain[0].Status) + require.Equal(snowtest.Accepted, chain[1].Status) + // Block 2 still hasn't been issued, so it's status should remain Undecided. + require.Equal(snowtest.Undecided, chain[2].Status) } // Voting for an unissued cached block that fails verification should not @@ -2883,8 +2881,8 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) { )) // There are no processing blocks, so no new poll should be created. require.Len(pollRequestIDs, 1) - require.Equal(choices.Accepted, acceptedChain[0].Status()) - require.Equal(choices.Rejected, rejectedChain[0].Status()) + require.Equal(snowtest.Accepted, acceptedChain[0].Status) + require.Equal(snowtest.Rejected, rejectedChain[0].Status) // Issue acceptedChain[1] to consensus. require.NoError(engine.PushQuery( @@ -2926,7 +2924,7 @@ func TestEngineRegistersInvalidVoterDependencyRegression(t *testing.T) { snowmantest.GenesisID, )) require.Len(pollRequestIDs, 3) - require.Equal(choices.Accepted, acceptedChain[1].Status()) + require.Equal(snowtest.Accepted, acceptedChain[1].Status) } func TestGetProcessingAncestor(t *testing.T) { diff --git a/snow/snowtest/status.go b/snow/snowtest/status.go index 2fe571271927..13e368fbae20 100644 --- a/snow/snowtest/status.go +++ b/snow/snowtest/status.go @@ -3,7 +3,7 @@ package snowtest -type Status uint32 +type Status int // [Undecided] means the operation hasn't been decided yet // [Accepted] means the operation was accepted diff --git a/vms/components/chain/state_test.go b/vms/components/chain/state_test.go index 6402ec06bbc5..88b69a0763b9 100644 --- a/vms/components/chain/state_test.go +++ b/vms/components/chain/state_test.go @@ -14,9 +14,9 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/utils/hashing" ) @@ -34,9 +34,9 @@ func NewTestBlock(i uint64, parentID ids.ID) *snowmantest.Block { b := []byte{byte(i)} id := hashing.ComputeHash256Array(b) return &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: id, - StatusV: choices.Unknown, + Decidable: snowtest.Decidable{ + IDV: id, + Status: -1, }, HeightV: i, ParentV: parentID, @@ -71,7 +71,7 @@ func createInternalBlockFuncs(blks []*snowmantest.Block) ( getBlock := func(_ context.Context, id ids.ID) (snowman.Block, error) { blk, ok := blkMap[id] - if !ok || !blk.Status().Fetched() { + if !ok || blk.Status < 0 { return nil, database.ErrNotFound } @@ -83,8 +83,8 @@ func createInternalBlockFuncs(blks []*snowmantest.Block) ( if !ok { return nil, fmt.Errorf("%w: %x", errUnexpectedBlockBytes, b) } - if blk.Status() == choices.Unknown { - blk.SetStatus(choices.Processing) + if blk.Status < 0 { + blk.Status = snowtest.Undecided } blkMap[blk.ID()] = blk @@ -119,7 +119,7 @@ func checkProcessingBlock(t *testing.T, s *State, blk snowman.Block) { // checkDecidedBlock asserts that [blk] is returned with the correct status by ParseBlock // and GetBlock. // expectedStatus should be either Accepted or Rejected. -func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus choices.Status, cached bool) { +func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus snowtest.Status, cached bool) { require := require.New(t) require.IsType(&BlockWrapper{}, blk) @@ -153,11 +153,11 @@ func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus } func checkAcceptedBlock(t *testing.T, s *State, blk snowman.Block, cached bool) { - checkDecidedBlock(t, s, blk, choices.Accepted, cached) + checkDecidedBlock(t, s, blk, snowtest.Accepted, cached) } func checkRejectedBlock(t *testing.T, s *State, blk snowman.Block, cached bool) { - checkDecidedBlock(t, s, blk, choices.Rejected, cached) + checkDecidedBlock(t, s, blk, snowtest.Rejected, cached) } func TestState(t *testing.T) { @@ -165,7 +165,7 @@ func TestState(t *testing.T) { testBlks := NewTestBlocks(3) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] blk2 := testBlks[2] // Need to create a block with a different bytes and hash here @@ -248,13 +248,13 @@ func TestBuildBlock(t *testing.T) { testBlks := NewTestBlocks(2) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] getBlock, parseBlock := createInternalBlockFuncs(testBlks) buildBlock := func(context.Context) (snowman.Block, error) { // Once the block is built, mark it as processing - blk1.SetStatus(choices.Processing) + blk1.Status = snowtest.Undecided return blk1, nil } @@ -288,7 +288,7 @@ func TestStateDecideBlock(t *testing.T) { testBlks := NewTestBlocks(4) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted badAcceptBlk := testBlks[1] badAcceptBlk.AcceptV = errAccept badVerifyBlk := testBlks[2] @@ -343,7 +343,7 @@ func TestStateParent(t *testing.T) { testBlks := NewTestBlocks(3) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] blk2 := testBlks[2] @@ -385,7 +385,7 @@ func TestGetBlockInternal(t *testing.T) { require := require.New(t) testBlks := NewTestBlocks(1) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ @@ -415,7 +415,7 @@ func TestGetBlockError(t *testing.T) { testBlks := NewTestBlocks(2) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] getBlock, parseBlock := createInternalBlockFuncs(testBlks) @@ -440,9 +440,9 @@ func TestGetBlockError(t *testing.T) { _, err := chainState.GetBlock(context.Background(), blk1.ID()) require.ErrorIs(err, database.ErrNotFound) - // Update the status to Processing, so that it will be returned by the internal get block - // function. - blk1.SetStatus(choices.Processing) + // Update the status to Undecided, so that it will be returned by the + // internal get block function. + blk1.Status = snowtest.Undecided blk, err := chainState.GetBlock(context.Background(), blk1.ID()) require.NoError(err) require.Equal(blk1.ID(), blk.ID()) @@ -452,7 +452,7 @@ func TestGetBlockError(t *testing.T) { func TestParseBlockError(t *testing.T) { testBlks := NewTestBlocks(1) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ @@ -473,7 +473,7 @@ func TestParseBlockError(t *testing.T) { func TestBuildBlockError(t *testing.T) { testBlks := NewTestBlocks(1) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ @@ -498,7 +498,7 @@ func TestMeteredCache(t *testing.T) { testBlks := NewTestBlocks(1) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted getBlock, parseBlock := createInternalBlockFuncs(testBlks) config := &Config{ @@ -523,7 +523,7 @@ func TestStateBytesToIDCache(t *testing.T) { testBlks := NewTestBlocks(3) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] blk2 := testBlks[2] @@ -576,7 +576,7 @@ func TestSetLastAcceptedBlock(t *testing.T) { testBlks := NewTestBlocks(1) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted postSetBlk1ParentID := hashing.ComputeHash256Array([]byte{byte(199)}) postSetBlk1 := NewTestBlock(200, postSetBlk1ParentID) @@ -625,14 +625,14 @@ func TestSetLastAcceptedBlockWithProcessingBlocksErrors(t *testing.T) { testBlks := NewTestBlocks(5) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] resetBlk := testBlks[4] getBlock, parseBlock := createInternalBlockFuncs(testBlks) buildBlock := func(context.Context) (snowman.Block, error) { - // Once the block is built, mark it as processing - blk1.SetStatus(choices.Processing) + // Once the block is built, mark it as undecided + genesisBlock.Status = snowtest.Undecided return blk1, nil } @@ -665,10 +665,10 @@ func TestStateParseTransitivelyAcceptedBlock(t *testing.T) { testBlks := NewTestBlocks(3) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] blk2 := testBlks[2] - blk2.SetStatus(choices.Accepted) + blk2.Status = snowtest.Accepted getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ @@ -692,7 +692,7 @@ func TestIsProcessing(t *testing.T) { testBlks := NewTestBlocks(2) genesisBlock := testBlks[0] - genesisBlock.SetStatus(choices.Accepted) + genesisBlock.Status = snowtest.Accepted blk1 := testBlks[1] getBlock, parseBlock := createInternalBlockFuncs(testBlks) diff --git a/vms/proposervm/post_fork_block_test.go b/vms/proposervm/post_fork_block_test.go index f59463a77049..be61e0fb75a6 100644 --- a/vms/proposervm/post_fork_block_test.go +++ b/vms/proposervm/post_fork_block_test.go @@ -14,9 +14,9 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/proposervm/block" @@ -953,7 +953,7 @@ func TestBlockAccept_PostForkBlock_TwoProBlocksWithSameCoreBlock_OneIsAccepted(t // set proBlk1 as preferred require.NoError(proBlk1.Accept(context.Background())) - require.Equal(choices.Accepted, coreBlk.Status()) + require.Equal(snowtest.Accepted, coreBlk.Status) acceptedID, err := proVM.LastAccepted(context.Background()) require.NoError(err) diff --git a/vms/proposervm/post_fork_option_test.go b/vms/proposervm/post_fork_option_test.go index 30ee4ea91c54..0055fa3f50e2 100644 --- a/vms/proposervm/post_fork_option_test.go +++ b/vms/proposervm/post_fork_option_test.go @@ -15,10 +15,10 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/common" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -350,7 +350,7 @@ func TestBlockReject_InnerBlockIsNotRejected(t *testing.T) { // reject oracle block require.NoError(builtBlk.Reject(context.Background())) - require.NotEqual(choices.Rejected, oracleCoreBlk.Status()) + require.NotEqual(snowtest.Rejected, oracleCoreBlk.Status) // reject an option require.IsType(&postForkBlock{}, builtBlk) @@ -359,7 +359,7 @@ func TestBlockReject_InnerBlockIsNotRejected(t *testing.T) { require.NoError(err) require.NoError(opts[0].Reject(context.Background())) - require.NotEqual(choices.Rejected, oracleCoreBlk.opts[0].Status()) + require.NotEqual(snowtest.Rejected, oracleCoreBlk.opts[0].Status) } func TestBlockVerify_PostForkOption_ParentIsNotOracleWithError(t *testing.T) { diff --git a/vms/proposervm/pre_fork_block_test.go b/vms/proposervm/pre_fork_block_test.go index ce12575ef321..2153a62f9e3b 100644 --- a/vms/proposervm/pre_fork_block_test.go +++ b/vms/proposervm/pre_fork_block_test.go @@ -15,10 +15,10 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" + "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/timer/mockable" @@ -473,7 +473,7 @@ func TestBlockReject_PreForkBlock_InnerBlockIsRejected(t *testing.T) { proBlk := sb.(*preForkBlock) require.NoError(proBlk.Reject(context.Background())) - require.Equal(choices.Rejected, coreBlk.Status()) + require.Equal(snowtest.Rejected, coreBlk.Status) } func TestBlockVerify_ForkBlockIsOracleBlock(t *testing.T) { diff --git a/vms/proposervm/tree/tree_test.go b/vms/proposervm/tree/tree_test.go index 48095a40f638..08cae64145e3 100644 --- a/vms/proposervm/tree/tree_test.go +++ b/vms/proposervm/tree/tree_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" + "github.com/ava-labs/avalanchego/snow/snowtest" ) func TestAcceptSingleBlock(t *testing.T) { @@ -28,7 +28,7 @@ func TestAcceptSingleBlock(t *testing.T) { require.True(contains) require.NoError(tr.Accept(context.Background(), block)) - require.Equal(choices.Accepted, block.Status()) + require.Equal(snowtest.Accepted, block.Status) _, contains = tr.Get(block) require.False(contains) @@ -55,11 +55,11 @@ func TestAcceptBlockConflict(t *testing.T) { require.NoError(tr.Accept(context.Background(), blockToAccept)) // check their statuses and that they are removed from the tree - require.Equal(choices.Accepted, blockToAccept.Status()) + require.Equal(snowtest.Accepted, blockToAccept.Status) _, contains = tr.Get(blockToAccept) require.False(contains) - require.Equal(choices.Rejected, blockToReject.Status()) + require.Equal(snowtest.Rejected, blockToReject.Status) _, contains = tr.Get(blockToReject) require.False(contains) } @@ -90,15 +90,15 @@ func TestAcceptChainConflict(t *testing.T) { require.NoError(tr.Accept(context.Background(), blockToAccept)) // check their statuses and whether they are removed from tree - require.Equal(choices.Accepted, blockToAccept.Status()) + require.Equal(snowtest.Accepted, blockToAccept.Status) _, contains = tr.Get(blockToAccept) require.False(contains) - require.Equal(choices.Rejected, blockToReject.Status()) + require.Equal(snowtest.Rejected, blockToReject.Status) _, contains = tr.Get(blockToReject) require.False(contains) - require.Equal(choices.Rejected, blockToRejectChild.Status()) + require.Equal(snowtest.Rejected, blockToRejectChild.Status) _, contains = tr.Get(blockToRejectChild) require.False(contains) } diff --git a/vms/proposervm/vm_test.go b/vms/proposervm/vm_test.go index e5f331b86104..813dc7a86689 100644 --- a/vms/proposervm/vm_test.go +++ b/vms/proposervm/vm_test.go @@ -1195,7 +1195,7 @@ func TestInnerVMRollback(t *testing.T) { // Restart the node and have the inner VM rollback state. require.NoError(proVM.Shutdown(context.Background())) - coreBlk.StatusV = choices.Processing + coreBlk.Status = snowtest.Undecided proVM = New( coreVM, @@ -1382,14 +1382,14 @@ func TestTwoForks_OneIsAccepted(t *testing.T) { require.Equal(yBlock.ID(), zBlock.Parent()) require.Equal(bBlock.ID(), cBlock.Parent()) - require.NotEqual(choices.Rejected, yBlock.Status()) + require.NotEqual(snowtest.Rejected, yBlock.Status) // accept A require.NoError(aBlock.Accept(context.Background())) - require.Equal(choices.Accepted, xBlock.Status()) - require.Equal(choices.Rejected, yBlock.Status()) - require.Equal(choices.Rejected, zBlock.Status()) + require.Equal(snowtest.Accepted, xBlock.Status) + require.Equal(snowtest.Rejected, yBlock.Status) + require.Equal(snowtest.Rejected, zBlock.Status) } func TestTooFarAdvanced(t *testing.T) { @@ -1508,7 +1508,7 @@ func TestTwoOptions_OneIsAccepted(t *testing.T) { require.NoError(bBlock.Accept(context.Background())) // the other pre-fork option should be rejected - require.Equal(choices.Rejected, xBlock.opts[1].Status()) + require.Equal(snowtest.Rejected, xBlock.opts[1].Status) } // Ensure that given the chance, built blocks will reference a lagged P-chain @@ -2036,15 +2036,15 @@ func TestVMInnerBlkCacheDeduplicationRegression(t *testing.T) { require.NoError(aBlock.Accept(context.Background())) require.NoError(bBlock.Reject(context.Background())) - require.Equal(choices.Accepted, xBlock.Status()) + require.Equal(snowtest.Accepted, xBlock.Status) - require.Equal(choices.Accepted, xBlockCopy.Status()) + require.Equal(snowtest.Accepted, xBlockCopy.Status) cachedXBlock, ok := proVM.innerBlkCache.Get(bBlock.ID()) require.True(ok) require.Equal( choices.Accepted, - cachedXBlock.(*snowmantest.Block).Status(), + cachedXBlock.(*snowmantest.Block).Status, ) } diff --git a/vms/rpcchainvm/state_syncable_vm_test.go b/vms/rpcchainvm/state_syncable_vm_test.go index 504f628fc90a..2a65025fd65b 100644 --- a/vms/rpcchainvm/state_syncable_vm_test.go +++ b/vms/rpcchainvm/state_syncable_vm_test.go @@ -16,7 +16,6 @@ import ( "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/snowtest" @@ -42,18 +41,18 @@ var ( // last accepted blocks data before and after summary is accepted preSummaryBlk = &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.ID{'f', 'i', 'r', 's', 't', 'B', 'l', 'K'}, - StatusV: choices.Accepted, + Decidable: snowtest.Decidable{ + IDV: ids.ID{'f', 'i', 'r', 's', 't', 'B', 'l', 'K'}, + Status: snowtest.Accepted, }, HeightV: preSummaryHeight, ParentV: ids.ID{'p', 'a', 'r', 'e', 'n', 't', 'B', 'l', 'k'}, } summaryBlk = &snowmantest.Block{ - TestDecidable: choices.TestDecidable{ - IDV: ids.ID{'s', 'u', 'm', 'm', 'a', 'r', 'y', 'B', 'l', 'K'}, - StatusV: choices.Accepted, + Decidable: snowtest.Decidable{ + IDV: ids.ID{'s', 'u', 'm', 'm', 'a', 'r', 'y', 'B', 'l', 'K'}, + Status: snowtest.Accepted, }, HeightV: SummaryHeight, ParentV: ids.ID{'p', 'a', 'r', 'e', 'n', 't', 'B', 'l', 'k'}, From 89af4256b593728258b25f94022d3a828a68b29e Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 17:50:04 -0400 Subject: [PATCH 08/24] nit --- vms/components/chain/state_test.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/vms/components/chain/state_test.go b/vms/components/chain/state_test.go index 88b69a0763b9..905341727dd1 100644 --- a/vms/components/chain/state_test.go +++ b/vms/components/chain/state_test.go @@ -119,7 +119,7 @@ func checkProcessingBlock(t *testing.T, s *State, blk snowman.Block) { // checkDecidedBlock asserts that [blk] is returned with the correct status by ParseBlock // and GetBlock. // expectedStatus should be either Accepted or Rejected. -func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus snowtest.Status, cached bool) { +func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, cached bool) { require := require.New(t) require.IsType(&BlockWrapper{}, blk) @@ -152,14 +152,6 @@ func checkDecidedBlock(t *testing.T, s *State, blk snowman.Block, expectedStatus require.Equal(parsedBlk, getBlk) } -func checkAcceptedBlock(t *testing.T, s *State, blk snowman.Block, cached bool) { - checkDecidedBlock(t, s, blk, snowtest.Accepted, cached) -} - -func checkRejectedBlock(t *testing.T, s *State, blk snowman.Block, cached bool) { - checkDecidedBlock(t, s, blk, snowtest.Rejected, cached) -} - func TestState(t *testing.T) { require := require.New(t) @@ -237,10 +229,10 @@ func TestState(t *testing.T) { // Flush the caches to ensure decided blocks are handled correctly on cache misses. chainState.Flush() - checkAcceptedBlock(t, chainState, wrappedGenesisBlk, false) - checkAcceptedBlock(t, chainState, parsedBlk1, false) - checkAcceptedBlock(t, chainState, parsedBlk2, false) - checkRejectedBlock(t, chainState, parsedBlk3, false) + checkDecidedBlock(t, chainState, wrappedGenesisBlk, false) + checkDecidedBlock(t, chainState, parsedBlk1, false) + checkDecidedBlock(t, chainState, parsedBlk2, false) + checkDecidedBlock(t, chainState, parsedBlk3, false) } func TestBuildBlock(t *testing.T) { @@ -280,7 +272,7 @@ func TestBuildBlock(t *testing.T) { require.NoError(builtBlk.Accept(context.Background())) - checkAcceptedBlock(t, chainState, builtBlk, true) + checkDecidedBlock(t, chainState, builtBlk, true) } func TestStateDecideBlock(t *testing.T) { @@ -373,7 +365,7 @@ func TestStateParent(t *testing.T) { genesisBlkParentID := parsedBlk1.Parent() genesisBlkParent, err := chainState.GetBlock(context.Background(), genesisBlkParentID) require.NoError(err) - checkAcceptedBlock(t, chainState, genesisBlkParent, true) + checkDecidedBlock(t, chainState, genesisBlkParent, true) parentBlk1ID := parsedBlk2.Parent() parentBlk1, err := chainState.GetBlock(context.Background(), parentBlk1ID) @@ -617,7 +609,7 @@ func TestSetLastAcceptedBlock(t *testing.T) { require.Equal(postSetBlk2.ID(), lastAcceptedID) require.Equal(postSetBlk2.ID(), chainState.LastAcceptedBlock().ID()) - checkAcceptedBlock(t, chainState, parsedpostSetBlk2, false) + checkDecidedBlock(t, chainState, parsedpostSetBlk2, false) } func TestSetLastAcceptedBlockWithProcessingBlocksErrors(t *testing.T) { From df69a947ddd52c0904f812d4dd4818be9172d4b4 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Sun, 30 Jun 2024 18:05:01 -0400 Subject: [PATCH 09/24] nit --- vms/proposervm/batched_vm.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vms/proposervm/batched_vm.go b/vms/proposervm/batched_vm.go index d9512a95ce5e..86672bdc19ea 100644 --- a/vms/proposervm/batched_vm.go +++ b/vms/proposervm/batched_vm.go @@ -159,6 +159,5 @@ func (vm *VM) getStatelessBlk(blkID ids.ID) (statelessblock.Block, error) { if currentBlk, exists := vm.verifiedBlocks[blkID]; exists { return currentBlk.getStatelessBlk(), nil } - statelessBlock, err := vm.State.GetBlock(blkID) - return statelessBlock, err + return vm.State.GetBlock(blkID) } From 937e553366b277886a39562b1e2907d70554ed28 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 2 Jul 2024 14:23:34 -0400 Subject: [PATCH 10/24] update coreth --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cf4ca86ee324..e1578d8bc63b 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.5-rc.0 + github.com/ava-labs/coreth v0.13.6-remove-status github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index f969c7512b4f..2a6710eaa6d4 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.5-rc.0 h1:PJQbR9o2RrW3j9ba4r1glXnmM2PNAP3xR569+gMcBd0= -github.com/ava-labs/coreth v0.13.5-rc.0/go.mod h1:cm5c12xo5NiTgtbmeduv8i2nYdzgkczz9Wm3yiwwTRU= +github.com/ava-labs/coreth v0.13.6-remove-status h1:vPHsy9rMRHou4/EuNVeTec14zVQ/BTwQG4yX8URrjY4= +github.com/ava-labs/coreth v0.13.6-remove-status/go.mod h1:MWVPvGqJMNnYYUevYe1+zq15Wzc9xJhbqKVZWQMWjfY= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= From 554fb76cc4951c703b6dbd902418bb2d70515338 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 2 Jul 2024 14:26:47 -0400 Subject: [PATCH 11/24] nit --- snow/snowtest/status.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/snow/snowtest/status.go b/snow/snowtest/status.go index 13e368fbae20..6fd90f856a3f 100644 --- a/snow/snowtest/status.go +++ b/snow/snowtest/status.go @@ -13,3 +13,16 @@ const ( Accepted Rejected ) + +func (s Status) String() string { + switch s { + case Undecided: + return "Undecided" + case Accepted: + return "Accepted" + case Rejected: + return "Rejected" + default: + return "Unknown" + } +} From ca3534145f982a29cb172deb6a0d29bfd920ed5c Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Wed, 3 Jul 2024 17:40:49 -0400 Subject: [PATCH 12/24] lint --- vms/components/chain/state.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vms/components/chain/state.go b/vms/components/chain/state.go index 0fa80f2295d6..d5021355e3a0 100644 --- a/vms/components/chain/state.go +++ b/vms/components/chain/state.go @@ -224,7 +224,7 @@ func (s *State) GetBlock(ctx context.Context, blkID ids.ID) (snowman.Block, erro // Since this block is not in consensus, addBlockOutsideConsensus // is called to add [blk] to the correct cache. - return s.addBlockOutsideConsensus(ctx, blk) + return s.addBlockOutsideConsensus(blk) } // getCachedBlock checks the caches for [blkID] by priority. Returning @@ -290,7 +290,7 @@ func (s *State) ParseBlock(ctx context.Context, b []byte) (snowman.Block, error) // Since this block is not in consensus, addBlockOutsideConsensus // is called to add [blk] to the correct cache. - return s.addBlockOutsideConsensus(ctx, blk) + return s.addBlockOutsideConsensus(blk) } // BatchedParseBlock implements part of the block.BatchedChainVM interface. In @@ -365,7 +365,7 @@ func (s *State) BatchedParseBlock(ctx context.Context, blksBytes [][]byte) ([]sn } s.missingBlocks.Evict(blkID) - wrappedBlk, err := s.addBlockOutsideConsensus(ctx, blk) + wrappedBlk, err := s.addBlockOutsideConsensus(blk) if err != nil { return nil, err } @@ -387,7 +387,7 @@ func (s *State) BuildBlockWithContext(ctx context.Context, blockCtx *block.Conte return nil, err } - return s.deduplicate(ctx, blk) + return s.deduplicate(blk) } // BuildBlock attempts to build a new internal Block, wraps it, and adds it @@ -398,10 +398,10 @@ func (s *State) BuildBlock(ctx context.Context) (snowman.Block, error) { return nil, err } - return s.deduplicate(ctx, blk) + return s.deduplicate(blk) } -func (s *State) deduplicate(ctx context.Context, blk snowman.Block) (snowman.Block, error) { +func (s *State) deduplicate(blk snowman.Block) (snowman.Block, error) { blkID := blk.ID() // Defensive: buildBlock should not return a block that has already been verified. // If it does, make sure to return the existing reference to the block. @@ -413,7 +413,7 @@ func (s *State) deduplicate(ctx context.Context, blk snowman.Block) (snowman.Blo s.missingBlocks.Evict(blkID) // wrap the returned block and add it to the correct cache - return s.addBlockOutsideConsensus(ctx, blk) + return s.addBlockOutsideConsensus(blk) } // addBlockOutsideConsensus adds [blk] to the correct cache and returns @@ -421,7 +421,7 @@ func (s *State) deduplicate(ctx context.Context, blk snowman.Block) (snowman.Blo // assumes [blk] is a known, non-wrapped block that is not currently // in consensus. [blk] could be either decided or a block that has not yet // been verified and added to consensus. -func (s *State) addBlockOutsideConsensus(ctx context.Context, blk snowman.Block) (snowman.Block, error) { +func (s *State) addBlockOutsideConsensus(blk snowman.Block) (snowman.Block, error) { wrappedBlk := &BlockWrapper{ Block: blk, state: s, From 888fbaaa9e45a00afe8b10fc8c16af34e4818974 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 5 Jul 2024 14:57:11 -0400 Subject: [PATCH 13/24] Fix bootstrapping test --- snow/consensus/snowman/snowmantest/engine.go | 20 ++++++++++++++- snow/engine/snowman/getter/getter_test.go | 27 ++++++++++++-------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/snow/consensus/snowman/snowmantest/engine.go b/snow/consensus/snowman/snowmantest/engine.go index 0ff2d8f3a374..2205845a69ed 100644 --- a/snow/consensus/snowman/snowmantest/engine.go +++ b/snow/consensus/snowman/snowmantest/engine.go @@ -6,12 +6,13 @@ package snowmantest import ( "context" + "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/snowtest" ) func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, error) { - return func(_ context.Context) (ids.ID, error) { + return func(context.Context) (ids.ID, error) { var ( highestHeight uint64 highestID ids.ID @@ -31,3 +32,20 @@ func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, err return highestID, nil } } + +func MakeGetBlockIDAtHeightF(blks ...[]*Block) func(context.Context, uint64) (ids.ID, error) { + return func(_ context.Context, height uint64) (ids.ID, error) { + for _, blks := range blks { + for _, blk := range blks { + if blk.Status != snowtest.Accepted { + continue + } + + if height == blk.Height() { + return blk.ID(), nil + } + } + } + return ids.Empty, database.ErrNotFound + } +} diff --git a/snow/engine/snowman/getter/getter_test.go b/snow/engine/snowman/getter/getter_test.go index cf58841b9581..6d1324cb2a32 100644 --- a/snow/engine/snowman/getter/getter_test.go +++ b/snow/engine/snowman/getter/getter_test.go @@ -80,20 +80,25 @@ func TestFilterAccepted(t *testing.T) { acceptedBlk := snowmantest.BuildChild(snowmantest.Genesis) require.NoError(acceptedBlk.Accept(context.Background())) - unknownBlkID := ids.GenerateTestID() + var ( + allBlocks = []*snowmantest.Block{ + snowmantest.Genesis, + acceptedBlk, + } + unknownBlkID = ids.GenerateTestID() + ) + vm.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF(allBlocks) + vm.GetBlockIDAtHeightF = snowmantest.MakeGetBlockIDAtHeightF(allBlocks) vm.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - switch blkID { - case snowmantest.GenesisID: - return snowmantest.Genesis, nil - case acceptedBlk.ID(): - return acceptedBlk, nil - case unknownBlkID: - return nil, errUnknownBlock - default: - require.FailNow(errUnknownBlock.Error()) - return nil, errUnknownBlock + for _, blk := range allBlocks { + if blk.ID() == blkID { + return blk, nil + } } + + require.Equal(unknownBlkID, blkID) + return nil, errUnknownBlock } var accepted []ids.ID From f8f833717775280bc9e27209509944a24b2ac416 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 5 Jul 2024 15:20:09 -0400 Subject: [PATCH 14/24] wip --- vms/proposervm/vm_test.go | 158 ++++++++++++-------------------------- 1 file changed, 48 insertions(+), 110 deletions(-) diff --git a/vms/proposervm/vm_test.go b/vms/proposervm/vm_test.go index 2b5d8a15cd6e..5a73d0db189a 100644 --- a/vms/proposervm/vm_test.go +++ b/vms/proposervm/vm_test.go @@ -21,7 +21,6 @@ import ( "github.com/ava-labs/avalanchego/database/prefixdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/consensus/snowman/snowmantest" "github.com/ava-labs/avalanchego/snow/engine/common" @@ -32,7 +31,6 @@ import ( "github.com/ava-labs/avalanchego/utils" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/proposervm/proposer" - "github.com/ava-labs/avalanchego/vms/proposervm/state" statelessblock "github.com/ava-labs/avalanchego/vms/proposervm/block" ) @@ -1060,61 +1058,62 @@ func TestInnerVMRollback(t *testing.T) { valState := &validators.TestState{ T: t, + GetCurrentHeightF: func(context.Context) (uint64, error) { + return defaultPChainHeight, nil + }, + GetValidatorSetF: func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { + nodeID := ids.BuildTestNodeID([]byte{1}) + return map[ids.NodeID]*validators.GetValidatorOutput{ + nodeID: { + NodeID: nodeID, + Weight: 100, + }, + }, nil + }, } - valState.GetCurrentHeightF = func(context.Context) (uint64, error) { - return defaultPChainHeight, nil - } - valState.GetValidatorSetF = func(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) { - nodeID := ids.BuildTestNodeID([]byte{1}) - return map[ids.NodeID]*validators.GetValidatorOutput{ - nodeID: { - NodeID: nodeID, - Weight: 100, - }, - }, nil - } - - coreVM := &block.TestVM{} - coreVM.T = t - coreVM.LastAcceptedF = snowmantest.MakeLastAcceptedBlockF( - []*snowmantest.Block{snowmantest.Genesis}, - ) - coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - switch blkID { - case snowmantest.GenesisID: - return snowmantest.Genesis, nil - default: - return nil, errUnknownBlock - } - } - coreVM.ParseBlockF = func(_ context.Context, b []byte) (snowman.Block, error) { - switch { - case bytes.Equal(b, snowmantest.GenesisBytes): - return snowmantest.Genesis, nil - default: - return nil, errUnknownBlock - } + coreVM := &block.TestVM{ + TestVM: common.TestVM{ + T: t, + InitializeF: func( + context.Context, + *snow.Context, + database.Database, + []byte, + []byte, + []byte, + chan<- common.Message, + []*common.Fx, + common.AppSender, + ) error { + return nil + }, + }, + ParseBlockF: func(_ context.Context, b []byte) (snowman.Block, error) { + switch { + case bytes.Equal(b, snowmantest.GenesisBytes): + return snowmantest.Genesis, nil + default: + return nil, errUnknownBlock + } + }, + GetBlockF: func(_ context.Context, blkID ids.ID) (snowman.Block, error) { + switch blkID { + case snowmantest.GenesisID: + return snowmantest.Genesis, nil + default: + return nil, errUnknownBlock + } + }, + LastAcceptedF: snowmantest.MakeLastAcceptedBlockF( + []*snowmantest.Block{snowmantest.Genesis}, + ), } ctx := snowtest.Context(t, snowtest.CChainID) ctx.NodeID = ids.NodeIDFromCert(pTestCert) ctx.ValidatorState = valState - coreVM.InitializeF = func( - context.Context, - *snow.Context, - database.Database, - []byte, - []byte, - []byte, - chan<- common.Message, - []*common.Fx, - common.AppSender, - ) error { - return nil - } - db := memdb.New() proVM := New( @@ -1943,9 +1942,6 @@ func TestVMInnerBlkCache(t *testing.T) { require.NoError(vm.Shutdown(context.Background())) }() - state := state.NewMockState(ctrl) // mock state - vm.State = state - // Create a block near the tip (0). blkNearTipInnerBytes := []byte{1} blkNearTip, err := statelessblock.Build( @@ -1959,9 +1955,6 @@ func TestVMInnerBlkCache(t *testing.T) { ) require.NoError(err) - // Parse a block. - // Not in the VM's state so need to parse it. - state.EXPECT().GetBlock(blkNearTip.ID()).Return(blkNearTip, choices.Accepted, nil).Times(2) // We will ask the inner VM to parse. mockInnerBlkNearTip := snowmantest.NewMockBlock(ctrl) mockInnerBlkNearTip.EXPECT().Height().Return(uint64(1)).Times(2) @@ -1993,61 +1986,6 @@ func TestVMInnerBlkCache(t *testing.T) { require.False(ok) } -func TestVMInnerBlkCacheDeduplicationRegression(t *testing.T) { - require := require.New(t) - var ( - activationTime = time.Unix(0, 0) - durangoTime = activationTime - ) - coreVM, _, proVM, _ := initTestProposerVM(t, activationTime, durangoTime, 0) - defer func() { - require.NoError(proVM.Shutdown(context.Background())) - }() - - // create pre-fork block X and post-fork block A - xBlock := snowmantest.BuildChild(snowmantest.Genesis) - - coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { - return xBlock, nil - } - aBlock, err := proVM.BuildBlock(context.Background()) - require.NoError(err) - coreVM.BuildBlockF = nil - - bStatelessBlock, err := statelessblock.BuildUnsigned( - snowmantest.GenesisID, - snowmantest.GenesisTimestamp, - defaultPChainHeight, - xBlock.Bytes(), - ) - require.NoError(err) - - xBlockCopy := *xBlock - coreVM.ParseBlockF = func(context.Context, []byte) (snowman.Block, error) { - return &xBlockCopy, nil - } - - bBlockBytes := bStatelessBlock.Bytes() - bBlock, err := proVM.ParseBlock(context.Background(), bBlockBytes) - require.NoError(err) - - require.NoError(aBlock.Verify(context.Background())) - require.NoError(bBlock.Verify(context.Background())) - require.NoError(aBlock.Accept(context.Background())) - require.NoError(bBlock.Reject(context.Background())) - - require.Equal(snowtest.Accepted, xBlock.Status) - - require.Equal(snowtest.Accepted, xBlockCopy.Status) - - cachedXBlock, ok := proVM.innerBlkCache.Get(bBlock.ID()) - require.True(ok) - require.Equal( - choices.Accepted, - cachedXBlock.(*snowmantest.Block).Status, - ) -} - type blockWithVerifyContext struct { *snowmantest.MockBlock *block.MockWithVerifyContext From ffb7bc7011d62aff2b90aceb988b2050b336439d Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 5 Jul 2024 15:22:02 -0400 Subject: [PATCH 15/24] nit --- vms/proposervm/vm_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vms/proposervm/vm_test.go b/vms/proposervm/vm_test.go index 5a73d0db189a..5ad10d3dfd4f 100644 --- a/vms/proposervm/vm_test.go +++ b/vms/proposervm/vm_test.go @@ -1177,7 +1177,7 @@ func TestInnerVMRollback(t *testing.T) { proVM.Clock.Set(statelessBlock.Timestamp()) - lastAcceptedID, err := proVM.GetLastAccepted() + lastAcceptedID, err := proVM.LastAccepted(context.Background()) require.NoError(err) require.Equal(snowmantest.GenesisID, lastAcceptedID) @@ -1188,7 +1188,7 @@ func TestInnerVMRollback(t *testing.T) { require.NoError(proVM.SetPreference(context.Background(), parsedBlock.ID())) require.NoError(parsedBlock.Accept(context.Background())) - lastAcceptedID, err = proVM.GetLastAccepted() + lastAcceptedID, err = proVM.LastAccepted(context.Background()) require.NoError(err) require.Equal(parsedBlock.ID(), lastAcceptedID) From a73ae2e067bd96ed8061eae5c9348b905a9210e7 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 5 Jul 2024 15:39:08 -0400 Subject: [PATCH 16/24] update coreth version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4eef73478aa4..52c55810d0f9 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/ava-labs/coreth v0.13.6-rc.1.0.20240702201359-ba2ce5367874 + github.com/ava-labs/coreth v0.13.7-remove-status github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index 0642e3c0e5fa..f265b48e620b 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.6-rc.1.0.20240702201359-ba2ce5367874 h1:aTDg0jvO07EvUvBYebmLO25bffe1DAaZZPPL0ooGhIA= -github.com/ava-labs/coreth v0.13.6-rc.1.0.20240702201359-ba2ce5367874/go.mod h1:VhNDxZBsqZQQaUTmIkzdyY8UicIsoTDXlRmPaPL9lkA= +github.com/ava-labs/coreth v0.13.7-remove-status h1:NVHOcHcHpgiVbGYQ1TcnnAbf16tONluvVnYt/Gi+bOA= +github.com/ava-labs/coreth v0.13.7-remove-status/go.mod h1:lTa5PYte0AXBtUK866iQrURSuJLprubKjztbDrTWSrQ= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95 h1:dOVbtdnZL++pENdTCNZ1nu41eYDQkTML4sWebDnnq8c= github.com/ava-labs/ledger-avalanche/go v0.0.0-20240610153809-9c955cc90a95/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= From ebc215945614b6c16a16254a10c5c9a7dbbf589f Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 5 Jul 2024 21:08:47 -0400 Subject: [PATCH 17/24] zero state on decision --- vms/example/xsvm/chain/block.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vms/example/xsvm/chain/block.go b/vms/example/xsvm/chain/block.go index bac28c9317c0..e56e49e327ce 100644 --- a/vms/example/xsvm/chain/block.go +++ b/vms/example/xsvm/chain/block.go @@ -101,11 +101,13 @@ func (b *block) Accept(context.Context) error { b.chain.lastAcceptedID = b.id b.chain.lastAcceptedHeight = b.Height() delete(b.chain.verifiedBlocks, b.ParentID) + b.state = nil return nil } func (b *block) Reject(context.Context) error { delete(b.chain.verifiedBlocks, b.id) + b.state = nil // TODO: push transactions back into the mempool return nil @@ -171,12 +173,8 @@ func (b *block) State() (database.Database, error) { return b.chain.acceptedState, nil } - // States of accepted blocks other than the lastAccepted are undefined. - if b.Height() <= b.chain.lastAcceptedHeight { - return nil, errMissingState - } - - // We should not be calling State on an unverified block. + // If this block isn't processing, then the child should never have had + // verify called on it. if b.state == nil { return nil, errParentNotVerified } From 9d0276166a9aca00f055836242be79f8fc6b593c Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Fri, 5 Jul 2024 21:09:10 -0400 Subject: [PATCH 18/24] remove unused error --- vms/example/xsvm/chain/block.go | 1 - 1 file changed, 1 deletion(-) diff --git a/vms/example/xsvm/chain/block.go b/vms/example/xsvm/chain/block.go index e56e49e327ce..6703788fb082 100644 --- a/vms/example/xsvm/chain/block.go +++ b/vms/example/xsvm/chain/block.go @@ -28,7 +28,6 @@ var ( errMissingParent = errors.New("missing parent block") errMissingChild = errors.New("missing child block") errParentNotVerified = errors.New("parent block has not been verified") - errMissingState = errors.New("missing state") errFutureTimestamp = errors.New("future timestamp") errTimestampBeforeParent = errors.New("timestamp before parent") errWrongHeight = errors.New("wrong height") From 35e6f13dc97aa76bbd93ea4ece495e5e22efb61b Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 11 Jul 2024 06:36:26 -0400 Subject: [PATCH 19/24] avoid shadowing --- snow/consensus/snowman/snowmantest/engine.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snow/consensus/snowman/snowmantest/engine.go b/snow/consensus/snowman/snowmantest/engine.go index 2205845a69ed..ee7560eadc51 100644 --- a/snow/consensus/snowman/snowmantest/engine.go +++ b/snow/consensus/snowman/snowmantest/engine.go @@ -17,8 +17,8 @@ func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, err highestHeight uint64 highestID ids.ID ) - for _, blks := range blks { - for _, blk := range blks { + for _, blkSlice := range blks { + for _, blk := range blkSlice { if blk.Status != snowtest.Accepted { continue } @@ -35,8 +35,8 @@ func MakeLastAcceptedBlockF(blks ...[]*Block) func(context.Context) (ids.ID, err func MakeGetBlockIDAtHeightF(blks ...[]*Block) func(context.Context, uint64) (ids.ID, error) { return func(_ context.Context, height uint64) (ids.ID, error) { - for _, blks := range blks { - for _, blk := range blks { + for _, blkSlice := range blks { + for _, blk := range blkSlice { if blk.Status != snowtest.Accepted { continue } From 78567e3115e660ad7404db1df862114c955b1522 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 11 Jul 2024 06:54:15 -0400 Subject: [PATCH 20/24] keep tests for defense in depth --- vms/proposervm/vm_byzantine_test.go | 151 ++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) diff --git a/vms/proposervm/vm_byzantine_test.go b/vms/proposervm/vm_byzantine_test.go index cccdd755586b..ca38084a4125 100644 --- a/vms/proposervm/vm_byzantine_test.go +++ b/vms/proposervm/vm_byzantine_test.go @@ -73,6 +73,157 @@ func TestInvalidByzantineProposerParent(t *testing.T) { require.ErrorIs(err, errUnknownBlock) } +// Ensure that a byzantine node issuing an invalid PreForkBlock (Y or Z) when +// the parent block (X) is issued into a PostForkBlock (A) will be marked as +// invalid correctly. +// +// G +// / | +// A - X +// / \ +// Y Z +func TestInvalidByzantineProposerOracleParent(t *testing.T) { + require := require.New(t) + + var ( + activationTime = time.Unix(0, 0) + durangoTime = activationTime + ) + coreVM, _, proVM, _ := initTestProposerVM(t, activationTime, durangoTime, 0) + proVM.Set(snowmantest.GenesisTimestamp) + defer func() { + require.NoError(proVM.Shutdown(context.Background())) + }() + + xTestBlock := snowmantest.BuildChild(snowmantest.Genesis) + xBlock := &TestOptionsBlock{ + Block: *xTestBlock, + opts: [2]*snowmantest.Block{ + snowmantest.BuildChild(xTestBlock), + snowmantest.BuildChild(xTestBlock), + }, + } + + coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { + return xBlock, nil + } + coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { + switch blkID { + case snowmantest.GenesisID: + return snowmantest.Genesis, nil + case xBlock.ID(): + return xBlock, nil + case xBlock.opts[0].ID(): + return xBlock.opts[0], nil + case xBlock.opts[1].ID(): + return xBlock.opts[1], nil + default: + return nil, database.ErrNotFound + } + } + coreVM.ParseBlockF = func(_ context.Context, b []byte) (snowman.Block, error) { + switch { + case bytes.Equal(b, snowmantest.GenesisBytes): + return snowmantest.Genesis, nil + case bytes.Equal(b, xBlock.Bytes()): + return xBlock, nil + case bytes.Equal(b, xBlock.opts[0].Bytes()): + return xBlock.opts[0], nil + case bytes.Equal(b, xBlock.opts[1].Bytes()): + return xBlock.opts[1], nil + default: + return nil, errUnknownBlock + } + } + + aBlockIntf, err := proVM.BuildBlock(context.Background()) + require.NoError(err) + + require.IsType(&postForkBlock{}, aBlockIntf) + aBlock := aBlockIntf.(*postForkBlock) + opts, err := aBlock.Options(context.Background()) + require.NoError(err) + + require.NoError(aBlock.Verify(context.Background())) + require.NoError(opts[0].Verify(context.Background())) + require.NoError(opts[1].Verify(context.Background())) + + wrappedXBlock, err := proVM.ParseBlock(context.Background(), xBlock.Bytes()) + require.NoError(err) + + // This should never be invoked by the consensus engine. However, it is + // enforced to fail verification as a failsafe. + err = wrappedXBlock.Verify(context.Background()) + require.ErrorIs(err, errUnexpectedBlockType) +} + +// Ensure that a byzantine node issuing an invalid PostForkBlock (B) when the +// parent block (X) is issued into a PostForkBlock (A) will be marked as invalid +// correctly. +// +// G +// / | +// A - X +// / | +// B - Y +func TestInvalidByzantineProposerPreForkParent(t *testing.T) { + require := require.New(t) + + var ( + activationTime = time.Unix(0, 0) + durangoTime = activationTime + ) + coreVM, _, proVM, _ := initTestProposerVM(t, activationTime, durangoTime, 0) + defer func() { + require.NoError(proVM.Shutdown(context.Background())) + }() + + xBlock := snowmantest.BuildChild(snowmantest.Genesis) + coreVM.BuildBlockF = func(context.Context) (snowman.Block, error) { + return xBlock, nil + } + + yBlock := snowmantest.BuildChild(xBlock) + coreVM.GetBlockF = func(_ context.Context, blkID ids.ID) (snowman.Block, error) { + switch blkID { + case snowmantest.GenesisID: + return snowmantest.Genesis, nil + case xBlock.ID(): + return xBlock, nil + case yBlock.ID(): + return yBlock, nil + default: + return nil, errUnknownBlock + } + } + coreVM.ParseBlockF = func(_ context.Context, blockBytes []byte) (snowman.Block, error) { + switch { + case bytes.Equal(blockBytes, snowmantest.GenesisBytes): + return snowmantest.Genesis, nil + case bytes.Equal(blockBytes, xBlock.Bytes()): + return xBlock, nil + case bytes.Equal(blockBytes, yBlock.Bytes()): + return yBlock, nil + default: + return nil, errUnknownBlock + } + } + + aBlock, err := proVM.BuildBlock(context.Background()) + require.NoError(err) + coreVM.BuildBlockF = nil + + require.NoError(aBlock.Verify(context.Background())) + + wrappedXBlock, err := proVM.ParseBlock(context.Background(), xBlock.Bytes()) + require.NoError(err) + + // This should never be invoked by the consensus engine. However, it is + // enforced to fail verification as a failsafe. + err = wrappedXBlock.Verify(context.Background()) + require.ErrorIs(err, errUnexpectedBlockType) +} + // Ensure that a byzantine node issuing an invalid OptionBlock (B) which // contains core block (Y) whose parent (G) doesn't match (B)'s parent (A)'s // inner block (X) will be marked as invalid correctly. From f7c05963f60f9b1b2c21be1b29c1a3f366e21e4f Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 11 Jul 2024 07:02:45 -0400 Subject: [PATCH 21/24] nit --- vms/components/chain/state_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vms/components/chain/state_test.go b/vms/components/chain/state_test.go index 905341727dd1..c186bd0002de 100644 --- a/vms/components/chain/state_test.go +++ b/vms/components/chain/state_test.go @@ -20,6 +20,8 @@ import ( "github.com/ava-labs/avalanchego/utils/hashing" ) +const Unknown snowtest.Status = -1 + var ( errCantBuildBlock = errors.New("can't build new block") errVerify = errors.New("verify failed") @@ -36,7 +38,7 @@ func NewTestBlock(i uint64, parentID ids.ID) *snowmantest.Block { return &snowmantest.Block{ Decidable: snowtest.Decidable{ IDV: id, - Status: -1, + Status: Unknown, }, HeightV: i, ParentV: parentID, @@ -71,7 +73,7 @@ func createInternalBlockFuncs(blks []*snowmantest.Block) ( getBlock := func(_ context.Context, id ids.ID) (snowman.Block, error) { blk, ok := blkMap[id] - if !ok || blk.Status < 0 { + if !ok || blk.Status == Unknown { return nil, database.ErrNotFound } @@ -83,7 +85,7 @@ func createInternalBlockFuncs(blks []*snowmantest.Block) ( if !ok { return nil, fmt.Errorf("%w: %x", errUnexpectedBlockBytes, b) } - if blk.Status < 0 { + if blk.Status == Unknown { blk.Status = snowtest.Undecided } blkMap[blk.ID()] = blk From 165af821a7f12a1ceced7b7b90157d150fd20d64 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 11 Jul 2024 07:51:53 -0400 Subject: [PATCH 22/24] nit --- snow/consensus/snowman/snowmantest/block.go | 2 ++ snow/consensus/snowman/snowmantest/engine.go | 2 ++ snow/consensus/snowman/snowmantest/require.go | 2 ++ snow/snowtest/decidable.go | 2 ++ snow/snowtest/status.go | 2 ++ 5 files changed, 10 insertions(+) diff --git a/snow/consensus/snowman/snowmantest/block.go b/snow/consensus/snowman/snowmantest/block.go index 4dba3d0cc697..19348532e54f 100644 --- a/snow/consensus/snowman/snowmantest/block.go +++ b/snow/consensus/snowman/snowmantest/block.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowmantest import ( diff --git a/snow/consensus/snowman/snowmantest/engine.go b/snow/consensus/snowman/snowmantest/engine.go index ee7560eadc51..954b6bbe7075 100644 --- a/snow/consensus/snowman/snowmantest/engine.go +++ b/snow/consensus/snowman/snowmantest/engine.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowmantest import ( diff --git a/snow/consensus/snowman/snowmantest/require.go b/snow/consensus/snowman/snowmantest/require.go index 7b942740dfd1..5a5e5d09bf44 100644 --- a/snow/consensus/snowman/snowmantest/require.go +++ b/snow/consensus/snowman/snowmantest/require.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowmantest import ( diff --git a/snow/snowtest/decidable.go b/snow/snowtest/decidable.go index 691cc90120bc..3cbdb2c1c9c2 100644 --- a/snow/snowtest/decidable.go +++ b/snow/snowtest/decidable.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowtest import ( diff --git a/snow/snowtest/status.go b/snow/snowtest/status.go index 6fd90f856a3f..36c26f83cbde 100644 --- a/snow/snowtest/status.go +++ b/snow/snowtest/status.go @@ -1,6 +1,8 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. +//go:build test + package snowtest type Status int From 4191d8ee2ec4bfb85d1a1a21c1c2c673bccc2693 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Thu, 11 Jul 2024 08:18:34 -0400 Subject: [PATCH 23/24] nit --- vms/components/chain/state_test.go | 110 +++++++++++++++-------------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/vms/components/chain/state_test.go b/vms/components/chain/state_test.go index c186bd0002de..223b861d27dc 100644 --- a/vms/components/chain/state_test.go +++ b/vms/components/chain/state_test.go @@ -20,7 +20,11 @@ import ( "github.com/ava-labs/avalanchego/utils/hashing" ) -const Unknown snowtest.Status = -1 +const ( + Unknown snowtest.Status = -1 + + defaultBlockCacheSize = 256 +) var ( errCantBuildBlock = errors.New("can't build new block") @@ -169,10 +173,10 @@ func TestState(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -253,10 +257,10 @@ func TestBuildBlock(t *testing.T) { } chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -291,10 +295,10 @@ func TestStateDecideBlock(t *testing.T) { badRejectBlk.RejectV = errReject getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -343,10 +347,10 @@ func TestStateParent(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -383,10 +387,10 @@ func TestGetBlockInternal(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -421,10 +425,10 @@ func TestGetBlockError(t *testing.T) { return blk, nil } chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: wrappedGetBlock, UnmarshalBlock: parseBlock, @@ -450,10 +454,10 @@ func TestParseBlockError(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -471,10 +475,10 @@ func TestBuildBlockError(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -496,10 +500,10 @@ func TestMeteredCache(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) config := &Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -581,10 +585,10 @@ func TestSetLastAcceptedBlock(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -631,10 +635,10 @@ func TestSetLastAcceptedBlockWithProcessingBlocksErrors(t *testing.T) { } chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -666,10 +670,10 @@ func TestStateParseTransitivelyAcceptedBlock(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: blk2, GetBlock: getBlock, UnmarshalBlock: parseBlock, @@ -691,10 +695,10 @@ func TestIsProcessing(t *testing.T) { getBlock, parseBlock := createInternalBlockFuncs(testBlks) chainState := NewState(&Config{ - DecidedCacheSize: 256, - MissingCacheSize: 256, - UnverifiedCacheSize: 256, - BytesToIDCacheSize: 256, + DecidedCacheSize: defaultBlockCacheSize, + MissingCacheSize: defaultBlockCacheSize, + UnverifiedCacheSize: defaultBlockCacheSize, + BytesToIDCacheSize: defaultBlockCacheSize, LastAcceptedBlock: genesisBlock, GetBlock: getBlock, UnmarshalBlock: parseBlock, From a30f1b0058967963791b4df5eebd3963b927fed5 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 16 Jul 2024 12:55:35 -0400 Subject: [PATCH 24/24] remove unused error --- vms/components/chain/state.go | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/vms/components/chain/state.go b/vms/components/chain/state.go index d5021355e3a0..0a01f0d3779a 100644 --- a/vms/components/chain/state.go +++ b/vms/components/chain/state.go @@ -224,7 +224,7 @@ func (s *State) GetBlock(ctx context.Context, blkID ids.ID) (snowman.Block, erro // Since this block is not in consensus, addBlockOutsideConsensus // is called to add [blk] to the correct cache. - return s.addBlockOutsideConsensus(blk) + return s.addBlockOutsideConsensus(blk), nil } // getCachedBlock checks the caches for [blkID] by priority. Returning @@ -290,7 +290,7 @@ func (s *State) ParseBlock(ctx context.Context, b []byte) (snowman.Block, error) // Since this block is not in consensus, addBlockOutsideConsensus // is called to add [blk] to the correct cache. - return s.addBlockOutsideConsensus(blk) + return s.addBlockOutsideConsensus(blk), nil } // BatchedParseBlock implements part of the block.BatchedChainVM interface. In @@ -365,11 +365,7 @@ func (s *State) BatchedParseBlock(ctx context.Context, blksBytes [][]byte) ([]sn } s.missingBlocks.Evict(blkID) - wrappedBlk, err := s.addBlockOutsideConsensus(blk) - if err != nil { - return nil, err - } - blks[i] = wrappedBlk + blks[i] = s.addBlockOutsideConsensus(blk) } return blks, nil } @@ -387,7 +383,7 @@ func (s *State) BuildBlockWithContext(ctx context.Context, blockCtx *block.Conte return nil, err } - return s.deduplicate(blk) + return s.deduplicate(blk), nil } // BuildBlock attempts to build a new internal Block, wraps it, and adds it @@ -398,15 +394,15 @@ func (s *State) BuildBlock(ctx context.Context) (snowman.Block, error) { return nil, err } - return s.deduplicate(blk) + return s.deduplicate(blk), nil } -func (s *State) deduplicate(blk snowman.Block) (snowman.Block, error) { +func (s *State) deduplicate(blk snowman.Block) snowman.Block { blkID := blk.ID() // Defensive: buildBlock should not return a block that has already been verified. // If it does, make sure to return the existing reference to the block. if existingBlk, ok := s.getCachedBlock(blkID); ok { - return existingBlk, nil + return existingBlk } // Evict the produced block from missing blocks in case it was previously // marked as missing. @@ -421,7 +417,7 @@ func (s *State) deduplicate(blk snowman.Block) (snowman.Block, error) { // assumes [blk] is a known, non-wrapped block that is not currently // in consensus. [blk] could be either decided or a block that has not yet // been verified and added to consensus. -func (s *State) addBlockOutsideConsensus(blk snowman.Block) (snowman.Block, error) { +func (s *State) addBlockOutsideConsensus(blk snowman.Block) snowman.Block { wrappedBlk := &BlockWrapper{ Block: blk, state: s, @@ -434,7 +430,7 @@ func (s *State) addBlockOutsideConsensus(blk snowman.Block) (snowman.Block, erro s.unverifiedBlocks.Put(blkID, wrappedBlk) } - return wrappedBlk, nil + return wrappedBlk } func (s *State) LastAccepted(context.Context) (ids.ID, error) {