Skip to content

Commit

Permalink
refactor(crosschain): move ballot voting logic into observer (#1511)
Browse files Browse the repository at this point in the history
* move logic for ballot voting for inbound

* fix mocks

* goimports

* changelog

* fix unit tests

* fix CI =

* x/observer/keeper/vote_outbound.go x/crosschain/types/expected_keepers.go x/crosschain/keeper/msg_server_vote_outbound_tx.go

* update mocks

* refactor finalized check

* make generate

* initialize vote inbound tests

* add sdk keepers in observer testutil

* implement mock option for observer

* inbound vote test

* initialize outbound tests

* goimports

* vote outbound tests

* update changelog

* test with integration tests

* add isNew in vote_inbound

* add tests back

* use tmp context for ballot logic

* add new test for finalized ballot

* add not finzalized test
  • Loading branch information
lumtis authored Feb 29, 2024
1 parent cfd27a7 commit 85eda62
Show file tree
Hide file tree
Showing 55 changed files with 1,576 additions and 394 deletions.
8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""
WORKDIR /go/delivery/zeta-node
COPY go.mod .
COPY go.sum .
#RUN --mount=type=cache,target=/root/.cache/go-build \
# go mod download

RUN go mod download
COPY . .

#RUN --mount=type=cache,target=/root/.cache/go-build \
# make install
#RUN --mount=type=cache,target=/root/.cache/go-build \
# make install-zetae2e
RUN make install
RUN make install-zetae2e
#
Expand Down
19 changes: 11 additions & 8 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

## Unreleased

### Features

* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses

### Refactor

* [1511](https://github.com/zeta-chain/node/pull/1511) - move ballot voting logic from `crosschain` to `observer`
* [1783](https://github.com/zeta-chain/node/pull/1783) - refactor zetaclient metrics naming and structure
* [1774](https://github.com/zeta-chain/node/pull/1774) - split params and config in zetaclient

### Features

* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses

### Tests

* [1767](https://github.com/zeta-chain/node/pull/1767) - add unit tests for emissions module begin blocker
Expand All @@ -21,7 +22,10 @@

## Version: v13.0.0

* `zetaclientd start` : 2 inputs required from stdin
### Breaking Changes

* `zetaclientd start`: now requires 2 inputs from stdin: hotkey password and tss keyshare password
Starting zetaclient now requires two passwords to be input; one for the hotkey and another for the tss key-share.

### Features

Expand All @@ -36,9 +40,9 @@
*[1728] (https://github.com/zeta-chain/node/pull/1728) - allow aborted transactions to be refunded by minting tokens to zEvm.

### Refactor

* [1766](https://github.com/zeta-chain/node/pull/1766) - Refactors the `PostTxProcessing` EVM hook functionality to deal with invalid withdraw events
* [1630](https://github.com/zeta-chain/node/pull/1630) added password prompts for hotkey and tss keyshare in zetaclient
Starting zetaclient now requires two passwords to be input; one for the hotkey and another for the tss key-share.
* [1630](https://github.com/zeta-chain/node/pull/1630) - added password prompts for hotkey and tss keyshare in zetaclient
* [1760](https://github.com/zeta-chain/node/pull/1760) - Make staking keeper private in crosschain module

### Fixes
Expand All @@ -54,7 +58,6 @@
* [1721](https://github.com/zeta-chain/node/issues/1721) - zetaclient should provide bitcoin_chain_id when querying TSS address
* [1744](https://github.com/zeta-chain/node/pull/1744) - added cmd to encrypt tss keyshare file, allowing empty tss password for backward compatibility.


### Tests

* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks
Expand Down
11 changes: 8 additions & 3 deletions common/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ func (chain Chain) BTCAddressFromWitnessProgram(witnessProgram []byte) (string,

// DecodeAddress decode the address string to bytes
func (chain Chain) DecodeAddress(addr string) ([]byte, error) {
if IsEVMChain(chain.ChainId) {
return DecodeAddressFromChainID(chain.ChainId, addr)
}

// DecodeAddressFromChainID decode the address string to bytes
func DecodeAddressFromChainID(chainID int64, addr string) ([]byte, error) {
if IsEVMChain(chainID) {
return ethcommon.HexToAddress(addr).Bytes(), nil
} else if IsBitcoinChain(chain.ChainId) {
} else if IsBitcoinChain(chainID) {
return []byte(addr), nil
}
return nil, fmt.Errorf("chain (%d) not supported", chain.ChainId)
return nil, fmt.Errorf("chain (%d) not supported", chainID)
}

func IsZetaChain(chainID int64) bool {
Expand Down
2 changes: 1 addition & 1 deletion testutil/keeper/crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
CrosschainNoMocks = CrosschainMockOptions{}
)

// CrosschainKeeper initializes a crosschain keeper for testing purposes with option to mock specific keepers
// CrosschainKeeperWithMocks initializes a crosschain keeper for testing purposes with option to mock specific keepers
func CrosschainKeeperWithMocks(
t testing.TB,
mockOptions CrosschainMockOptions,
Expand Down
22 changes: 11 additions & 11 deletions testutil/keeper/mocks/crosschain/fungible.go

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

84 changes: 84 additions & 0 deletions testutil/keeper/mocks/crosschain/observer.go

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

19 changes: 19 additions & 0 deletions testutil/keeper/mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

/**
Expand Down Expand Up @@ -59,6 +60,10 @@ type FungibleEVMKeeper interface {
fungibletypes.EVMKeeper
}

/**
* Emissions Mocks
*/

//go:generate mockery --name EmissionAccountKeeper --filename account.go --case underscore --output ./emissions
type EmissionAccountKeeper interface {
emissionstypes.AccountKeeper
Expand All @@ -78,3 +83,17 @@ type EmissionStakingKeeper interface {
type EmissionObserverKeeper interface {
emissionstypes.ObserverKeeper
}

/**
* Observer Mocks
*/

//go:generate mockery --name ObserverStakingKeeper --filename staking.go --case underscore --output ./observer
type ObserverStakingKeeper interface {
observertypes.StakingKeeper
}

//go:generate mockery --name ObserverSlashingKeeper --filename slashing.go --case underscore --output ./observer
type ObserverSlashingKeeper interface {
observertypes.SlashingKeeper
}
53 changes: 53 additions & 0 deletions testutil/keeper/mocks/observer/slashing.go

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

Loading

0 comments on commit 85eda62

Please sign in to comment.