Skip to content

Commit

Permalink
fix: Do not perform conversions on the commission (ethereum-optimism#166
Browse files Browse the repository at this point in the history
)
  • Loading branch information
vitsalis authored Dec 5, 2023
1 parent eebea03 commit e617478
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
7 changes: 2 additions & 5 deletions clientcontroller/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/hex"
"fmt"
"math/big"
"time"

"cosmossdk.io/math"
Expand Down Expand Up @@ -150,16 +149,14 @@ func (bc *BabylonController) RegisterValidator(
chainPk []byte,
valPk *btcec.PublicKey,
pop []byte,
commission *big.Int,
commission *math.LegacyDec,
description []byte,
) (*types.TxResponse, error) {
var bbnPop btcstakingtypes.ProofOfPossession
if err := bbnPop.Unmarshal(pop); err != nil {
return nil, fmt.Errorf("invalid proof-of-possession: %w", err)
}

sdkCommission := math.LegacyNewDecFromBigInt(commission)

var sdkDescription sttypes.Description
if err := sdkDescription.Unmarshal(description); err != nil {
return nil, fmt.Errorf("invalid description: %w", err)
Expand All @@ -170,7 +167,7 @@ func (bc *BabylonController) RegisterValidator(
BabylonPk: &secp256k1.PubKey{Key: chainPk},
BtcPk: bbntypes.NewBIP340PubKeyFromBTCPK(valPk),
Pop: &bbnPop,
Commission: &sdkCommission,
Commission: commission,
Description: &sdkDescription,
}

Expand Down
5 changes: 2 additions & 3 deletions clientcontroller/interface.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package clientcontroller

import (
"cosmossdk.io/math"
"fmt"
"math/big"

"github.com/btcsuite/btcd/chaincfg"
"go.uber.org/zap"

Expand Down Expand Up @@ -36,7 +35,7 @@ type ValidatorAPIs interface {
chainPk []byte,
valPk *btcec.PublicKey,
pop []byte,
commission *big.Int,
commission *math.LegacyDec,
description []byte,
) (*types.TxResponse, error)

Expand Down
4 changes: 2 additions & 2 deletions itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ func StartManagerWithValidator(t *testing.T) (*TestManager, *service.ValidatorIn
func (tm *TestManager) Stop(t *testing.T) {
err := tm.Va.Stop()
require.NoError(t, err)
err = tm.CovenantEmulator.Stop()
require.NoError(t, err)
err = tm.BabylonHandler.Stop()
require.NoError(t, err)
err = os.RemoveAll(tm.ValConfig.DatabaseConfig.Path)
Expand All @@ -209,8 +211,6 @@ func (tm *TestManager) Stop(t *testing.T) {
tm.EOTSServerHandler.Stop()
err = os.RemoveAll(tm.EOTSServerHandler.baseDir)
require.NoError(t, err)
err = tm.CovenantEmulator.Stop()
require.NoError(t, err)
}

func (tm *TestManager) WaitForValRegistered(t *testing.T, bbnPk *secp256k1.PubKey) {
Expand Down
6 changes: 3 additions & 3 deletions testutil/mocks/babylon.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion validator/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ func (app *ValidatorApp) registrationLoop() {
req.bbnPubKey.Key,
req.btcPubKey.MustToBTCPK(),
popBytes,
req.commission.BigInt(),
req.commission,
req.description,
)

Expand Down
2 changes: 1 addition & 1 deletion validator/service/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func FuzzRegisterValidator(f *testing.F) {
validator.GetBabylonPK().Key,
validator.MustGetBIP340BTCPK().MustToBTCPK(),
popBytes,
testutil.ZeroCommissionRate().BigInt(),
testutil.ZeroCommissionRate(),
testutil.EmptyDescription(),
).Return(&types.TxResponse{TxHash: txHash}, nil).AnyTimes()

Expand Down

0 comments on commit e617478

Please sign in to comment.