babylonchain / staking-indexer

A tool that extracts BTC staking relevant data from the Bitcoin blockchain
Other
3 stars 4 forks source link

feat: new command `btc-headers` #93

Closed RafilxTenfen closed 5 months ago

RafilxTenfen commented 5 months ago

I was thinking we could export just as a slice of BTCHeaderInfo, but in the end we might just using it for the genesis

Closes: #32

Example

$ ./build/sid btc-headers 10 13

2024-05-20T22:56:22.821443Z     info    Successfully wrote btc headers to file  {"fromBlock": 10, "toBlock": 13, "outputFile": "/home/rafilx/.sid/output-btc-headers.json"}

It should generate 4 block 10 ~ 13 (inclusive)

$ cat /home/rafilx/.sid/btc-headers.json | jq '.btc_headers | length'

4
RafilxTenfen commented 5 months ago

@gitferry the failing on CI https://app.circleci.com/jobs/github/babylonchain/staking-indexer/738 Is related to a invalid value here

I tried to hardcode the seed 28 to reproduce, but was not able to Any tips?

gitferry commented 5 months ago

Re the failing on CI https://app.circleci.com/jobs/github/babylonchain/staking-indexer/738

So this is flaky right now. I think the culprit is that Intn() will panic when the input is 0. This can happen if params.MaxStakingTime = params.MinStakingTime. It would be good if you can fix it in this PR.

In testutils/datagen/params.go, we change line 52: maxStakingTime := uint16(r.Intn(10000)) + minStakingTime -> maxStakingTime := uint16(r.Intn(10000)) + minStakingTime + 1