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

chore: send one msg per tx if batch of msgs fails #98

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1aed9a0
chore: init of copying relayer msgs
RafilxTenfen Jan 17, 2025
c8f253a
chore: build message complete
RafilxTenfen Jan 18, 2025
7622a46
Merge branch 'main' of github.com:babylonlabs-io/covenant-emulator in…
RafilxTenfen Jan 20, 2025
df5f9ed
chore: trytest with acc sequence increment
RafilxTenfen Jan 21, 2025
fe84b51
chore: passing with account sequence
RafilxTenfen Jan 21, 2025
f0296c8
fix: lint
RafilxTenfen Jan 21, 2025
530b7e1
chore: add #98 to changelog
RafilxTenfen Jan 21, 2025
614717d
fix: sending with acc number
RafilxTenfen Jan 21, 2025
b36e916
fix: panic
RafilxTenfen Jan 21, 2025
1e149e0
chore: add errgroup
RafilxTenfen Jan 21, 2025
5bb0789
fix: finally signing
RafilxTenfen Jan 21, 2025
2ecb65a
fix: lint and notes
RafilxTenfen Jan 21, 2025
502cf0e
chore: remove split of e2e test runs, failing to start
RafilxTenfen Jan 21, 2025
81f31d3
chore: split e2e run on covenant emulator
RafilxTenfen Jan 21, 2025
430ed8b
chore: remove login docker
RafilxTenfen Jan 21, 2025
130e627
fix: wait group failure
RafilxTenfen Jan 21, 2025
184c4eb
chore: set permissions at the job level
RafilxTenfen Jan 21, 2025
463c313
chore: solve function closure of vars
RafilxTenfen Jan 21, 2025
18ab8ce
fix: lint call add prior to go routine
RafilxTenfen Jan 21, 2025
64fb043
chore: set to run a single message at a time
RafilxTenfen Jan 21, 2025
3980368
tryfix: e2e test wait group
RafilxTenfen Jan 21, 2025
91a7da1
chore: add option to start covenant emulator
RafilxTenfen Jan 21, 2025
960a88c
chore: refactory to return an slice of tx response
RafilxTenfen Jan 21, 2025
df8759b
test: modified to use multiple txs for checking
RafilxTenfen Jan 21, 2025
5994bc1
chore: rollback to use batch first
RafilxTenfen Jan 21, 2025
2114a6e
chore: increase exec time
RafilxTenfen Jan 21, 2025
a78b025
chore: remove opt to remote signer, should always use remote signer (…
RafilxTenfen Jan 29, 2025
9a9453b
chore: small refactor, need to have more public funcs in babylonclient
RafilxTenfen Jan 29, 2025
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
60 changes: 59 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
go-version: '1.23'
go-lint-version: 'v1.60.2'
run-unit-tests: true
run-integration-tests: true
run-integration-tests: false
run-lint: true
run-build: true
run-gosec: true
Expand Down Expand Up @@ -55,3 +55,61 @@
dockerContext: ./
repoName: covenant-signer
docker_scan: true

###############################################################################
### E2E ###
###############################################################################

e2e-cov-signer:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
Fixed Show fixed Hide fixed
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
- name: Run e2e covenant signer
run: |
cd covenant-signer; make test-e2e

e2e-cov-emulator-life:
Fixed Show fixed Hide fixed
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
Fixed Show fixed Hide fixed
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
- name: Run e2e covenant emulator life cycle
run: |
make test-e2e-cov-emu-life

e2e-cov-pending-dels:
Fixed Show fixed Hide fixed
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
Fixed Show fixed Hide fixed
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Go
uses: actions/setup-go@v5
with:
go-version: 1.23.1
- name: Run e2e covenant emulator pending dels
run: |
make test-e2e-cov-pending-del
Fixed Show fixed Hide fixed
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* [#95](https://github.com/babylonlabs-io/covenant-emulator/pull/95) removed local signer option
as the covenant emulator should only connect to a remote signer
* [#96](https://github.com/babylonlabs-io/covenant-emulator/pull/96) add pagination to `queryDelegationsWithStatus`
* [#98](https://github.com/babylonlabs-io/covenant-emulator/pull/98) add submission of covenant
signatures as one msg per transaction if batch of transactions fails

## v0.11.3

Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ test:

test-e2e:
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG)
go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e
go test -mod=readonly -timeout=5m -v $(PACKAGES_E2E) --tags=e2e
cd covenant-signer; make test-e2e

test-e2e-cov-emu-life:
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG)
go test -run TestCovenantEmulatorLifeCycle -mod=readonly -timeout=5m -v $(PACKAGES_E2E) --tags=e2e

test-e2e-cov-pending-del:
cd $(TOOLS_DIR); go install -trimpath $(BABYLON_PKG)
go test -run TestQueryPendingDelegations -mod=readonly -timeout=5m -v $(PACKAGES_E2E) --tags=e2e

mock-gen:
mkdir -p $(MOCKS_DIR)
$(MOCKGEN_CMD) -source=clientcontroller/interface.go -package mocks -destination $(MOCKS_DIR)/babylon.go
Expand Down
67 changes: 66 additions & 1 deletion clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (

sdkmath "cosmossdk.io/math"
"github.com/btcsuite/btcd/btcec/v2"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

bbn "github.com/babylonlabs-io/babylon/app"
appparams "github.com/babylonlabs-io/babylon/app/params"
bbnclient "github.com/babylonlabs-io/babylon/client/client"
bbntypes "github.com/babylonlabs-io/babylon/types"
btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"
Expand All @@ -36,6 +39,7 @@ type BabylonController struct {
bbnClient *bbnclient.Client
cfg *config.BBNConfig
btcParams *chaincfg.Params
encCfg *appparams.EncodingConfig
logger *zap.Logger
}

Expand Down Expand Up @@ -63,6 +67,7 @@ func NewBabylonController(
bc,
cfg,
btcParams,
bbn.GetEncodingConfig(),
logger,
}, nil
}
Expand Down Expand Up @@ -159,6 +164,37 @@ func (bc *BabylonController) reliablySendMsgs(msgs []sdk.Msg) (*provider.Relayer
)
}

func (bc *BabylonController) reliablySendMsgsAsMultipleTxs(msgs []sdk.Msg) (*provider.RelayerTxResponse, error) {
// ctx := context.Background()
cfg := bc.bbnClient.GetConfig()
encCfg := bc.encCfg
// c := bc.bbnClient.GetConfig()
// c.acc
keybase, err := KeybaseFromCfg(cfg, encCfg.Codec)
if err != nil {
return nil, err
}

covAddr, err := GetKeyAddressForKey(keybase, cfg.Key)
if err != nil {
return nil, err
}

covAddrStr := covAddr.String()
bc.logger.Debug(
"covenant_signing",
zap.String("address", covAddrStr),
)

covAcc, err := bc.QueryAccount(covAddrStr)
if err != nil {
return nil, err
}

_, _, err = reliablySendEachMsgAsTx(cfg, msgs, bc.logger, bc.bbnClient.RPCClient, encCfg, covAcc, expectedErrors, unrecoverableErrors)
return nil, err
}

// SubmitCovenantSigs submits the Covenant signature via a MsgAddCovenantSig to Babylon if the daemon runs in Covenant mode
// it returns tx hash and error
func (bc *BabylonController) SubmitCovenantSigs(covSigs []*types.CovenantSigs) (*types.TxResponse, error) {
Expand All @@ -174,7 +210,11 @@ func (bc *BabylonController) SubmitCovenantSigs(covSigs []*types.CovenantSigs) (
SlashingUnbondingTxSigs: covSig.SlashingUnbondingSigs,
})
}
res, err := bc.reliablySendMsgs(msgs)
// res, err := bc.reliablySendMsgs(msgs)
// if err != nil {
// return nil, err
// }
res, err := bc.reliablySendMsgsAsMultipleTxs(msgs)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -509,3 +549,28 @@ func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfo

return res.Header, nil
}

// QueryAccount returns the account interface based on the address
func (bc *BabylonController) QueryAccount(addr string) (sdk.AccountI, error) {
ctx, cancel := getContextWithCancel(bc.cfg.Timeout)
defer cancel()

clientCtx := sdkclient.Context{Client: bc.bbnClient.RPCClient}.WithCodec(bc.encCfg.Codec)

queryClient := authtypes.NewQueryClient(clientCtx)

req := &authtypes.QueryAccountRequest{
Address: addr,
}
resp, err := queryClient.Account(ctx, req)
if err != nil {
return nil, fmt.Errorf("failed to query account: %v", err)
}

var account sdk.AccountI
if err := bc.encCfg.InterfaceRegistry.UnpackAny(resp.Account, &account); err != nil {
return nil, err
}

return account, nil
}
Loading
Loading