From b8c3e6850e9bfcafe5e67936cf87e1c0ac0b1aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Sch=C3=B6ll?= Date: Thu, 9 Nov 2023 16:24:36 +0100 Subject: [PATCH] update firehose-core to v0.2.1 (#99) * bump firehose-core to v0.2.1 * implement new firecore.Block methods * cleanup * add test --- codec/consolereader_test.go | 2 +- go.mod | 7 ++-- go.sum | 14 ++++---- types/pb/sf/antelope/type/v1/codec.go | 47 +++++++++------------------ 4 files changed, 28 insertions(+), 42 deletions(-) diff --git a/codec/consolereader_test.go b/codec/consolereader_test.go index 16098df..3008206 100644 --- a/codec/consolereader_test.go +++ b/codec/consolereader_test.go @@ -232,7 +232,7 @@ func testReaderConsoleReader(helperFunc func(), lines chan string, closer func() l := &ConsoleReader{ lines: lines, - blockEncoder: firecore.NewGenericBlockEncoder(1), + blockEncoder: firecore.NewBlockEncoder(), close: closer, ctx: &parseCtx{ logger: zlogTest, diff --git a/go.mod b/go.mod index eb46e95..b9f00cf 100644 --- a/go.mod +++ b/go.mod @@ -14,12 +14,12 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.15.0 - github.com/streamingfast/bstream v0.0.2-0.20230829131224-b9272048dc6a + github.com/streamingfast/bstream v0.0.2-0.20231108161055-1092e9150ee8 github.com/streamingfast/cli v0.0.4-0.20230825151644-8cc84512cd80 github.com/streamingfast/dbin v0.9.1-0.20220513054835-1abebbb944ad github.com/streamingfast/dmetrics v0.0.0-20230919161904-206fa8ebd545 github.com/streamingfast/dstore v0.1.1-0.20230620124109-3924b3b36c77 - github.com/streamingfast/firehose-core v0.1.12 + github.com/streamingfast/firehose-core v0.2.1 github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0 github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 github.com/streamingfast/node-manager v0.0.2-0.20230406142433-692298a8b8d2 @@ -91,6 +91,7 @@ require ( github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect @@ -181,7 +182,7 @@ require ( github.com/streamingfast/dtracing v0.0.0-20220305214756-b5c0e8699839 // indirect github.com/streamingfast/firehose v0.1.1-0.20230731171526-3428fc0ff8d9 // indirect github.com/streamingfast/index-builder v0.0.0-20221031203737-fa2e70f09dc2 // indirect - github.com/streamingfast/merger v0.0.3-0.20230413191947-fe3ce68cb9f8 // indirect + github.com/streamingfast/merger v0.0.3-0.20231027161314-209c2ddd8d96 // indirect github.com/streamingfast/opaque v0.0.0-20210811180740-0c01d37ea308 // indirect github.com/streamingfast/relayer v0.0.2-0.20220909122435-e67fbc964fd9 // indirect github.com/streamingfast/sf-tracing v0.0.0-20230616174903-cd2ade641ca9 // indirect diff --git a/go.sum b/go.sum index b31ea8e..5b0a027 100644 --- a/go.sum +++ b/go.sum @@ -291,6 +291,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d h1:zqfo2jECgX5eYQseB/X+uV4Y5ocGOG/vG/LTztUCyPA= +github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d/go.mod h1:6daplAwHHGbUGib4990V3Il26O0OC4aRyvewaaAihaA= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -766,8 +768,8 @@ github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag github.com/streamingfast/atm v0.0.0-20220131151839-18c87005e680 h1:fGJnUx0shX9Y312QOlz+/+yLquihXRhNqctJ26jtZZM= github.com/streamingfast/atm v0.0.0-20220131151839-18c87005e680/go.mod h1:iISPGAstbUsPgyC3auLLi7PYUTi9lHv5z0COam0OPOY= github.com/streamingfast/bstream v0.0.2-0.20221017131819-2a7e38be1047/go.mod h1:Njkx972HcZiz0djWBylxqO/eq686eDGr+egQ1lePj3Q= -github.com/streamingfast/bstream v0.0.2-0.20230829131224-b9272048dc6a h1:NeCO5JLz38HRK1uaV1Emo9u5gUSRtmtZZGNK8BKyLIE= -github.com/streamingfast/bstream v0.0.2-0.20230829131224-b9272048dc6a/go.mod h1:Njkx972HcZiz0djWBylxqO/eq686eDGr+egQ1lePj3Q= +github.com/streamingfast/bstream v0.0.2-0.20231108161055-1092e9150ee8 h1:97vTsS3HZ5Q/ADapuQGbOWlOl4VGlUmG6TDtk8vmL/E= +github.com/streamingfast/bstream v0.0.2-0.20231108161055-1092e9150ee8/go.mod h1:Njkx972HcZiz0djWBylxqO/eq686eDGr+egQ1lePj3Q= github.com/streamingfast/cli v0.0.4-0.20230825151644-8cc84512cd80 h1:UxJUTcEVkdZy8N77E3exz0iNlgQuxl4m220GPvzdZ2s= github.com/streamingfast/cli v0.0.4-0.20230825151644-8cc84512cd80/go.mod h1:QxjVH73Lkqk+mP8bndvhMuQDUINfkgsYhdCH/5TJFKI= github.com/streamingfast/dauth v0.0.0-20210812020920-1c83ba29add1/go.mod h1:FIYpVqt+ICVuNBoOH3ZIicIctpVoCq3393+RpfXsPEM= @@ -800,8 +802,8 @@ github.com/streamingfast/dtracing v0.0.0-20220305214756-b5c0e8699839/go.mod h1:h github.com/streamingfast/firehose v0.1.1-0.20221017171248-8fd3adbe7b4d/go.mod h1:weGz9xDNJMBNmn03XiJZ/b5Ngw8UAUoLirarqG7OwQY= github.com/streamingfast/firehose v0.1.1-0.20230731171526-3428fc0ff8d9 h1:SybLEPFkJk8EINJGDlijSWxEZGNXDul4zqlDpttQUCI= github.com/streamingfast/firehose v0.1.1-0.20230731171526-3428fc0ff8d9/go.mod h1:lGC1T6mpAAApjBQNF5COSXb3SbrYRI3dBR1f6/PZE54= -github.com/streamingfast/firehose-core v0.1.12 h1:eNmAfuyKkJXd1rAqpUxNPPHBa8gdU3CJ6nORA1nab+Q= -github.com/streamingfast/firehose-core v0.1.12/go.mod h1:RUwLigWHqoBipsf9SwQczRAnuGFM/MDHcbrSWMZ0f2k= +github.com/streamingfast/firehose-core v0.2.1 h1:yErirlPp1gkgj9GiO+TfBIsr3UDCM6PnnwbJbgBqr4A= +github.com/streamingfast/firehose-core v0.2.1/go.mod h1:5Bf1vpTAhxI93isYYc7zcGrW1QzAZxioIll6siC6FTw= github.com/streamingfast/index-builder v0.0.0-20221031203737-fa2e70f09dc2 h1:dgYLhP3STiPi30fISAijFPEB11D4r1fQFc8D3cpgV5s= github.com/streamingfast/index-builder v0.0.0-20221031203737-fa2e70f09dc2/go.mod h1:OYv1UX/kRsV9aP4SEwa9zpt34qGzdtJzOvdGn+n56as= github.com/streamingfast/jsonpb v0.0.0-20210811021341-3670f0aa02d0 h1:g8eEYbFSykyzIyuxNMmHEUGGUvJE0ivmqZagLDK42gw= @@ -813,8 +815,8 @@ github.com/streamingfast/logging v0.0.0-20220304183711-ddba33d79e27/go.mod h1:4G github.com/streamingfast/logging v0.0.0-20220304214715-bc750a74b424/go.mod h1:VlduQ80JcGJSargkRU4Sg9Xo63wZD/l8A5NC/Uo1/uU= github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 h1:RN5mrigyirb8anBEtdjtHFIufXdacyTi6i4KBfeNXeo= github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091/go.mod h1:VlduQ80JcGJSargkRU4Sg9Xo63wZD/l8A5NC/Uo1/uU= -github.com/streamingfast/merger v0.0.3-0.20230413191947-fe3ce68cb9f8 h1:riOEu4aTwjy7Gjq8safA8kYUs+jVKi/gZ0+k7S/w/u8= -github.com/streamingfast/merger v0.0.3-0.20230413191947-fe3ce68cb9f8/go.mod h1:WGMs+zwpPQNfzRnOqnyNdQfyGSG4lXYWQacicAGiP4s= +github.com/streamingfast/merger v0.0.3-0.20231027161314-209c2ddd8d96 h1:aq5hUjo+Y+3OUH2z1egyJ9fSepRvOzxgR+TYICdSEgE= +github.com/streamingfast/merger v0.0.3-0.20231027161314-209c2ddd8d96/go.mod h1:WGMs+zwpPQNfzRnOqnyNdQfyGSG4lXYWQacicAGiP4s= github.com/streamingfast/node-manager v0.0.2-0.20230406142433-692298a8b8d2 h1:6Jdu6LBwaW38n2jjInFk1fM460cq+5paEAHGPPRWWN0= github.com/streamingfast/node-manager v0.0.2-0.20230406142433-692298a8b8d2/go.mod h1:R5WwJuyNueq0QXKAFinTGU8zaON0hWJBFHX6KA9WZqk= github.com/streamingfast/opaque v0.0.0-20210811180740-0c01d37ea308 h1:xlWSfi1BoPfsHtPb0VEHGUcAdBF208LUiFCwfaVPfLA= diff --git a/types/pb/sf/antelope/type/v1/codec.go b/types/pb/sf/antelope/type/v1/codec.go index d760441..82ed5d6 100644 --- a/types/pb/sf/antelope/type/v1/codec.go +++ b/types/pb/sf/antelope/type/v1/codec.go @@ -37,6 +37,13 @@ func (b *Block) PreviousID() string { return b.Header.Previous } +func (b *Block) PreviousNumber() uint64 { + if b.PreviousID() == "" { + return 0 + } + return uint64(b.Number) - 1 +} + func (b *Block) Time() time.Time { return b.Header.Timestamp.AsTime() } @@ -55,33 +62,22 @@ func (b *Block) GetFirehoseBlockParentID() string { return b.PreviousID() } +func (b *Block) GetFirehoseBlockParentNumber() uint64 { + return b.PreviousNumber() +} + func (b *Block) GetFirehoseBlockTime() time.Time { return b.Time() } +func (b *Block) GetFirehoseBlockVersion() int32 { + return int32(b.Version) +} + func (b *Block) GetFirehoseBlockLIBNum() uint64 { return b.LIBNum() } -// todo legacy code should be replaced with timestamppb -//func (b *Block) Time() (time.Time, error) { -// timestamp, err := ptypes.Timestamp(b.Header.Timestamp) -// if err != nil { -// return time.Time{}, fmt.Errorf("unable to turn google proto Timestamp into time.Time: %s", err) -// } -// -// return timestamp, nil -//} -// -//func (b *Block) MustTime() time.Time { -// timestamp, err := b.Time() -// if err != nil { -// panic(err) -// } -// -// return timestamp -//} - func (b *Block) LIBNum() uint64 { return uint64(b.DposIrreversibleBlocknum) } @@ -175,19 +171,6 @@ func (b *Block) MigrateV0ToV1() { } } -func (b *Block) MigrateV1ToV2() { - if b.Version != 1 { - return - } - b.Version = 2 - - if b.FilteringApplied { - // prendre filtering_include_filter_expr -> mettre dans un pbcodec.FilteringFilters{} - // hasher ceux qui sont trop gros? tous? pour tous les blocks où blockNum%100 != 0 - // on append ce FilteredApplied à - } -} - type FilteringActionMatcher interface { Matched(actionIndex uint32) bool }