Skip to content

Commit 85eda62

Browse files
authored
refactor(crosschain): move ballot voting logic into observer (#1511)
* 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
1 parent cfd27a7 commit 85eda62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1576
-394
lines changed

Dockerfile

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""
1616
WORKDIR /go/delivery/zeta-node
1717
COPY go.mod .
1818
COPY go.sum .
19-
#RUN --mount=type=cache,target=/root/.cache/go-build \
20-
# go mod download
19+
2120
RUN go mod download
2221
COPY . .
23-
24-
#RUN --mount=type=cache,target=/root/.cache/go-build \
25-
# make install
26-
#RUN --mount=type=cache,target=/root/.cache/go-build \
27-
# make install-zetae2e
2822
RUN make install
2923
RUN make install-zetae2e
3024
#

changelog.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
## Unreleased
44

5-
### Features
6-
7-
* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses
8-
95
### Refactor
106

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

11+
### Features
12+
13+
* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses
14+
1415
### Tests
1516

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

2223
## Version: v13.0.0
2324

24-
* `zetaclientd start` : 2 inputs required from stdin
25+
### Breaking Changes
26+
27+
* `zetaclientd start`: now requires 2 inputs from stdin: hotkey password and tss keyshare password
28+
Starting zetaclient now requires two passwords to be input; one for the hotkey and another for the tss key-share.
2529

2630
### Features
2731

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

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

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

57-
5861
### Tests
5962

6063
* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks

common/chain.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,17 @@ func (chain Chain) BTCAddressFromWitnessProgram(witnessProgram []byte) (string,
7575

7676
// DecodeAddress decode the address string to bytes
7777
func (chain Chain) DecodeAddress(addr string) ([]byte, error) {
78-
if IsEVMChain(chain.ChainId) {
78+
return DecodeAddressFromChainID(chain.ChainId, addr)
79+
}
80+
81+
// DecodeAddressFromChainID decode the address string to bytes
82+
func DecodeAddressFromChainID(chainID int64, addr string) ([]byte, error) {
83+
if IsEVMChain(chainID) {
7984
return ethcommon.HexToAddress(addr).Bytes(), nil
80-
} else if IsBitcoinChain(chain.ChainId) {
85+
} else if IsBitcoinChain(chainID) {
8186
return []byte(addr), nil
8287
}
83-
return nil, fmt.Errorf("chain (%d) not supported", chain.ChainId)
88+
return nil, fmt.Errorf("chain (%d) not supported", chainID)
8489
}
8590

8691
func IsZetaChain(chainID int64) bool {

testutil/keeper/crosschain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
CrosschainNoMocks = CrosschainMockOptions{}
3333
)
3434

35-
// CrosschainKeeper initializes a crosschain keeper for testing purposes with option to mock specific keepers
35+
// CrosschainKeeperWithMocks initializes a crosschain keeper for testing purposes with option to mock specific keepers
3636
func CrosschainKeeperWithMocks(
3737
t testing.TB,
3838
mockOptions CrosschainMockOptions,

testutil/keeper/mocks/crosschain/fungible.go

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testutil/keeper/mocks/crosschain/observer.go

+84
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testutil/keeper/mocks/mocks.go

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
55
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
66
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types"
7+
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
78
)
89

910
/**
@@ -59,6 +60,10 @@ type FungibleEVMKeeper interface {
5960
fungibletypes.EVMKeeper
6061
}
6162

63+
/**
64+
* Emissions Mocks
65+
*/
66+
6267
//go:generate mockery --name EmissionAccountKeeper --filename account.go --case underscore --output ./emissions
6368
type EmissionAccountKeeper interface {
6469
emissionstypes.AccountKeeper
@@ -78,3 +83,17 @@ type EmissionStakingKeeper interface {
7883
type EmissionObserverKeeper interface {
7984
emissionstypes.ObserverKeeper
8085
}
86+
87+
/**
88+
* Observer Mocks
89+
*/
90+
91+
//go:generate mockery --name ObserverStakingKeeper --filename staking.go --case underscore --output ./observer
92+
type ObserverStakingKeeper interface {
93+
observertypes.StakingKeeper
94+
}
95+
96+
//go:generate mockery --name ObserverSlashingKeeper --filename slashing.go --case underscore --output ./observer
97+
type ObserverSlashingKeeper interface {
98+
observertypes.SlashingKeeper
99+
}

testutil/keeper/mocks/observer/slashing.go

+53
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)