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

refactor(crosschain): move ballot voting logic into observer #1511

Merged
merged 32 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a616eef
move logic for ballot voting for inbound
lumtis Jan 2, 2024
ce55d9c
fix mocks
lumtis Jan 2, 2024
678027d
goimports
lumtis Jan 2, 2024
18e4880
changelog
lumtis Jan 2, 2024
935043e
fix unit tests
lumtis Jan 2, 2024
af8dade
fix CI =
lumtis Jan 2, 2024
0d19c85
x/observer/keeper/vote_outbound.go x/crosschain/types/expected_keeper…
lumtis Jan 2, 2024
c6abd29
update mocks
lumtis Jan 2, 2024
b146606
Merge branch 'develop' into refactor/outbound-inbound-validation
lumtis Jan 5, 2024
73c339e
Merge branch 'develop' into refactor/outbound-inbound-validation
lumtis Jan 6, 2024
c548c7d
conflicts
lumtis Feb 4, 2024
a37bc8a
refactor finalized check
lumtis Feb 4, 2024
d1932a0
make generate
lumtis Feb 5, 2024
f9a00d8
Merge branch 'develop' into refactor/outbound-inbound-validation
lumtis Feb 20, 2024
4d15fcc
initialize vote inbound tests
lumtis Feb 20, 2024
e5930be
add sdk keepers in observer testutil
lumtis Feb 20, 2024
926e12e
implement mock option for observer
lumtis Feb 20, 2024
f474277
inbound vote test
lumtis Feb 20, 2024
f0c7843
initialize outbound tests
lumtis Feb 20, 2024
ebcc423
goimports
lumtis Feb 20, 2024
6fdeb47
vote outbound tests
lumtis Feb 20, 2024
70671b6
Merge branch 'develop' into refactor/outbound-inbound-validation
lumtis Feb 20, 2024
e5cecb5
update changelog
lumtis Feb 20, 2024
cda061b
test with integration tests
lumtis Feb 21, 2024
3e08a1d
add isNew in vote_inbound
lumtis Feb 21, 2024
78c3c0c
add tests back
lumtis Feb 21, 2024
76e2198
use tmp context for ballot logic
lumtis Feb 21, 2024
a68155c
conflicts
lumtis Feb 26, 2024
342f90c
Merge branch 'develop' into refactor/outbound-inbound-validation
lumtis Feb 27, 2024
db00ba1
Merge branch 'develop' into refactor/outbound-inbound-validation
lumtis Feb 27, 2024
e039531
add new test for finalized ballot
lumtis Feb 28, 2024
580e897
add not finzalized test
lumtis Feb 28, 2024
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
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 @@

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

Check warning on line 78 in common/chain.go

View check run for this annotation

Codecov / codecov/patch

common/chain.go#L78

Added line #L78 was not covered by tests
}

// DecodeAddressFromChainID decode the address string to bytes
func DecodeAddressFromChainID(chainID int64, addr string) ([]byte, error) {
if IsEVMChain(chainID) {

Check warning on line 83 in common/chain.go

View check run for this annotation

Codecov / codecov/patch

common/chain.go#L82-L83

Added lines #L82 - L83 were not covered by tests
return ethcommon.HexToAddress(addr).Bytes(), nil
} else if IsBitcoinChain(chain.ChainId) {
} else if IsBitcoinChain(chainID) {

Check warning on line 85 in common/chain.go

View check run for this annotation

Codecov / codecov/patch

common/chain.go#L85

Added line #L85 was not covered by tests
return []byte(addr), nil
}
return nil, fmt.Errorf("chain (%d) not supported", chain.ChainId)
return nil, fmt.Errorf("chain (%d) not supported", chainID)

Check warning on line 88 in common/chain.go

View check run for this annotation

Codecov / codecov/patch

common/chain.go#L88

Added line #L88 was not covered by tests
}

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
Loading