Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.0 firecore binary, new block format (based on anypb) #19

Merged
merged 67 commits into from
Dec 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
546709a
wip
billettc Nov 15, 2023
4bdf188
wip
billettc Nov 15, 2023
17d6e82
WIP waiting for bstream little refactor ;-)
billettc Nov 15, 2023
6faf4ef
added firehose
billettc Nov 16, 2023
0f3c601
bye bye bstream.Block!
billettc Nov 16, 2023
189450e
fix print and download tools
billettc Nov 16, 2023
9b48bf1
all test pass!
billettc Nov 17, 2023
7a5d1dc
all test pass!
billettc Nov 20, 2023
c47d937
bump bstream with new pbbstream.Block
billettc Nov 20, 2023
3f8b86d
Added rpc poller
jubeless Nov 21, 2023
1f22525
rename rpcpoller pckg to blkpoller
jubeless Nov 21, 2023
e146a25
rename blkpoller to blockpoller
jubeless Nov 21, 2023
2dda977
poller BlockFireFunc is now for internal use and tests
billettc Nov 21, 2023
297b1ef
clean up poller and bstream
jubeless Nov 22, 2023
c92a777
Added cursor, state test
jubeless Nov 22, 2023
991d08a
clean up formatting
jubeless Nov 22, 2023
b80045e
clean up code and fix bug
jubeless Nov 22, 2023
53446f5
fix block handler interface
jubeless Nov 22, 2023
bfd6e22
fix state test
jubeless Nov 22, 2023
e2de095
fix block handler
jubeless Nov 22, 2023
f7debde
Move block printing logic to the Block interface
billettc Nov 23, 2023
3f07b24
bump bstream
billettc Nov 23, 2023
5bd6074
clean up naming
jubeless Nov 23, 2023
644e8a8
Refactor variable names in blockpoller
billettc Nov 23, 2023
80ea795
Add error handling and logging in saveState function
billettc Nov 23, 2023
c9396c2
Refactor print statement in blockpoller
billettc Nov 23, 2023
81e1e91
Remove protobuf usage in consolereader
billettc Nov 23, 2023
19ad29a
fix test
billettc Nov 23, 2023
679c342
github workflows
billettc Nov 23, 2023
b53f673
github workflows switch branch
billettc Nov 23, 2023
f3ec523
github workflows add login
billettc Nov 23, 2023
c9041e5
github workflows fix image name
billettc Nov 23, 2023
2e3f5e2
github workflows fix permission
billettc Nov 23, 2023
e9da1f7
added grpc_health_probe to images
billettc Nov 24, 2023
b2cf970
Move the responsibility of waiting between block fetch to the block f…
billettc Nov 27, 2023
31d5902
Update block printing functions to support chain context
billettc Nov 27, 2023
bc92305
fix logger naming
jubeless Nov 27, 2023
f5e9f30
Implement dynamic protobuf parsing in block printing
billettc Nov 28, 2023
7aa2064
added the ability to ignore the cursor on the block poller
jubeless Nov 30, 2023
1d6f3c3
rename block poller option
jubeless Nov 30, 2023
2e7b9f9
fix substreams block-type
jubeless Nov 30, 2023
57af3fd
Clean up print block
jubeless Dec 4, 2023
818d341
Cleaned up print block
jubeless Dec 5, 2023
5a004d9
bump bstream
jubeless Dec 5, 2023
50415ed
fix firehose server on old and new blocks
sduchesneau Dec 5, 2023
b22a574
clean up printing
jubeless Dec 5, 2023
b639760
remove streamfactory 'decodeblock' option
sduchesneau Dec 5, 2023
f58cd08
refactor of tools and apps package
billettc Dec 5, 2023
efd96c3
wip refactor of tools and apps package
billettc Dec 5, 2023
e851074
finish refactor of tools and apps package
billettc Dec 5, 2023
bf490db
Added proto registry support
jubeless Dec 5, 2023
126fe12
Clean up marshaller added hex support
jubeless Dec 5, 2023
e177b36
clean up func
jubeless Dec 5, 2023
1535160
cleaned up encoder
jubeless Dec 5, 2023
bd5ad8f
move common flags to main
billettc Dec 5, 2023
5a810db
merge firehose commits after Nov9
sduchesneau Dec 6, 2023
6f6433e
bump substreams, bstream to latest
sduchesneau Dec 6, 2023
d2c719a
fix index builder
sduchesneau Dec 6, 2023
2d21be8
bump bstreams to prevent heavy blocks printed in logs
sduchesneau Dec 6, 2023
0ae01d4
add firehose-bitcoin in well known proto types
jubeless Dec 6, 2023
b5b7a44
bump substreams: remove the need to specify block type
sduchesneau Dec 6, 2023
6665daf
bump substreams: fix blockType getter on tier1
sduchesneau Dec 6, 2023
b6771e0
fix merger to convert legacy blocks
sduchesneau Dec 7, 2023
f094747
fix tests
billettc Dec 7, 2023
6db5324
remove CoreBinaryEnabled from chain definition, now only part of the …
sduchesneau Dec 8, 2023
574234d
bump libraries one last time, bump changelog for v1.0.0
sduchesneau Dec 8, 2023
dce4f95
Merge branch 'develop' into block_any
sduchesneau Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions blockpoller/fetcher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package blockpoller

import (
"context"
"time"

pbbstream "github.com/streamingfast/bstream/pb/sf/bstream/v1"
)

type BlockFetcher interface {
PollingInterval() time.Duration
Fetch(ctx context.Context, blkNum uint64) (*pbbstream.Block, error)
}
37 changes: 12 additions & 25 deletions blockpoller/types.go → blockpoller/handler.go
Original file line number Diff line number Diff line change
@@ -1,52 +1,39 @@
package blockpoller

import (
"context"
"encoding/base64"
"fmt"
"time"
"sync"

pbbstream "github.com/streamingfast/bstream/pb/sf/bstream/v1"
"google.golang.org/protobuf/types/known/anypb"
)

type BlockFireFunc func(b *block) error

type BlockFetcher interface {
PollingInterval() time.Duration
Fetch(ctx context.Context, blkNum uint64) (*pbbstream.Block, error)
}

type BlockFinalizer interface {
type BlockHandler interface {
Init()
Fire(blk *pbbstream.Block) error
}

var _ BlockFinalizer = (*FireBlockFinalizer)(nil)
var _ BlockHandler = (*FireBlockHandler)(nil)

type FireBlockFinalizer struct {
type FireBlockHandler struct {
blockTypeURL string
init sync.Once
}

func NewFireBlockFinalizer(blockTypeURL string) *FireBlockFinalizer {
return &FireBlockFinalizer{
func NewFireBlockHandler(blockTypeURL string) *FireBlockHandler {
return &FireBlockHandler{
blockTypeURL: blockTypeURL,
}
}

func (f *FireBlockFinalizer) Init() {
func (f *FireBlockHandler) Init() {
fmt.Println("FIRE INIT 1.0 ", f.blockTypeURL)
}

func (f *FireBlockFinalizer) Fire(b *pbbstream.Block) error {
func (f *FireBlockHandler) Fire(b *pbbstream.Block) error {
//blockLine := "FIRE BLOCK 18571000 d2836a703a02f3ca2a13f05efe26fc48c6fa0db0d754a49e56b066d3b7d54659 18570999 55de88c909fa368ae1e93b6b8ffb3fbb12e64aefec1d4a1fcc27ae7633de2f81 18570800 1699992393935935000 Ci10eXBlLmdvb2dsZWFwaXMuY29tL3NmLmV0aGVyZXVtLnR5cGUudjIuQmxvY2sSJxIg0oNqcDoC88oqE/Be/ib8SMb6DbDXVKSeVrBm07fVRlkY+L3tCA=="
anyBlock, err := anypb.New(b)
if err != nil {
return fmt.Errorf("converting block to anypb: %w", err)
}

if anyBlock.TypeUrl != f.blockTypeURL {
return fmt.Errorf("block type url %q does not match expected type %q", anyBlock.TypeUrl, f.blockTypeURL)
if b.Payload.TypeUrl != f.blockTypeURL {
return fmt.Errorf("block type url %q does not match expected type %q", b.Payload.TypeUrl, f.blockTypeURL)
}

blockLine := fmt.Sprintf(
@@ -57,7 +44,7 @@ func (f *FireBlockFinalizer) Fire(b *pbbstream.Block) error {
b.ParentId,
b.LibNum,
b.Timestamp.AsTime().UnixNano(),
base64.StdEncoding.EncodeToString(anyBlock.Value),
base64.StdEncoding.EncodeToString(b.Payload.Value),
)

fmt.Println(blockLine)
4 changes: 2 additions & 2 deletions blockpoller/init_test.go
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ func (b *TestBlockFetcher) check(t *testing.T) {
require.Equal(b.t, uint64(len(b.blocks)), b.idx, "we should have fetched all %d blocks, only fired %d blocks", len(b.blocks), b.idx)
}

var _ BlockFinalizer = &TestBlockFinalizer{}
var _ BlockHandler = &TestBlockFinalizer{}

type TestBlockFinalizer struct {
t *testing.T
@@ -111,7 +111,7 @@ func (b *TestBlockFinalizer) check(t *testing.T) {
require.Equal(b.t, uint64(len(b.fireBlocks)), b.idx, "we should have fired all %d blocks, only fired %d blocks", len(b.fireBlocks), b.idx)
}

var _ BlockFinalizer = &TestNoopBlockFinalizer{}
var _ BlockHandler = &TestNoopBlockFinalizer{}

type TestNoopBlockFinalizer struct{}

14 changes: 7 additions & 7 deletions blockpoller/poller.go
Original file line number Diff line number Diff line change
@@ -19,23 +19,23 @@ type BlockPoller struct {
fetchBlockRetryCount uint64
stateStorePath string

blockFetcher BlockFetcher
blockFinalizer BlockFinalizer
forkDB *forkable.ForkDB
blockFetcher BlockFetcher
blockHandler BlockHandler
forkDB *forkable.ForkDB

logger *zap.Logger
}

func New(
blockFetcher BlockFetcher,
blockFinalizer BlockFinalizer,
blockFinalizer BlockHandler,
opts ...Option,
) *BlockPoller {

b := &BlockPoller{
Shutter: shutter.New(),
blockFetcher: blockFetcher,
blockFinalizer: blockFinalizer,
blockHandler: blockFinalizer,
fetchBlockRetryCount: 4,
logger: zap.NewNop(),
}
@@ -56,7 +56,7 @@ func (p *BlockPoller) Run(ctx context.Context, startBlockNum uint64, finalizedBl
zap.Uint64("resolved_start_block_num", resolveStartBlockNum),
)

p.blockFinalizer.Init()
p.blockHandler.Init()

startBlock, err := p.blockFetcher.Fetch(ctx, resolveStartBlockNum)
if err != nil {
@@ -208,7 +208,7 @@ func (p *BlockPoller) fire(blk *block) (bool, error) {
return false, nil
}

if err := p.blockFinalizer.Fire(blk.Block); err != nil {
if err := p.blockHandler.Fire(blk.Block); err != nil {
return false, err
}

2 changes: 1 addition & 1 deletion blockpoller/poller_test.go
Original file line number Diff line number Diff line change
@@ -222,7 +222,7 @@ func TestForkHandler_fire(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
poller := &BlockPoller{startBlockNumGate: test.startBlockNum, blockFinalizer: &TestNoopBlockFinalizer{}}
poller := &BlockPoller{startBlockNumGate: test.startBlockNum, blockHandler: &TestNoopBlockFinalizer{}}
ok, err := poller.fire(test.block)
require.NoError(t, err)
assert.Equal(t, test.expect, ok)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ 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.20231121211820-e45c1b42f472
github.com/streamingfast/bstream v0.0.2-0.20231122151642-aa0d174c0e39
github.com/streamingfast/cli v0.0.4-0.20230825151644-8cc84512cd80
github.com/streamingfast/dauth v0.0.0-20230929180355-921f9c9be330
github.com/streamingfast/dbin v0.9.1-0.20231117225723-59790c798e2c
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -574,10 +574,10 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU=
github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
github.com/streamingfast/bstream v0.0.2-0.20231121140754-a458ffe57f0d h1:yPqseR0o2RFU2HNoAi6hqIszWr8WVoOQbnHKcEI2zZE=
github.com/streamingfast/bstream v0.0.2-0.20231121140754-a458ffe57f0d/go.mod h1:08GVb+DXyz6jVNIsbf+2zlaC81UeEGu5o1h49KrSR3Y=
github.com/streamingfast/bstream v0.0.2-0.20231121211820-e45c1b42f472 h1:HhWgNV7PIdKiK7IZIXLQ/3mNsERqLm5ztzLwn43AcOo=
github.com/streamingfast/bstream v0.0.2-0.20231121211820-e45c1b42f472/go.mod h1:08GVb+DXyz6jVNIsbf+2zlaC81UeEGu5o1h49KrSR3Y=
github.com/streamingfast/bstream v0.0.2-0.20231122151642-aa0d174c0e39 h1:4MP75Z2TGPh/TpaoqFZH1fDI9yEv6ZeShqqjKMb6r/A=
github.com/streamingfast/bstream v0.0.2-0.20231122151642-aa0d174c0e39/go.mod h1:08GVb+DXyz6jVNIsbf+2zlaC81UeEGu5o1h49KrSR3Y=
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-20230929180355-921f9c9be330 h1:49JYZkn8ALGe+LhcACZyX3L9B8tIxRZ3F3l+OxmNMhY=
@@ -617,8 +617,6 @@ github.com/streamingfast/shutter v1.5.0 h1:NpzDYzj0HVpSiDJVO/FFSL6QIK/YKOxY0gJAt
github.com/streamingfast/shutter v1.5.0/go.mod h1:B/T6efqdeMGbGwjzPS1ToXzYZI4kDzI5/u4I+7qbjY8=
github.com/streamingfast/snapshotter v0.0.0-20230316190750-5bcadfde44d0 h1:Y15G1Z4fpEdm2b+/70owI7TLuXadlqBtGM7rk4Hxrzk=
github.com/streamingfast/snapshotter v0.0.0-20230316190750-5bcadfde44d0/go.mod h1:/Rnz2TJvaShjUct0scZ9kKV2Jr9/+KBAoWy4UMYxgv4=
github.com/streamingfast/substreams v1.1.21-0.20231120175501-9d89549d81a1 h1:PQeoATwMtCXKw2ztdS3ruwIOMzCj4GEGkkxB8LvcMOE=
github.com/streamingfast/substreams v1.1.21-0.20231120175501-9d89549d81a1/go.mod h1:HimUVtUnRKCdWfkNKFdVgqGCcrNu49+Az5Cyzdpuc4Q=
github.com/streamingfast/substreams v1.1.21-0.20231122013157-938ec26b0ef6 h1:eNA736ywGv/XXCotwx4LkfRDmOrHUyPbAqCKI+RzYI4=
github.com/streamingfast/substreams v1.1.21-0.20231122013157-938ec26b0ef6/go.mod h1:JHCOsJtgXUM2KWNxsvi5/hjrLy4KpClaMRriBR3ybnI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=