Skip to content

Commit

Permalink
fix yaml config file parsing, a few fixes and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Aug 23, 2024
1 parent f708314 commit 7cebed0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ If you were at `firehose-core` version `1.0.0` and are bumping to `1.1.0`, you s
- `advertise-block-features` List of features describing the blocks (optional)
- `advertise-block-id-encoding` Encoding format of the block ID [BLOCK_ID_ENCODING_BASE58, BLOCK_ID_ENCODING_BASE64, BLOCK_ID_ENCODING_BASE64URL, BLOCK_ID_ENCODING_HEX, BLOCK_ID_ENCODING_0X_HEX] (required, unless the block type is in the "well-known" list)

* Add a well-known list of chains (hard-coded in `wellknown/chains.go` to help automatically determine the 'advertise' flag values)
* Add a well-known list of chains (hard-coded in `wellknown/chains.go` to help automatically determine the 'advertise' flag values). Users are encouraged to propose Pull Requests to add more chains to the list.
* The new info endpoint adds a mandatory fetching of the first streamable block on startup, with a failure if no block can be fetched after 3 minutes and you are running `firehose` or `substreams-tier1` service.
It validates the following on a well-known chain:
- if the first-streamable-block Num/ID match the genesis block of a known chain, e.g. `matic`, it will refuse another value for `advertise-chain-name` than `matic` or one of its aliases (`polygon`)
- If the first-streamable-block does not match any known chain, it will require the `advertise-chain-name` to be non-empty
- If the first-streamable-block type is unknown (i.e. not ethereum, solana, near, cosmos, bitcoin...), it will require the user to provide `advertise-chain-name` as well as `advertise-block-id-encoding`

* Substreams: revert module hash calculation from `v1.5.5`, when using a non-zero firstStreamableBlock. Hashes will now be the same even if the chain's first streamable block affects the initialBlock of a module.
* Substreams: add `--substreams-block-execution-timeout` flag (default 3 minutes) to prevent requests stalling
Expand Down
4 changes: 4 additions & 0 deletions cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func setupCmd(cmd *cobra.Command, binaryName string) error {
return fmt.Errorf("invalid flag %s in config file under command %s", k, subCommand)
}

// Keep compatibility with config files, allow empty value to unset the flag
if v == nil {
v = ""
}
viper.SetDefault(flag.viperKey, v)

// For root command, we want to keep compatibility for `viper.GetXXX("global-<flag>")` to work with config loaded value
Expand Down
2 changes: 2 additions & 0 deletions firehose/info/endpoint_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (s *InfoServer) getBlockFromMergedBlocksStore(ctx context.Context, blockNum

block, err := bstream.FetchBlockFromMergedBlocksStore(ctx, blockNum, mergedBlocksStore)
if err != nil {
time.Sleep(time.Millisecond * 500)
continue
}
return block
Expand Down Expand Up @@ -132,6 +133,7 @@ func (s *InfoServer) getBlockFromOneBlockStore(ctx context.Context, blockNum uin

block, err := bstream.FetchBlockFromOneBlockStore(ctx, blockNum, "", oneBlockStore)
if err != nil {
time.Sleep(time.Millisecond * 500)
continue
}
return block
Expand Down
4 changes: 2 additions & 2 deletions launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
var Config map[string]*CommandConfig

type CommandConfig struct {
Args []string `json:"args"`
Flags map[string]string `json:"flags"`
Args []string `json:"args"`
Flags map[string]any `json:"flags"`
}

// Load reads a YAML config, and sets the global DfuseConfig variable
Expand Down
7 changes: 6 additions & 1 deletion well-known/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ type WellKnownProtocol struct {
}

type Chain struct {
Name string
// Canonical name, from https://thegraph.com/docs/en/developing/supported-networks/
Name string
// Aliases are other names that can be used to refer to the chain, for example 'polygon' is a popular name for the chain 'matic'
Aliases []string
// Genesis block here is actually the "lowest possible" first streamable block through firehose blocks.
// In most cases, it matches the "genesis block" of the chain.
// It must match the value of the `sf.bstream.v1.Block.id` field (https://github.com/streamingfast/bstream/blob/develop/proto/sf/bstream/v1/bstream.proto#L71)
// and it follows the encoding specified in the `BytesEncoding` field of the WellKnownProtocol
// You can generally get the genesis block ID by running `firecore tools print merged-blocks <path/to/merged-blocks> <first-streamable-block-number>` on the merged-blocks
GenesisBlockID string
GenesisBlockNumber uint64
}
Expand Down

0 comments on commit 7cebed0

Please sign in to comment.