From edddbaf2062e6ad883478a7821be814d20e58940 Mon Sep 17 00:00:00 2001 From: Hubert Bugaj Date: Wed, 6 Nov 2024 14:59:45 +0700 Subject: [PATCH] copy over current changes --- cmd/fireacme/main.go | 27 +++++ devel/standard/standard.yaml | 8 +- devel/stdin/start.sh | 7 +- devel/stdin/stdin.yaml | 2 +- pb/sf/acme/type/v1/type.go | 33 ++++++ pb/sf/acme/type/v1/type.pb.go | 171 +++++++++++++++++++++++++++++++ proto/sf/acme/type/v1/type.proto | 11 ++ 7 files changed, 250 insertions(+), 9 deletions(-) create mode 100644 cmd/fireacme/main.go create mode 100644 pb/sf/acme/type/v1/type.go create mode 100644 pb/sf/acme/type/v1/type.pb.go create mode 100644 proto/sf/acme/type/v1/type.proto diff --git a/cmd/fireacme/main.go b/cmd/fireacme/main.go new file mode 100644 index 0000000..0bb7fde --- /dev/null +++ b/cmd/fireacme/main.go @@ -0,0 +1,27 @@ +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/devel/standard/standard.yaml b/devel/standard/standard.yaml index 0ff9abd..bc3ba2d 100644 --- a/devel/standard/standard.yaml +++ b/devel/standard/standard.yaml @@ -11,12 +11,10 @@ start: # Specifies the path to the binary, we assume you did # `go install github.com/streamingfast/dummy-blockchain@latest` (and that you have value # of `go env GOPATH` in your environment). - reader-node-path: "dummy-blockchain" + reader-node-path: "forest" reader-node-data-dir: "{data-dir}/reader-node" # Flags that will be added to the dummy chain process command reader-node-arguments: - start - --tracer=firehose - --store-dir={node-data-dir} - --block-rate=60 + --chain calibnet + --encrypt-keystore false diff --git a/devel/stdin/start.sh b/devel/stdin/start.sh index 282d606..ffe72a6 100755 --- a/devel/stdin/start.sh +++ b/devel/stdin/start.sh @@ -3,7 +3,7 @@ ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" clean= -firefil="$ROOT/../firefil" +fireacme="$ROOT/../fireacme" main() { pushd "$ROOT" &> /dev/null @@ -33,7 +33,8 @@ 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" | $firefil -c $(basename $ROOT).yaml start "$@" + # 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 | $fireacme -c $(basename $ROOT).yaml start "$@" } usage_error() { @@ -55,4 +56,4 @@ usage() { echo " -c Clean actual data directory first" } -main "$@" \ No newline at end of file +main "$@" diff --git a/devel/stdin/stdin.yaml b/devel/stdin/stdin.yaml index dea4ac6..13fc38a 100644 --- a/devel/stdin/stdin.yaml +++ b/devel/stdin/stdin.yaml @@ -1,6 +1,6 @@ # Invoked using: # -# dummy-blockchain start --tracer=firehose --store-dir=./devel/stdin/firehose-data/reader-node --block-rate=60 | ./devel/stdin/start.sh +# forest --chain calibnet --encrypt-keystore=false | ./devel/stdin/start.sh # # The `./devel/stdin/start.sh` does the above invocation and pipes the output to the `stdin` process. start: diff --git a/pb/sf/acme/type/v1/type.go b/pb/sf/acme/type/v1/type.go new file mode 100644 index 0000000..89e3566 --- /dev/null +++ b/pb/sf/acme/type/v1/type.go @@ -0,0 +1,33 @@ +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 new file mode 100644 index 0000000..bffc755 --- /dev/null +++ b/pb/sf/acme/type/v1/type.pb.go @@ -0,0 +1,171 @@ +// 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/proto/sf/acme/type/v1/type.proto b/proto/sf/acme/type/v1/type.proto new file mode 100644 index 0000000..aded26c --- /dev/null +++ b/proto/sf/acme/type/v1/type.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package sf.acme.type.v1; + +option go_package = "github.com/streamingfast/firehose-acme/pb/sf/acme/type/v1;pbacme"; + +message Tipset { + uint64 height = 1; + uint64 block_count = 2; + uint64 timestamp = 3; +}