babylonlabs-io / finality-gadget

Other
4 stars 1 forks source link

feat: store BTC staking activated timestamp into DB #22

Closed lesterli closed 3 weeks ago

lesterli commented 3 weeks ago

Summary

This PR persists the BTC staking activated timestamp into DB, b/c it never changes, so it is better to store it in DB rather than perform the query to the Babylon node each time.

The origin comment https://github.com/babylonchain/babylon-finality-gadget/pull/61#discussion_r1689373331

Test Plan

make lint
make test

Also, we can test it and check the finality-gadget log by running the integration deployment scripts:

git clone git@github.com:babylonlabs-io/babylon-integration-deployment.git
cd babylon-integration-deployment
git submodule init && git submodule update

make start-deployment-finality-gadget-integration-op-l2-demo

docker logs finality-gadget
2024-08-22T11:47:23.038878Z     debug   BTC staking activated at        {"timestamp": 1724327212}
2024-08-22T11:47:23.041548Z     debug   Saved BTC staking activated timestamp to database       {"timestamp": 1724327212}
2024-08-22T11:47:23.041625Z     info    Skipping block before BTC staking activation    {"block_height": 0}
2024-08-22T11:47:33.029236Z     debug   BTC staking activated timestamp found in database       {"timestamp": 1724327212}