Skip to content

Commit

Permalink
Merge branch 'main' of github.com:babylonlabs-io/babylon into rafilx/…
Browse files Browse the repository at this point in the history
…improve-performance-btc-dist
  • Loading branch information
RafilxTenfen committed Dec 9, 2024
2 parents f80d9f6 + bf31f69 commit 513b73d
Show file tree
Hide file tree
Showing 86 changed files with 378,727 additions and 516 deletions.
98 changes: 36 additions & 62 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,103 +1,77 @@
run:
timeout: 5m
# TODO: enable all linters
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
# - bodyclose
# - containedctx
# - contextcheck
- decorder
- depguard
- dogsled
- dupl
# - dogsled
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exhaustivestruct
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
# - errorlint
# - exhaustive
# - forbidigo
# - forcetypeassert
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofumpt
# - gocritic
# - gocyclo
- goheader
- golint
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- interfacebloat
- interfacer
- ireturn
- lll
- loggercheck
- maintidx
- makezero
- maligned
# - maintidx
# - makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
# - nlreturn
- noctx
- nolintlint
- nonamedreturns
- nosnakecase
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
# - paralleltest
- reassign
- revive
# - revive
- rowserrcheck
- scopelint
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tagliatelle
# - stylecheck
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
# - tparallel
- typecheck
- unconvert
- unparam
- unused
# - unparam
- usestdlibvars
- varcheck
- varnamelen
- unused
- wastedassign
- whitespace
- wrapcheck
- wsl
# - wrapcheck

issues:
max-same-issues: 0
# Default: https://golangci-lint.run/usage/false-positives/#default-exclusions
exclude-dirs:
- e2etest
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- path-except: _test\.go
linters:
- forbidigo
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- [#306](https://github.com/babylonlabs-io/babylon/pull/306) feat: improve BTC reward distribution with
virtual block periods for each finality provider that has delegations and reward tracker structures.
- [#316](https://github.com/babylonlabs-io/babylon/pull/316) Add testnet upgrade data

### Bug fixes

Expand All @@ -52,6 +53,10 @@ jailed fp counter
- [#326](https://github.com/babylonlabs-io/babylon/pull/326) docs: btcstaking:
Update btcstaking module docs to include EOI

## v0.18.1

- [#328](https://github.com/babylonlabs-io/babylon/pull/328) Fix btc activation height validation in genesis

## v0.18.0

### Improvements
Expand Down
1 change: 0 additions & 1 deletion app/ante/ante_btc_validation_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func NewBtcValidationDecorator(
}

func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {

// only do this validation when handling mempool addition. During DeliverTx they
// should be performed by btclightclient and btccheckpoint modules
if ctx.IsCheckTx() || ctx.IsReCheckTx() {
Expand Down
20 changes: 15 additions & 5 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ type SetupOptions struct {
AppOpts types.AppOptions
}

func setup(t *testing.T, ps *appkeepers.PrivSigner, withGenesis bool, invCheckPeriod uint) (*BabylonApp, GenesisState) {
func setup(t *testing.T, ps *appkeepers.PrivSigner, withGenesis bool, invCheckPeriod uint, btcConf bbn.SupportedBtcNetwork) (*BabylonApp, GenesisState) {
db := dbm.NewMemDB()
nodeHome := t.TempDir()

appOptions := make(simsutils.AppOptionsMap, 0)
appOptions[flags.FlagHome] = nodeHome // ensure unique folder
appOptions[server.FlagInvCheckPeriod] = invCheckPeriod
appOptions["btc-config.network"] = string(bbn.BtcSimnet)
appOptions["btc-config.network"] = string(btcConf)
appOptions[server.FlagPruning] = pruningtypes.PruningOptionDefault
appOptions[server.FlagMempoolMaxTxs] = mempool.DefaultMaxTx
appOptions[flags.FlagChainID] = "chain-test"
Expand Down Expand Up @@ -226,6 +226,16 @@ func genesisStateWithValSet(t *testing.T,
// one validator in validator set during InitGenesis abci call - https://github.com/cosmos/cosmos-sdk/pull/9697
func Setup(t *testing.T, isCheckTx bool) *BabylonApp {
t.Helper()
return SetupWithBitcoinConf(t, isCheckTx, bbn.BtcSimnet)
}

// SetupWithBitcoinConf initializes a new BabylonApp with a specific btc network config.
// A Nop logger is set in BabylonApp. Created Babylon application will have one validator
// with hardoced amount of tokens. This is necessary as from cosmos-sdk 0.46 it is required
// that there is at least one validator in validator set during InitGenesis abci call
// https://github.com/cosmos/cosmos-sdk/pull/9697
func SetupWithBitcoinConf(t *testing.T, isCheckTx bool, btcConf bbn.SupportedBtcNetwork) *BabylonApp {
t.Helper()

ps, err := SetupTestPrivSigner()
require.NoError(t, err)
Expand All @@ -242,7 +252,7 @@ func Setup(t *testing.T, isCheckTx bool) *BabylonApp {
require.NoError(t, err)
genesisValSet := []*checkpointingtypes.GenesisKey{genesisKey}

app := SetupWithGenesisValSet(t, genesisValSet, ps, []authtypes.GenesisAccount{acc}, balance)
app := SetupWithGenesisValSet(t, btcConf, genesisValSet, ps, []authtypes.GenesisAccount{acc}, balance)

return app
}
Expand All @@ -266,9 +276,9 @@ func SetupTestPrivSigner() (*appkeepers.PrivSigner, error) {
// of one consensus engine unit (10^6) in the default token of the babylon app from first genesis
// account. A Nop logger is set in BabylonApp.
// Note that the privSigner should be the 0th item of valSet
func SetupWithGenesisValSet(t *testing.T, valSet []*checkpointingtypes.GenesisKey, privSigner *appkeepers.PrivSigner, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *BabylonApp {
func SetupWithGenesisValSet(t *testing.T, btcConf bbn.SupportedBtcNetwork, valSet []*checkpointingtypes.GenesisKey, privSigner *appkeepers.PrivSigner, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *BabylonApp {
t.Helper()
app, genesisState := setup(t, privSigner, true, 5)
app, genesisState := setup(t, privSigner, true, 5, btcConf)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
Expand Down
43 changes: 2 additions & 41 deletions app/upgrades/v1/mainnet/btc_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,10 @@ package mainnet
const NewBtcHeadersStr = `{
"btc_headers": [
{
"header": "00000020f61eee3b63a380a477a063af32b2bbc97c9ff9f01f2c4225e973988108000000f575c83235984e7dc4afc1f30944c170462e84437ab6f2d52e16878a79e4678bd1914d5fae77031eccf40700"
"header": "0000002031746b63c89e0e9b0a341611a8c45011d176077901c44c963d3debf86e000000dcc825d49792f6cb0585542cc80dade8e44824c7c792e3ceca17805e5a738f3c04b84366934f011e2b9b5c01"
},
{
"header": "00000020533b53ded9bff4adc94101d32400a144c54edc5ed492a3b26c63b2d686000000b38fef50592017cfafbcab88eb3d9cf50b2c801711cad8299495d26df5e54812e7914d5fae77031ecfdd0b00"
},
{
"header": "000000202960f3752f0bfa8858a3e333294aedc7808025e868c9dc03e71d88bb320000007765fcd3d5b4966beb338bba2675dc2cf2ad28d4ad1d83bdb6f286e7e27ac1f807924d5fae77031e81d60b00"
},
{
"header": "00000020b06443a13ae1d3d50faef5ecad38c6818194dc46abca3e972e2aacdae800000069a5829097e80fee00ac49a56ea9f82d741a6af84d32b3bc455cf31871e2a8ac27924d5fae77031e9c910500"
},
{
"header": "000000207ed403758a4f228a1939418a155e2ebd4ae6b26e5ffd0ae433123f7694010000542e80b609c5bc58af5bdf492e26d4f60cd43a3966c2e063c50444c29b3757a636924d5fae77031ee8601d00"
},
{
"header": "000000205bea0a88d1422c3df08d766ad72df95084d0700e6f873b75dd4e986c7703000002b57516d33ed60c2bdd9f93d6d5614083324c837e68e5ba6e04287a7285633585924d5fae77031ed1719600"
},
{
"header": "00000020daf3b60d374b19476461f97540498dcfa2eb7016238ec6b1d022f82fb60100007a7ae65b53cb988c2ec92d2384996713821d5645ffe61c9acea60da75cd5edfa1a944d5fae77031e9dbb0500"
},
{
"header": "00000020457cc5f3c2e1a5655bc20e20e48d33e1b7ea68786c614032b5c518f0b6000000541f36942d82c6e7248275ff15c8933487fbe1819c67a9ecc0f4b70bb7e6cf672a944d5fae77031e8f398600"
},
{
"header": "00000020a2eb61eb4f3831baa3a3363e1b42db4462663f756f07423e81ed30322102000077224de7dea0f8d0ec22b1d2e2e255f0a987b96fe7200e1a2e6373f48a2f5b7894954d5fae77031e36867e00"
},
{
"header": "00000020a868e8514be5e46dabd6a122132f423f36a43b716a40c394e2a8d063e1010000f4c6c717e99d800c699c25a2006a75a0c5c09f432a936f385e6fce139cdbd1a5e9964d5fae77031e7d026e00"
},
{
"header": "000000205b969d72d19a47f39703c89a0cdb9eada8c4db934064f30e31f89a8e41010000949eef89068ffc76bf4dca6762e26581d410d0df40edf147d4ffdc6dea404a1512984d5fae77031ee67c1200"
},
{
"header": "000000209410d824b5c57e762922a4035d300bd1d24db4e57b130ff7762ae5df4c030000532299955b2dc6bd7c13c267d3c0990fefdf7aec3bcbab5b2c85d0d36316f93644984d5fae77031ecdea1600"
},
{
"header": "0000002009f649453a4079cb1d1beb138ea915d2355788bd4689785ecf7a265d3700000010bd26b43a88350e614736674431e62cc7c77dc577d07edd80620a02339d5fab82984d5fae77031efe682400"
},
{
"header": "0000002035b9ff9157a6e7b5b9ee3807b8246ab687d2ee340f5b0f86cd0e2798aa00000028ef48260b3c0d45bbe5321335b05dde8fcb130e063202457884585298b8a5dde4984d5fae77031ec0a08600"
},
{
"header": "0000002086102ffb6fd14131a08faa1e87680d5470954ba9638f15b56b7345de500100009f423c63aa6d39330082b58808013a85af5a7f338a7a3587f0a85b587665e6174e9a4d5fae77031e79353a00"
"header": "00000020a87076e9e536209ba9e91bf6a6dda9df17284ced7a195d055950b820e9000000ffcb47795f9aca88db55add40ef3a59faa0c10728f6158553d965c388299a3270dbe4366934f011e153a4b01"
}
]
}`
Loading

0 comments on commit 513b73d

Please sign in to comment.