Commit 4d2c28f0 authored by Son of Odin's avatar Son of Odin 💬

Merge branch 'test-patch-1' into 'master'

[bugfix] tiny misc bug fixes

See merge request !683
parents c6a2d024 7468d6ac
Pipeline #128631475 passed with stages
in 69 minutes and 13 seconds
......@@ -40,7 +40,7 @@ require (
github.com/tendermint/tendermint v0.32.9
github.com/tendermint/tm-db v0.2.0
github.com/zondax/ledger-go v0.11.0 // indirect
gitlab.com/thorchain/tss/go-tss v0.0.0-20200312094649-aef9dc0dbd42
gitlab.com/thorchain/tss/go-tss v0.0.0-20200320003459-54d30a7e8a20
go.uber.org/multierr v1.5.0 // indirect
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
......
......@@ -774,6 +774,8 @@ gitlab.com/thorchain/tss/go-tss v0.0.0-20200311063750-ecbf4b87e492 h1:fEpRLHPsS/
gitlab.com/thorchain/tss/go-tss v0.0.0-20200311063750-ecbf4b87e492/go.mod h1:ezIsYgnT42fXgani/rJvF7yNSbI1yr6RsZD06aC6yJg=
gitlab.com/thorchain/tss/go-tss v0.0.0-20200312094649-aef9dc0dbd42 h1:Lhocay+Q3xKM27xg6wDpjgPAkC6pRNXx13VfwGTRUXo=
gitlab.com/thorchain/tss/go-tss v0.0.0-20200312094649-aef9dc0dbd42/go.mod h1:ezIsYgnT42fXgani/rJvF7yNSbI1yr6RsZD06aC6yJg=
gitlab.com/thorchain/tss/go-tss v0.0.0-20200320003459-54d30a7e8a20 h1:AWFD7DINvj1UuPG8ls4aA8j1wKeUXC4h2eaJG0W/phc=
gitlab.com/thorchain/tss/go-tss v0.0.0-20200320003459-54d30a7e8a20/go.mod h1:ezIsYgnT42fXgani/rJvF7yNSbI1yr6RsZD06aC6yJg=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
......
......@@ -75,7 +75,6 @@ func (h ObservedTxInHandler) validateV1(ctx sdk.Context, msg MsgObservedTxIn) (b
if newSigner {
return true, nil
}
ctx.Logger().Error(notAuthorized.Error())
return false, notAuthorized
}
......
......@@ -17,7 +17,7 @@ type KeeperObserver interface {
func (k KVStore) SetActiveObserver(ctx sdk.Context, addr sdk.AccAddress) {
store := ctx.KVStore(k.storeKey)
key := k.GetKey(ctx, prefixActiveObserver, addr.String())
ctx.Logger().Info("set_active_observer", "key", key)
ctx.Logger().Debug("set_active_observer", "key", key)
store.Set([]byte(key), addr.Bytes())
}
......@@ -32,7 +32,7 @@ func (k KVStore) RemoveActiveObserver(ctx sdk.Context, addr sdk.AccAddress) {
func (k KVStore) IsActiveObserver(ctx sdk.Context, addr sdk.AccAddress) bool {
store := ctx.KVStore(k.storeKey)
key := k.GetKey(ctx, prefixActiveObserver, addr.String())
ctx.Logger().Info("is_active_observer", "key", key)
ctx.Logger().Debug("is_active_observer", "key", key)
return store.Has([]byte(key))
}
......
......@@ -794,10 +794,10 @@ func queryTSSSigners(ctx sdk.Context, path []string, req abci.RequestQuery, keep
return nil, sdk.ErrUnknownRequest("invalid pool pub key")
}
// seed is the current block height, rounded down to the nearest 10th
// seed is the current block height, rounded down to the nearest 100th
// This helps keep the selected nodes to be the same across blocks, but
// also change immediately if we have a change in which nodes are active
seed := ctx.BlockHeight() / 10
seed := ctx.BlockHeight() / 100
accountAddrs, err := keeper.GetObservingAddresses(ctx)
if err != nil {
......
......@@ -325,7 +325,7 @@ func (s *ThorchainSuite) TestRagnarok(c *C) {
c.Assert(err, IsNil)
// this should trigger stage 1 of the ragnarok protocol. We should see a tx
// out per node account
c.Assert(validatorMgr.processRagnarok(ctx, active, consts), IsNil)
c.Assert(validatorMgr.processRagnarok(ctx, consts), IsNil)
// after ragnarok get trigged , we pay bond reward immediately
for idx, bonder := range bonders {
na, err := keeper.GetNodeAccount(ctx, bonder.NodeAddress)
......@@ -358,7 +358,7 @@ func (s *ThorchainSuite) TestRagnarok(c *C) {
migrateInterval := consts.GetInt64Value(constants.FundMigrationInterval)
for i := 1; i <= 10; i++ { // simulate each round of ragnarok (max of ten)
ctx = ctx.WithBlockHeight(ragnarokHeight + (int64(i) * migrateInterval))
c.Assert(validatorMgr.processRagnarok(ctx, active, consts), IsNil)
c.Assert(validatorMgr.processRagnarok(ctx, consts), IsNil)
items, err := versionedTxOutStoreDummy.txoutStore.GetOutboundItems(ctx)
c.Assert(err, IsNil)
c.Assert(items, HasLen, 15, Commentf("%d", len(items)))
......
......@@ -118,17 +118,20 @@ func NewNodeAccount(nodeAddress sdk.AccAddress, status NodeStatus, nodePubKeySet
// IsEmpty decide whether NodeAccount is empty
func (n NodeAccount) IsEmpty() bool {
return n.NodeAddress.Empty()
return n.NodeAddress.Empty() || n.Status == Unknown
}
// IsValid check whether NodeAccount has all necessary values
func (n NodeAccount) IsValid() error {
if n.NodeAddress.Empty() {
return errors.New("node bep address is empty")
return errors.New("node thor address is empty")
}
if n.BondAddress.IsEmpty() {
return errors.New("bond address is empty")
}
if n.Status == Unknown {
return errors.New("node status cannot be unknown")
}
return nil
}
......
......@@ -134,7 +134,7 @@ func (vm *validatorMgrV1) EndBlock(ctx sdk.Context, constAccessor constants.Cons
// when ragnarok is in progress, just process ragnarok
if vm.k.RagnarokInProgress(ctx) {
// process ragnarok
if err := vm.processRagnarok(ctx, activeNodes, constAccessor); err != nil {
if err := vm.processRagnarok(ctx, constAccessor); err != nil {
ctx.Logger().Error("fail to process ragnarok protocol", "error", err)
}
return nil
......@@ -163,7 +163,7 @@ func (vm *validatorMgrV1) EndBlock(ctx sdk.Context, constAccessor constants.Cons
}
if len(retiring) == 0 { // wait until all funds are migrated before starting ragnarok
if err := vm.processRagnarok(ctx, activeNodes, constAccessor); err != nil {
if err := vm.processRagnarok(ctx, constAccessor); err != nil {
ctx.Logger().Error("fail to process ragnarok protocol", "error", err)
}
}
......@@ -326,7 +326,7 @@ func (vm *validatorMgrV1) payNodeAccountBondAward(ctx sdk.Context, na NodeAccoun
}
// determines when/if to run each part of the ragnarok process
func (vm *validatorMgrV1) processRagnarok(ctx sdk.Context, activeNodes NodeAccounts, constAccessor constants.ConstantValues) error {
func (vm *validatorMgrV1) processRagnarok(ctx sdk.Context, constAccessor constants.ConstantValues) error {
// execute Ragnarok protocol, no going back
// THORNode have to request the fund back now, because once it get to the rotate block height ,
// THORNode won't have validators anymore
......@@ -338,7 +338,7 @@ func (vm *validatorMgrV1) processRagnarok(ctx sdk.Context, activeNodes NodeAccou
if ragnarokHeight == 0 {
ragnarokHeight = ctx.BlockHeight()
vm.k.SetRagnarokBlockHeight(ctx, ragnarokHeight)
if err := vm.ragnarokProtocolStage1(ctx, activeNodes); err != nil {
if err := vm.ragnarokProtocolStage1(ctx); err != nil {
return fmt.Errorf("fail to execute ragnarok protocol step 1: %w", err)
}
if err := vm.ragnarokBondReward(ctx); err != nil {
......@@ -362,8 +362,8 @@ func (vm *validatorMgrV1) processRagnarok(ctx sdk.Context, activeNodes NodeAccou
// ragnarokProtocolStage1 - request all yggdrasil pool to return the fund
// when THORNode observe the node return fund successfully, the node's bound will be refund.
func (vm *validatorMgrV1) ragnarokProtocolStage1(ctx sdk.Context, activeNodes NodeAccounts) error {
return vm.recallYggFunds(ctx, activeNodes)
func (vm *validatorMgrV1) ragnarokProtocolStage1(ctx sdk.Context) error {
return vm.recallYggFunds(ctx)
}
func (vm *validatorMgrV1) ragnarokProtocolStage2(ctx sdk.Context, nth int64, constAccessor constants.ConstantValues) error {
......@@ -672,9 +672,14 @@ func (vm *validatorMgrV1) RequestYggReturn(ctx sdk.Context, node NodeAccount) er
return nil
}
func (vm *validatorMgrV1) recallYggFunds(ctx sdk.Context, activeNodes NodeAccounts) error {
func (vm *validatorMgrV1) recallYggFunds(ctx sdk.Context) error {
nodes, err := vm.k.ListNodeAccounts(ctx)
if err != nil {
return fmt.Errorf("fail to list all node accounts: %w", err)
}
// request every node to return fund
for _, na := range activeNodes {
for _, na := range nodes {
if err := vm.RequestYggReturn(ctx, na); err != nil {
return fmt.Errorf("fail to request yggdrasil fund back: %w", err)
}
......
......@@ -166,16 +166,18 @@ func (vm *VaultMgr) EndBlock(ctx sdk.Context, version semver.Version, constAcces
},
Memo: NewMigrateMemo(ctx.BlockHeight()).String(),
}
_, err = txOutStore.TryAddTxOutItem(ctx, toi)
ok, err := txOutStore.TryAddTxOutItem(ctx, toi)
if err != nil {
return err
}
vault.PendingTxCount += 1
if ok {
vault.PendingTxCount += 1
if err := vm.k.SetVault(ctx, vault); err != nil {
return fmt.Errorf("fail to save vault: %w", err)
}
}
}
}
if err := vm.k.SetVault(ctx, vault); err != nil {
return fmt.Errorf("fail to save vault: %w", err)
}
}
return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment