From 9452318df64538404393a8410606cfb1f0b1c637 Mon Sep 17 00:00:00 2001 From: parketh Date: Wed, 27 Nov 2024 17:23:35 +0000 Subject: [PATCH 1/5] feat: decouple QueryIsBlockBabylonFinalizedFromBabylon --- proto/finalitygadget.pb.go | 121 +++++++++++++++++--------------- proto/finalitygadget.proto | 5 ++ proto/finalitygadget_grpc.pb.go | 55 +++++++++++++-- 3 files changed, 119 insertions(+), 62 deletions(-) diff --git a/proto/finalitygadget.pb.go b/proto/finalitygadget.pb.go index 9942553..027e507 100644 --- a/proto/finalitygadget.pb.go +++ b/proto/finalitygadget.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v4.25.3 +// protoc v5.28.3 // source: proto/finalitygadget.proto package proto @@ -138,6 +138,7 @@ type QueryBlockRangeBabylonFinalizedRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + // blocks is a list of blocks to query Blocks []*BlockInfo `protobuf:"bytes,1,rep,name=blocks,proto3" json:"blocks,omitempty"` } @@ -600,7 +601,7 @@ var file_proto_finalitygadget_proto_rawDesc = []byte{ 0x65, 0x72, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x6e, 0x66, - 0x6f, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x32, 0xd3, 0x05, 0x0a, 0x0e, 0x46, 0x69, 0x6e, + 0x6f, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x32, 0xd0, 0x06, 0x0a, 0x0e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x47, 0x61, 0x64, 0x67, 0x65, 0x74, 0x12, 0x70, 0x0a, 0x1c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x12, 0x2a, 0x2e, 0x70, 0x72, @@ -608,48 +609,56 @@ var file_proto_finalitygadget_proto_rawDesc = []byte{ 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x80, 0x01, - 0x0a, 0x1f, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x61, 0x6e, 0x67, - 0x65, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, - 0x64, 0x12, 0x2d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, - 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x2e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, - 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x86, 0x01, 0x0a, 0x21, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x74, 0x63, 0x53, 0x74, 0x61, - 0x6b, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x42, 0x74, 0x63, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x41, 0x63, - 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x74, 0x63, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x41, - 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x1d, 0x51, 0x75, 0x65, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7b, 0x0a, + 0x27, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x61, 0x62, + 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x46, 0x72, 0x6f, + 0x6d, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x12, 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x61, 0x62, + 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, - 0x65, 0x64, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2b, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, - 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, - 0x1b, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, - 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x12, 0x29, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x1f, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x61, + 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x12, 0x2d, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x46, 0x69, 0x6e, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x86, 0x01, + 0x0a, 0x21, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x74, 0x63, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, + 0x67, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x12, 0x2f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x42, 0x74, 0x63, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x74, 0x69, 0x76, + 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x42, 0x74, 0x63, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x72, 0x0a, 0x1d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, + 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, + 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, - 0x19, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x27, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x46, 0x69, - 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, - 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x62, - 0x79, 0x6c, 0x6f, 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x66, 0x69, 0x6e, 0x61, - 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x67, 0x61, 0x64, 0x67, 0x65, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, + 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x1b, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x64, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x12, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, + 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x42, 0x79, 0x48, 0x61, 0x73, 0x68, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x49, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, + 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x19, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, + 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x46, 0x69, 0x6e, 0x61, 0x6c, + 0x69, 0x7a, 0x65, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, + 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, + 0x79, 0x2d, 0x67, 0x61, 0x64, 0x67, 0x65, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -683,19 +692,21 @@ var file_proto_finalitygadget_proto_depIdxs = []int32{ 0, // 1: proto.QueryBlockRangeBabylonFinalizedRequest.blocks:type_name -> proto.BlockInfo 0, // 2: proto.QueryBlockResponse.block:type_name -> proto.BlockInfo 1, // 3: proto.FinalityGadget.QueryIsBlockBabylonFinalized:input_type -> proto.QueryIsBlockBabylonFinalizedRequest - 2, // 4: proto.FinalityGadget.QueryBlockRangeBabylonFinalized:input_type -> proto.QueryBlockRangeBabylonFinalizedRequest - 4, // 5: proto.FinalityGadget.QueryBtcStakingActivatedTimestamp:input_type -> proto.QueryBtcStakingActivatedTimestampRequest - 6, // 6: proto.FinalityGadget.QueryIsBlockFinalizedByHeight:input_type -> proto.QueryIsBlockFinalizedByHeightRequest - 7, // 7: proto.FinalityGadget.QueryIsBlockFinalizedByHash:input_type -> proto.QueryIsBlockFinalizedByHashRequest - 9, // 8: proto.FinalityGadget.QueryLatestFinalizedBlock:input_type -> proto.QueryLatestFinalizedBlockRequest - 8, // 9: proto.FinalityGadget.QueryIsBlockBabylonFinalized:output_type -> proto.QueryIsBlockFinalizedResponse - 3, // 10: proto.FinalityGadget.QueryBlockRangeBabylonFinalized:output_type -> proto.QueryBlockRangeBabylonFinalizedResponse - 5, // 11: proto.FinalityGadget.QueryBtcStakingActivatedTimestamp:output_type -> proto.QueryBtcStakingActivatedTimestampResponse - 8, // 12: proto.FinalityGadget.QueryIsBlockFinalizedByHeight:output_type -> proto.QueryIsBlockFinalizedResponse - 8, // 13: proto.FinalityGadget.QueryIsBlockFinalizedByHash:output_type -> proto.QueryIsBlockFinalizedResponse - 10, // 14: proto.FinalityGadget.QueryLatestFinalizedBlock:output_type -> proto.QueryBlockResponse - 9, // [9:15] is the sub-list for method output_type - 3, // [3:9] is the sub-list for method input_type + 1, // 4: proto.FinalityGadget.QueryIsBlockBabylonFinalizedFromBabylon:input_type -> proto.QueryIsBlockBabylonFinalizedRequest + 2, // 5: proto.FinalityGadget.QueryBlockRangeBabylonFinalized:input_type -> proto.QueryBlockRangeBabylonFinalizedRequest + 4, // 6: proto.FinalityGadget.QueryBtcStakingActivatedTimestamp:input_type -> proto.QueryBtcStakingActivatedTimestampRequest + 6, // 7: proto.FinalityGadget.QueryIsBlockFinalizedByHeight:input_type -> proto.QueryIsBlockFinalizedByHeightRequest + 7, // 8: proto.FinalityGadget.QueryIsBlockFinalizedByHash:input_type -> proto.QueryIsBlockFinalizedByHashRequest + 9, // 9: proto.FinalityGadget.QueryLatestFinalizedBlock:input_type -> proto.QueryLatestFinalizedBlockRequest + 8, // 10: proto.FinalityGadget.QueryIsBlockBabylonFinalized:output_type -> proto.QueryIsBlockFinalizedResponse + 8, // 11: proto.FinalityGadget.QueryIsBlockBabylonFinalizedFromBabylon:output_type -> proto.QueryIsBlockFinalizedResponse + 3, // 12: proto.FinalityGadget.QueryBlockRangeBabylonFinalized:output_type -> proto.QueryBlockRangeBabylonFinalizedResponse + 5, // 13: proto.FinalityGadget.QueryBtcStakingActivatedTimestamp:output_type -> proto.QueryBtcStakingActivatedTimestampResponse + 8, // 14: proto.FinalityGadget.QueryIsBlockFinalizedByHeight:output_type -> proto.QueryIsBlockFinalizedResponse + 8, // 15: proto.FinalityGadget.QueryIsBlockFinalizedByHash:output_type -> proto.QueryIsBlockFinalizedResponse + 10, // 16: proto.FinalityGadget.QueryLatestFinalizedBlock:output_type -> proto.QueryBlockResponse + 10, // [10:17] is the sub-list for method output_type + 3, // [3:10] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name diff --git a/proto/finalitygadget.proto b/proto/finalitygadget.proto index 58d1329..f07f1ab 100644 --- a/proto/finalitygadget.proto +++ b/proto/finalitygadget.proto @@ -10,6 +10,11 @@ service FinalityGadget { rpc QueryIsBlockBabylonFinalized(QueryIsBlockBabylonFinalizedRequest) returns (QueryIsBlockFinalizedResponse); + // QueryIsBlockBabylonFinalizedFromBabylon returns the finality status of a block by + // querying Babylon chain directly + rpc QueryIsBlockBabylonFinalizedFromBabylon(QueryIsBlockBabylonFinalizedRequest) + returns (QueryIsBlockFinalizedResponse); + // QueryBlockRangeBabylonFinalized returns the last finalized block height // within a block range by querying Babylon chain rpc QueryBlockRangeBabylonFinalized(QueryBlockRangeBabylonFinalizedRequest) diff --git a/proto/finalitygadget_grpc.pb.go b/proto/finalitygadget_grpc.pb.go index e77d75f..21264f0 100644 --- a/proto/finalitygadget_grpc.pb.go +++ b/proto/finalitygadget_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.25.3 +// - protoc v5.28.3 // source: proto/finalitygadget.proto package proto @@ -19,12 +19,13 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - FinalityGadget_QueryIsBlockBabylonFinalized_FullMethodName = "/proto.FinalityGadget/QueryIsBlockBabylonFinalized" - FinalityGadget_QueryBlockRangeBabylonFinalized_FullMethodName = "/proto.FinalityGadget/QueryBlockRangeBabylonFinalized" - FinalityGadget_QueryBtcStakingActivatedTimestamp_FullMethodName = "/proto.FinalityGadget/QueryBtcStakingActivatedTimestamp" - FinalityGadget_QueryIsBlockFinalizedByHeight_FullMethodName = "/proto.FinalityGadget/QueryIsBlockFinalizedByHeight" - FinalityGadget_QueryIsBlockFinalizedByHash_FullMethodName = "/proto.FinalityGadget/QueryIsBlockFinalizedByHash" - FinalityGadget_QueryLatestFinalizedBlock_FullMethodName = "/proto.FinalityGadget/QueryLatestFinalizedBlock" + FinalityGadget_QueryIsBlockBabylonFinalized_FullMethodName = "/proto.FinalityGadget/QueryIsBlockBabylonFinalized" + FinalityGadget_QueryIsBlockBabylonFinalizedFromBabylon_FullMethodName = "/proto.FinalityGadget/QueryIsBlockBabylonFinalizedFromBabylon" + FinalityGadget_QueryBlockRangeBabylonFinalized_FullMethodName = "/proto.FinalityGadget/QueryBlockRangeBabylonFinalized" + FinalityGadget_QueryBtcStakingActivatedTimestamp_FullMethodName = "/proto.FinalityGadget/QueryBtcStakingActivatedTimestamp" + FinalityGadget_QueryIsBlockFinalizedByHeight_FullMethodName = "/proto.FinalityGadget/QueryIsBlockFinalizedByHeight" + FinalityGadget_QueryIsBlockFinalizedByHash_FullMethodName = "/proto.FinalityGadget/QueryIsBlockFinalizedByHash" + FinalityGadget_QueryLatestFinalizedBlock_FullMethodName = "/proto.FinalityGadget/QueryLatestFinalizedBlock" ) // FinalityGadgetClient is the client API for FinalityGadget service. @@ -34,6 +35,9 @@ type FinalityGadgetClient interface { // QueryIsBlockBabylonFinalized returns the finality status of a block by // querying Babylon chain QueryIsBlockBabylonFinalized(ctx context.Context, in *QueryIsBlockBabylonFinalizedRequest, opts ...grpc.CallOption) (*QueryIsBlockFinalizedResponse, error) + // QueryIsBlockBabylonFinalizedFromBabylon returns the finality status of a block by + // querying Babylon chain directly + QueryIsBlockBabylonFinalizedFromBabylon(ctx context.Context, in *QueryIsBlockBabylonFinalizedRequest, opts ...grpc.CallOption) (*QueryIsBlockFinalizedResponse, error) // QueryBlockRangeBabylonFinalized returns the last finalized block height // within a block range by querying Babylon chain QueryBlockRangeBabylonFinalized(ctx context.Context, in *QueryBlockRangeBabylonFinalizedRequest, opts ...grpc.CallOption) (*QueryBlockRangeBabylonFinalizedResponse, error) @@ -68,6 +72,15 @@ func (c *finalityGadgetClient) QueryIsBlockBabylonFinalized(ctx context.Context, return out, nil } +func (c *finalityGadgetClient) QueryIsBlockBabylonFinalizedFromBabylon(ctx context.Context, in *QueryIsBlockBabylonFinalizedRequest, opts ...grpc.CallOption) (*QueryIsBlockFinalizedResponse, error) { + out := new(QueryIsBlockFinalizedResponse) + err := c.cc.Invoke(ctx, FinalityGadget_QueryIsBlockBabylonFinalizedFromBabylon_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *finalityGadgetClient) QueryBlockRangeBabylonFinalized(ctx context.Context, in *QueryBlockRangeBabylonFinalizedRequest, opts ...grpc.CallOption) (*QueryBlockRangeBabylonFinalizedResponse, error) { out := new(QueryBlockRangeBabylonFinalizedResponse) err := c.cc.Invoke(ctx, FinalityGadget_QueryBlockRangeBabylonFinalized_FullMethodName, in, out, opts...) @@ -120,6 +133,9 @@ type FinalityGadgetServer interface { // QueryIsBlockBabylonFinalized returns the finality status of a block by // querying Babylon chain QueryIsBlockBabylonFinalized(context.Context, *QueryIsBlockBabylonFinalizedRequest) (*QueryIsBlockFinalizedResponse, error) + // QueryIsBlockBabylonFinalizedFromBabylon returns the finality status of a block by + // querying Babylon chain directly + QueryIsBlockBabylonFinalizedFromBabylon(context.Context, *QueryIsBlockBabylonFinalizedRequest) (*QueryIsBlockFinalizedResponse, error) // QueryBlockRangeBabylonFinalized returns the last finalized block height // within a block range by querying Babylon chain QueryBlockRangeBabylonFinalized(context.Context, *QueryBlockRangeBabylonFinalizedRequest) (*QueryBlockRangeBabylonFinalizedResponse, error) @@ -145,6 +161,9 @@ type UnimplementedFinalityGadgetServer struct { func (UnimplementedFinalityGadgetServer) QueryIsBlockBabylonFinalized(context.Context, *QueryIsBlockBabylonFinalizedRequest) (*QueryIsBlockFinalizedResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryIsBlockBabylonFinalized not implemented") } +func (UnimplementedFinalityGadgetServer) QueryIsBlockBabylonFinalizedFromBabylon(context.Context, *QueryIsBlockBabylonFinalizedRequest) (*QueryIsBlockFinalizedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryIsBlockBabylonFinalizedFromBabylon not implemented") +} func (UnimplementedFinalityGadgetServer) QueryBlockRangeBabylonFinalized(context.Context, *QueryBlockRangeBabylonFinalizedRequest) (*QueryBlockRangeBabylonFinalizedResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryBlockRangeBabylonFinalized not implemented") } @@ -191,6 +210,24 @@ func _FinalityGadget_QueryIsBlockBabylonFinalized_Handler(srv interface{}, ctx c return interceptor(ctx, in, info, handler) } +func _FinalityGadget_QueryIsBlockBabylonFinalizedFromBabylon_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIsBlockBabylonFinalizedRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FinalityGadgetServer).QueryIsBlockBabylonFinalizedFromBabylon(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FinalityGadget_QueryIsBlockBabylonFinalizedFromBabylon_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FinalityGadgetServer).QueryIsBlockBabylonFinalizedFromBabylon(ctx, req.(*QueryIsBlockBabylonFinalizedRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _FinalityGadget_QueryBlockRangeBabylonFinalized_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryBlockRangeBabylonFinalizedRequest) if err := dec(in); err != nil { @@ -292,6 +329,10 @@ var FinalityGadget_ServiceDesc = grpc.ServiceDesc{ MethodName: "QueryIsBlockBabylonFinalized", Handler: _FinalityGadget_QueryIsBlockBabylonFinalized_Handler, }, + { + MethodName: "QueryIsBlockBabylonFinalizedFromBabylon", + Handler: _FinalityGadget_QueryIsBlockBabylonFinalizedFromBabylon_Handler, + }, { MethodName: "QueryBlockRangeBabylonFinalized", Handler: _FinalityGadget_QueryBlockRangeBabylonFinalized_Handler, From a7cd3e253a74f274ac3cc8b16afaf76612217906 Mon Sep 17 00:00:00 2001 From: parketh Date: Wed, 27 Nov 2024 19:45:27 +0000 Subject: [PATCH 2/5] feat: update cw client --- cwclient/cwclient.go | 82 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/cwclient/cwclient.go b/cwclient/cwclient.go index 04dc8bc..3f351eb 100644 --- a/cwclient/cwclient.go +++ b/cwclient/cwclient.go @@ -95,6 +95,44 @@ func (cwClient *CosmWasmClient) QueryIsEnabled() (bool, error) { return isEnabled, nil } +func (cwClient *CosmWasmClient) QueryIsBlockForked(blockHeight uint64) (bool, error) { + queryData, err := createIsForkedBlockQueryData(blockHeight) + if err != nil { + return false, err + } + + resp, err := cwClient.querySmartContractState(queryData) + if err != nil { + return false, err + } + + var isForked bool + if err := json.Unmarshal(resp.Data, &isForked); err != nil { + return false, err + } + + return isForked, nil +} + +func (cwClient *CosmWasmClient) QueryForkedBlocksInRange(startHeight, endHeight uint64) ([]blockRange, error) { + queryData, err := createForkedBlocksInRangeQueryData(startHeight, endHeight) + if err != nil { + return nil, err + } + + resp, err := cwClient.querySmartContractState(queryData) + if err != nil { + return nil, err + } + + var forkedBlocks []blockRange + if err := json.Unmarshal(resp.Data, &forkedBlocks); err != nil { + return nil, err + } + + return forkedBlocks, nil +} + ////////////////////////////// // INTERNAL ////////////////////////////// @@ -118,9 +156,16 @@ type contractConfigResponse struct { ActivatedHeight uint64 `json:"activated_height"` } type ContractQueryMsgs struct { - Config *contractConfig `json:"config,omitempty"` - BlockVoters *blockVotersQuery `json:"block_voters,omitempty"` - IsEnabled *isEnabledQuery `json:"is_enabled,omitempty"` + Config *contractConfig `json:"config,omitempty"` + BlockVoters *blockVotersQuery `json:"block_voters,omitempty"` + IsBlockForked *isBlockForkedQuery `json:"is_block_forked,omitempty"` + ForkedBlocksInRange *blockRange `json:"forked_blocks_in_range,omitempty"` + IsEnabled *isEnabledQuery `json:"is_enabled,omitempty"` +} + +type blockRange struct { + Start uint64 `json:"start"` + End uint64 `json:"end"` } type blockVotersQuery struct { @@ -128,6 +173,10 @@ type blockVotersQuery struct { Height uint64 `json:"height"` } +type isBlockForkedQuery struct { + Height uint64 `json:"height"` +} + type isEnabledQuery struct{} type contractConfig struct{} @@ -154,6 +203,33 @@ func createIsEnabledQueryData() ([]byte, error) { return data, nil } +func createIsForkedBlockQueryData(blockHeight uint64) ([]byte, error) { + queryData := ContractQueryMsgs{ + IsBlockForked: &isBlockForkedQuery{ + Height: blockHeight, + }, + } + data, err := json.Marshal(queryData) + if err != nil { + return nil, err + } + return data, nil +} + +func createForkedBlocksInRangeQueryData(startHeight, endHeight uint64) ([]byte, error) { + queryData := ContractQueryMsgs{ + ForkedBlocksInRange: &blockRange{ + Start: startHeight, + End: endHeight, + }, + } + data, err := json.Marshal(queryData) + if err != nil { + return nil, err + } + return data, nil +} + // querySmartContractState queries the smart contract state given the contract address and query data func (cwClient *CosmWasmClient) querySmartContractState( queryData []byte, From 50755b340c3f275426c528555fd2676168d1a59f Mon Sep 17 00:00:00 2001 From: parketh Date: Wed, 27 Nov 2024 19:57:17 +0000 Subject: [PATCH 3/5] feat: skip forked block --- finalitygadget/expected_clients.go | 1 + finalitygadget/finalitygadget.go | 9 +++++++++ testutil/mocks/expected_clients_mock.go | 15 +++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/finalitygadget/expected_clients.go b/finalitygadget/expected_clients.go index 0ac6919..b852a38 100644 --- a/finalitygadget/expected_clients.go +++ b/finalitygadget/expected_clients.go @@ -28,6 +28,7 @@ type IBabylonClient interface { type ICosmWasmClient interface { QueryListOfVotedFinalityProviders(queryParams *types.Block) ([]string, error) QueryConsumerId() (string, error) + QueryIsBlockForked(blockHeight uint64) (bool, error) QueryIsEnabled() (bool, error) } diff --git a/finalitygadget/finalitygadget.go b/finalitygadget/finalitygadget.go index a2f3713..0e62812 100644 --- a/finalitygadget/finalitygadget.go +++ b/finalitygadget/finalitygadget.go @@ -150,6 +150,15 @@ func (fg *FinalityGadget) QueryIsBlockBabylonFinalizedFromBabylon(block *types.B return true, nil } + // check if block is part of reorg whitelist, if so return true to unblock deriv pipeline + isForked, err := fg.cwClient.QueryIsBlockForked(block.BlockHeight) + if err != nil { + return false, err + } + if isForked { + return true, nil + } + // trim prefix 0x for the L2 block hash block.BlockHash = strings.TrimPrefix(block.BlockHash, "0x") diff --git a/testutil/mocks/expected_clients_mock.go b/testutil/mocks/expected_clients_mock.go index 9a77e33..c01f14a 100644 --- a/testutil/mocks/expected_clients_mock.go +++ b/testutil/mocks/expected_clients_mock.go @@ -243,6 +243,21 @@ func (mr *MockICosmWasmClientMockRecorder) QueryConsumerId() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryConsumerId", reflect.TypeOf((*MockICosmWasmClient)(nil).QueryConsumerId)) } +// QueryIsBlockForked mocks base method. +func (m *MockICosmWasmClient) QueryIsBlockForked(blockHeight uint64) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "QueryIsBlockForked", blockHeight) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// QueryIsBlockForked indicates an expected call of QueryIsBlockForked. +func (mr *MockICosmWasmClientMockRecorder) QueryIsBlockForked(blockHeight any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryIsBlockForked", reflect.TypeOf((*MockICosmWasmClient)(nil).QueryIsBlockForked), blockHeight) +} + // QueryIsEnabled mocks base method. func (m *MockICosmWasmClient) QueryIsEnabled() (bool, error) { m.ctrl.T.Helper() From da500271eeb3ad9f5c69ccc50502e64fa9f6d2fd Mon Sep 17 00:00:00 2001 From: parketh Date: Wed, 27 Nov 2024 20:14:52 +0000 Subject: [PATCH 4/5] test: add test case, fix tests --- finalitygadget/finalitygadget_test.go | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/finalitygadget/finalitygadget_test.go b/finalitygadget/finalitygadget_test.go index 7a296c9..2b62929 100644 --- a/finalitygadget/finalitygadget_test.go +++ b/finalitygadget/finalitygadget_test.go @@ -150,6 +150,7 @@ func TestQueryIsBlockBabylonFinalized(t *testing.T) { mockCwClient := mocks.NewMockICosmWasmClient(ctl) mockCwClient.EXPECT().QueryIsEnabled().Return(true, nil).Times(1) + mockCwClient.EXPECT().QueryIsBlockForked(tc.block.BlockHeight).Return(false, nil).Times(1) mockCwClient.EXPECT().QueryConsumerId().Return(consumerChainID, nil).Times(1) mockBTCClient := mocks.NewMockIBitcoinClient(ctl) mockBTCClient.EXPECT(). @@ -268,8 +269,9 @@ func TestQueryBlockRangeBabylonFinalized(t *testing.T) { defer ctl.Finish() mockDbHandler := mocks.NewMockIDatabaseHandler(ctl) + mockCwClient := mocks.NewMockICosmWasmClient(ctl) - // Setup mock DB responses + // Setup mock DB and cw contract responses if len(tc.queryBlocks) > 0 && tc.queryDB { mockDbHandler.EXPECT(). QueryEarliestFinalizedBlock(). @@ -282,7 +284,8 @@ func TestQueryBlockRangeBabylonFinalized(t *testing.T) { } mockFinalityGadget := &FinalityGadget{ - db: mockDbHandler, + db: mockDbHandler, + cwClient: mockCwClient, } res, err := mockFinalityGadget.QueryBlockRangeBabylonFinalized(tc.queryBlocks) @@ -668,6 +671,29 @@ func TestQueryIsBlockFinalizedByHashForNonExistentBlock(t *testing.T) { require.Equal(t, err, types.ErrBlockNotFound) } +func TestQueryIsBlockFinalizedFromBabylonForked(t *testing.T) { + ctl := gomock.NewController(t) + + // mock CwClient + mockCwClient := mocks.NewMockICosmWasmClient(ctl) + mockCwClient.EXPECT().QueryIsEnabled().Return(true, nil).Times(1) + mockCwClient.EXPECT().QueryIsBlockForked(uint64(1)).Return(true, nil).Times(1) + + mockTestFinalityGadget := &FinalityGadget{ + cwClient: mockCwClient, + bbnClient: nil, + btcClient: nil, + } + + res, err := mockTestFinalityGadget.QueryIsBlockBabylonFinalizedFromBabylon(&types.Block{ + BlockHeight: 1, + BlockHash: "0x123", + BlockTimestamp: 1000, + }) + require.NoError(t, err) + require.True(t, res) +} + func TestQueryLatestFinalizedBlock(t *testing.T) { // define blocks first := &types.Block{ From 53e1276dc3a61e04ea9dfeea0e6ec0e6859f0728 Mon Sep 17 00:00:00 2001 From: parketh Date: Thu, 28 Nov 2024 14:02:40 +0000 Subject: [PATCH 5/5] nit: add comment to remove unused fn --- cwclient/cwclient.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cwclient/cwclient.go b/cwclient/cwclient.go index 3f351eb..ed61bca 100644 --- a/cwclient/cwclient.go +++ b/cwclient/cwclient.go @@ -114,6 +114,7 @@ func (cwClient *CosmWasmClient) QueryIsBlockForked(blockHeight uint64) (bool, er return isForked, nil } +// TODO: for temp testing only, to remove if not used func (cwClient *CosmWasmClient) QueryForkedBlocksInRange(startHeight, endHeight uint64) ([]blockRange, error) { queryData, err := createForkedBlocksInRangeQueryData(startHeight, endHeight) if err != nil {