From c272eabfcbf7a1534f1896214bb5ae5f0c371475 Mon Sep 17 00:00:00 2001 From: Hubert Bugaj Date: Wed, 6 Nov 2024 15:58:13 +0700 Subject: [PATCH] no more acme, more fields --- cmd/fireacme/main.go | 27 ----- cmd/firefil/main.go | 10 +- devel/stdin/start.sh | 3 +- pb/last_generate.txt | 4 +- pb/sf/acme/type/v1/type.go | 33 ------ pb/sf/acme/type/v1/type.pb.go | 171 ------------------------------ pb/sf/filecoin/type/v1/type.go | 30 +++--- pb/sf/filecoin/type/v1/type.pb.go | 35 +++--- 8 files changed, 42 insertions(+), 271 deletions(-) delete mode 100644 cmd/fireacme/main.go delete mode 100644 pb/sf/acme/type/v1/type.go delete mode 100644 pb/sf/acme/type/v1/type.pb.go diff --git a/cmd/fireacme/main.go b/cmd/fireacme/main.go deleted file mode 100644 index 0bb7fde..0000000 --- a/cmd/fireacme/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - pbacme "github.com/streamingfast/firehose-acme/pb/sf/acme/type/v1" - firecore "github.com/streamingfast/firehose-core" - fhCmd "github.com/streamingfast/firehose-core/cmd" -) - -func main() { - fhCmd.Main(&firecore.Chain[*pbacme.Tipset]{ - ShortName: "acme", - LongName: "Acme", - ExecutableName: "forest", - FullyQualifiedModule: "github.com/streamingfast/firehose-acme", - Version: version, - - FirstStreamableBlock: 1, - - BlockFactory: func() firecore.Block { return new(pbacme.Tipset) }, - ConsoleReaderFactory: firecore.NewConsoleReader, - - Tools: &firecore.ToolsConfig[*pbacme.Tipset]{}, - }) -} - -// Version value, injected via go build `ldflags` at build time, **must** not be removed or inlined -var version = "dev" diff --git a/cmd/firefil/main.go b/cmd/firefil/main.go index ee1a48d..71bbc7b 100644 --- a/cmd/firefil/main.go +++ b/cmd/firefil/main.go @@ -7,19 +7,19 @@ import ( ) func main() { - fhCmd.Main(&firecore.Chain[*pbfilecoin.Block]{ + fhCmd.Main(&firecore.Chain[*pbfilecoin.Tipset]{ ShortName: "filecoin", LongName: "Filecoin", - ExecutableName: "dummy-blockchain", - FullyQualifiedModule: "github.com/chainsafe/firehose-filecoin", + ExecutableName: "forest", + FullyQualifiedModule: "github.com/chainsafe/firehose-filecoin", Version: version, FirstStreamableBlock: 1, - BlockFactory: func() firecore.Block { return new(pbfilecoin.Block) }, + BlockFactory: func() firecore.Block { return new(pbfilecoin.Tipset) }, ConsoleReaderFactory: firecore.NewConsoleReader, - Tools: &firecore.ToolsConfig[*pbfilecoin.Block]{}, + Tools: &firecore.ToolsConfig[*pbfilecoin.Tipset]{}, }) } diff --git a/devel/stdin/start.sh b/devel/stdin/start.sh index 26a226e..614ec17 100755 --- a/devel/stdin/start.sh +++ b/devel/stdin/start.sh @@ -3,7 +3,7 @@ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" clean= -fireacme="$ROOT/../fireacme" +firefil="$ROOT/../firefil" main() { pushd "$ROOT" &> /dev/null @@ -33,7 +33,6 @@ main() { # usage_error "The 'dummy-blockchain' executable must be found within your PATH, install it from source of 'https://github.com/streamingfast/dummy-blockchain'" # fi - # exec go run github.com/streamingfast/dummy-blockchain@v1.2.0 start --tracer=firehose --block-rate=60 --store-dir "$chain_data" | $fireacme -c $(basename $ROOT).yaml start "$@" forest --chain calibnet --encrypt-keystore=false | $firefil -c $(basename $ROOT).yaml start "$@" } diff --git a/pb/last_generate.txt b/pb/last_generate.txt index 1d34874..f88cc5d 100644 --- a/pb/last_generate.txt +++ b/pb/last_generate.txt @@ -1,2 +1,2 @@ -generate.sh - Wed Nov 6 15:20:13 +07 2024 - rumcajs -streamingfast/firehose-filecoin/proto revision: edddbaf +generate.sh - Wed Nov 6 15:46:22 +07 2024 - rumcajs +streamingfast/firehose-filecoin/proto revision: 3910e98 diff --git a/pb/sf/acme/type/v1/type.go b/pb/sf/acme/type/v1/type.go deleted file mode 100644 index 89e3566..0000000 --- a/pb/sf/acme/type/v1/type.go +++ /dev/null @@ -1,33 +0,0 @@ -package pbacme - -import ( - "time" - - firecore "github.com/streamingfast/firehose-core" -) - -var _ firecore.Block = (*Tipset)(nil) - -func (b *Tipset) GetFirehoseBlockID() string { - return "blah" -} - -func (b *Tipset) GetFirehoseBlockNumber() uint64 { - return b.Height -} - -func (b *Tipset) GetFirehoseBlockParentID() string { - return "" -} - -func (b *Tipset) GetFirehoseBlockParentNumber() uint64 { - return *&b.Height - 1 -} - -func (b *Tipset) GetFirehoseBlockTime() time.Time { - return time.Unix(0, int64(b.Timestamp)).UTC() -} - -func (b *Tipset) GetFirehoseBlockLIBNum() uint64 { - return b.Height -} diff --git a/pb/sf/acme/type/v1/type.pb.go b/pb/sf/acme/type/v1/type.pb.go deleted file mode 100644 index bffc755..0000000 --- a/pb/sf/acme/type/v1/type.pb.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v5.28.3 -// source: sf/acme/type/v1/type.proto - -package pbacme - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type Tipset struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - BlockCount uint64 `protobuf:"varint,2,opt,name=block_count,json=blockCount,proto3" json:"block_count,omitempty"` - Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (x *Tipset) Reset() { - *x = Tipset{} - if protoimpl.UnsafeEnabled { - mi := &file_sf_acme_type_v1_type_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Tipset) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Tipset) ProtoMessage() {} - -func (x *Tipset) ProtoReflect() protoreflect.Message { - mi := &file_sf_acme_type_v1_type_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Tipset.ProtoReflect.Descriptor instead. -func (*Tipset) Descriptor() ([]byte, []int) { - return file_sf_acme_type_v1_type_proto_rawDescGZIP(), []int{0} -} - -func (x *Tipset) GetHeight() uint64 { - if x != nil { - return x.Height - } - return 0 -} - -func (x *Tipset) GetBlockCount() uint64 { - if x != nil { - return x.BlockCount - } - return 0 -} - -func (x *Tipset) GetTimestamp() uint64 { - if x != nil { - return x.Timestamp - } - return 0 -} - -var File_sf_acme_type_v1_type_proto protoreflect.FileDescriptor - -var file_sf_acme_type_v1_type_proto_rawDesc = []byte{ - 0x0a, 0x1a, 0x73, 0x66, 0x2f, 0x61, 0x63, 0x6d, 0x65, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, - 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x73, 0x66, - 0x2e, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x5f, 0x0a, - 0x06, 0x54, 0x69, 0x70, 0x73, 0x65, 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, 0x12, - 0x1f, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x43, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x42, - 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x66, 0x61, 0x73, 0x74, 0x2f, 0x66, 0x69, 0x72, 0x65, 0x68, - 0x6f, 0x73, 0x65, 0x2d, 0x61, 0x63, 0x6d, 0x65, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x66, 0x2f, 0x61, - 0x63, 0x6d, 0x65, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x62, 0x61, 0x63, - 0x6d, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_sf_acme_type_v1_type_proto_rawDescOnce sync.Once - file_sf_acme_type_v1_type_proto_rawDescData = file_sf_acme_type_v1_type_proto_rawDesc -) - -func file_sf_acme_type_v1_type_proto_rawDescGZIP() []byte { - file_sf_acme_type_v1_type_proto_rawDescOnce.Do(func() { - file_sf_acme_type_v1_type_proto_rawDescData = protoimpl.X.CompressGZIP(file_sf_acme_type_v1_type_proto_rawDescData) - }) - return file_sf_acme_type_v1_type_proto_rawDescData -} - -var file_sf_acme_type_v1_type_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_sf_acme_type_v1_type_proto_goTypes = []interface{}{ - (*Tipset)(nil), // 0: sf.acme.type.v1.Tipset -} -var file_sf_acme_type_v1_type_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_sf_acme_type_v1_type_proto_init() } -func file_sf_acme_type_v1_type_proto_init() { - if File_sf_acme_type_v1_type_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_sf_acme_type_v1_type_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Tipset); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_sf_acme_type_v1_type_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_sf_acme_type_v1_type_proto_goTypes, - DependencyIndexes: file_sf_acme_type_v1_type_proto_depIdxs, - MessageInfos: file_sf_acme_type_v1_type_proto_msgTypes, - }.Build() - File_sf_acme_type_v1_type_proto = out.File - file_sf_acme_type_v1_type_proto_rawDesc = nil - file_sf_acme_type_v1_type_proto_goTypes = nil - file_sf_acme_type_v1_type_proto_depIdxs = nil -} diff --git a/pb/sf/filecoin/type/v1/type.go b/pb/sf/filecoin/type/v1/type.go index 02e458a..efac389 100644 --- a/pb/sf/filecoin/type/v1/type.go +++ b/pb/sf/filecoin/type/v1/type.go @@ -6,36 +6,36 @@ import ( firecore "github.com/streamingfast/firehose-core" ) -var _ firecore.Block = (*Block)(nil) +var _ firecore.Block = (*Tipset)(nil) -func (b *Block) GetFirehoseBlockID() string { - return b.Header.Hash +func (b *Tipset) GetFirehoseBlockID() string { + return b.TipsetKey } -func (b *Block) GetFirehoseBlockNumber() uint64 { - return b.Header.Height +func (b *Tipset) GetFirehoseBlockNumber() uint64 { + return b.Height } -func (b *Block) GetFirehoseBlockParentID() string { - if b.Header.PreviousHash == nil { +func (b *Tipset) GetFirehoseBlockParentID() string { + if b.ParentTipsetKey == nil { return "" } - return *b.Header.PreviousHash + return *b.ParentTipsetKey } -func (b *Block) GetFirehoseBlockParentNumber() uint64 { - if b.Header.PreviousNum == nil { +func (b *Tipset) GetFirehoseBlockParentNumber() uint64 { + if b.Height == 0 { return 0 } - return *b.Header.PreviousNum + return b.Height - 1 } -func (b *Block) GetFirehoseBlockTime() time.Time { - return time.Unix(0, int64(b.Header.Timestamp)).UTC() +func (b *Tipset) GetFirehoseBlockTime() time.Time { + return time.Unix(0, int64(b.Timestamp)).UTC() } -func (b *Block) GetFirehoseBlockLIBNum() uint64 { - return b.Header.FinalNum +func (b *Tipset) GetFirehoseBlockLIBNum() uint64 { + return 1; } diff --git a/pb/sf/filecoin/type/v1/type.pb.go b/pb/sf/filecoin/type/v1/type.pb.go index 720809b..e0301fa 100644 --- a/pb/sf/filecoin/type/v1/type.pb.go +++ b/pb/sf/filecoin/type/v1/type.pb.go @@ -30,11 +30,11 @@ type Tipset struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - BlockCount uint64 `protobuf:"varint,2,opt,name=block_count,json=blockCount,proto3" json:"block_count,omitempty"` - Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - TipsetKey string `protobuf:"bytes,4,opt,name=tipset_key,json=tipsetKey,proto3" json:"tipset_key,omitempty"` - ParentTipsetKey string `protobuf:"bytes,5,opt,name=parent_tipset_key,json=parentTipsetKey,proto3" json:"parent_tipset_key,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + BlockCount uint64 `protobuf:"varint,2,opt,name=block_count,json=blockCount,proto3" json:"block_count,omitempty"` + Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + TipsetKey string `protobuf:"bytes,4,opt,name=tipset_key,json=tipsetKey,proto3" json:"tipset_key,omitempty"` + ParentTipsetKey *string `protobuf:"bytes,5,opt,name=parent_tipset_key,json=parentTipsetKey,proto3,oneof" json:"parent_tipset_key,omitempty"` } func (x *Tipset) Reset() { @@ -98,8 +98,8 @@ func (x *Tipset) GetTipsetKey() string { } func (x *Tipset) GetParentTipsetKey() string { - if x != nil { - return x.ParentTipsetKey + if x != nil && x.ParentTipsetKey != nil { + return *x.ParentTipsetKey } return "" } @@ -110,7 +110,7 @@ var file_sf_filecoin_type_v1_type_proto_rawDesc = []byte{ 0x0a, 0x1e, 0x73, 0x66, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x73, 0x66, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x74, 0x79, - 0x70, 0x65, 0x2e, 0x76, 0x31, 0x22, 0xaa, 0x01, 0x0a, 0x06, 0x54, 0x69, 0x70, 0x73, 0x65, 0x74, + 0x70, 0x65, 0x2e, 0x76, 0x31, 0x22, 0xc5, 0x01, 0x0a, 0x06, 0x54, 0x69, 0x70, 0x73, 0x65, 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, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x62, @@ -118,15 +118,17 @@ var file_sf_filecoin_type_v1_type_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x69, 0x70, 0x73, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x69, 0x70, - 0x73, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x11, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, + 0x73, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x11, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x70, 0x73, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x70, 0x73, 0x65, 0x74, 0x4b, - 0x65, 0x79, 0x42, 0x4a, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x73, 0x61, 0x66, 0x65, 0x2f, 0x66, 0x69, 0x72, 0x65, 0x68, - 0x6f, 0x73, 0x65, 0x2d, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2f, 0x70, 0x62, 0x2f, - 0x73, 0x66, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x2f, 0x76, 0x31, 0x3b, 0x70, 0x62, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x09, 0x48, 0x00, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x70, 0x73, 0x65, + 0x74, 0x4b, 0x65, 0x79, 0x88, 0x01, 0x01, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x70, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x70, 0x73, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x42, 0x4a, 0x5a, + 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, + 0x6e, 0x73, 0x61, 0x66, 0x65, 0x2f, 0x66, 0x69, 0x72, 0x65, 0x68, 0x6f, 0x73, 0x65, 0x2d, 0x66, + 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2f, 0x70, 0x62, 0x2f, 0x73, 0x66, 0x2f, 0x66, 0x69, + 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x70, + 0x62, 0x66, 0x69, 0x6c, 0x65, 0x63, 0x6f, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -172,6 +174,7 @@ func file_sf_filecoin_type_v1_type_proto_init() { } } } + file_sf_filecoin_type_v1_type_proto_msgTypes[0].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{