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

test: initialize simulation tests for custom zetachain modules #3095

Merged
merged 38 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9369869
add crosschain decoders
kingpinXD Oct 24, 2024
873153d
decoders test
kingpinXD Oct 28, 2024
422d03b
add oeprations
kingpinXD Oct 31, 2024
39d9863
add fungible deploy contracts
kingpinXD Oct 31, 2024
84d2089
add fungible deploy contracts
kingpinXD Nov 1, 2024
5d68917
add simulation for observer module
kingpinXD Nov 5, 2024
c4dfcd7
add comments for crosschain operations
kingpinXD Nov 5, 2024
fa1234f
add comments for observer and fungible operations
kingpinXD Nov 5, 2024
9e3c7b3
rebase develop
kingpinXD Nov 6, 2024
9f976c0
generate files
kingpinXD Nov 7, 2024
bacd4b2
debug import export test
kingpinXD Nov 7, 2024
2b0509a
fix import export tests
kingpinXD Nov 7, 2024
d03ed5f
fix import export tests
kingpinXD Nov 7, 2024
7070211
fix app determinism test
kingpinXD Nov 8, 2024
cda3f22
update codecov.yml
kingpinXD Nov 8, 2024
9172df7
reduce weight for DeployedSystemContracts operation
kingpinXD Nov 8, 2024
8526eab
add new function to generate eth address from provided randomness
kingpinXD Nov 8, 2024
ea92069
Update x/fungible/simulation/decoders.go
kingpinXD Nov 8, 2024
977a22c
Update testutil/sample/sample.go
kingpinXD Nov 8, 2024
863cf0b
add validations
kingpinXD Nov 8, 2024
44abb89
add validations
kingpinXD Nov 8, 2024
94ecd5e
add randmoness to tss
kingpinXD Nov 8, 2024
13f919f
make requested changes 1
kingpinXD Nov 13, 2024
4975947
update state.go file
kingpinXD Nov 13, 2024
eea9fd4
update state.go file
kingpinXD Nov 13, 2024
083d861
change chains.IsEVMChain to chains.IsEthereumChain in deposit tests
kingpinXD Nov 14, 2024
fb0a626
add decoder for tss history
kingpinXD Nov 14, 2024
524b377
remove unnecessary todo
kingpinXD Nov 14, 2024
626b9c8
remove unnecessary todo
kingpinXD Nov 14, 2024
5861bc3
remove unused keys
kingpinXD Nov 15, 2024
d9dd460
Update simulation/simulation_test.go
kingpinXD Dec 9, 2024
cbce35b
fix comments and remove unused functions
kingpinXD Dec 10, 2024
256d013
Merge remote-tracking branch 'origin/crosschain-simulation-params' in…
kingpinXD Dec 10, 2024
8963569
fix comments and remove unused functions
kingpinXD Dec 10, 2024
8470009
improve comment wording for operation weights
kingpinXD Dec 10, 2024
98bab57
improve comment wording for operation weights
kingpinXD Dec 10, 2024
1167862
rebase develop
kingpinXD Dec 11, 2024
a05339e
rebase develop
kingpinXD Dec 11, 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
Prev Previous commit
Next Next commit
add new function to generate eth address from provided randomness
kingpinXD committed Nov 8, 2024

Verified

This commit was signed with the committer’s verified signature.
kingpinXD Tanmay
commit 8526eab5a9ac027c24c91519492a5a42b8e9df7d
17 changes: 17 additions & 0 deletions simulation/state.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@ import (
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
"github.com/zeta-chain/node/testutil/sample"
fungibletypes "github.com/zeta-chain/node/x/fungible/types"

zetaapp "github.com/zeta-chain/node/app"
authoritytypes "github.com/zeta-chain/node/x/authority/types"
@@ -203,12 +205,27 @@ func AppStateFn(
}
authorityState.Policies = policies

//Update the fungible genesis state
fungibleStateBz, ok := rawState[fungibletypes.ModuleName]
if !ok {
panic("fungible genesis state is missing")
}
fungibleState := new(fungibletypes.GenesisState)
cdc.MustUnmarshalJSON(fungibleStateBz, fungibleState)
// TOODO generate ethereum address from r
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
fungibleState.SystemContract = &fungibletypes.SystemContract{
SystemContract: sample.EthAddressRandom(r).String(),
ConnectorZevm: sample.EthAddressRandom(r).String(),
Gateway: sample.EthAddressRandom(r).String(),
}

// change appState back
rawState[evmtypes.ModuleName] = cdc.MustMarshalJSON(evmState)
rawState[stakingtypes.ModuleName] = cdc.MustMarshalJSON(stakingState)
rawState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankState)
rawState[observertypes.ModuleName] = cdc.MustMarshalJSON(observerState)
rawState[authoritytypes.ModuleName] = cdc.MustMarshalJSON(authorityState)
rawState[fungibletypes.ModuleName] = cdc.MustMarshalJSON(fungibleState)

// replace appstate
appState, err = json.Marshal(rawState)
9 changes: 5 additions & 4 deletions testutil/sample/crosschain.go
Original file line number Diff line number Diff line change
@@ -299,11 +299,12 @@ func InboundVote(coinType coin.CoinType, from, to int64) types.MsgVoteInbound {

// InboundVoteSim creates a simulated inbound vote message. This function uses the provided source of randomness to generate
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
func InboundVoteSim(coinType coin.CoinType, from, to int64, r *rand.Rand) types.MsgVoteInbound {
EthAddress()
return types.MsgVoteInbound{
Creator: "",
Sender: "0x388C818CA8B9251b393131C08a736A67ccB19297",
Sender: EthAddressRandom(r).String(),
SenderChainId: from,
Receiver: "0x388C818CA8B9251b393131C08a736A67ccB19297",
Receiver: EthAddressRandom(r).String(),
ReceiverChain: to,
Amount: math.NewUint(r.Uint64()),
Message: base64.StdEncoding.EncodeToString(RandomBytes(r)),
@@ -313,8 +314,8 @@ func InboundVoteSim(coinType coin.CoinType, from, to int64, r *rand.Rand) types.
},
InboundHash: ethcommon.BytesToHash(RandomBytes(r)).String(),
CoinType: coinType,
TxOrigin: "0x388C818CA8B9251b393131C08a736A67ccB19297",
Asset: "",
TxOrigin: EthAddressRandom(r).String(),
Asset: StringRandom(r, 32),
EventIndex: r.Uint64(),
}
}
5 changes: 5 additions & 0 deletions testutil/sample/crypto.go
Original file line number Diff line number Diff line change
@@ -60,6 +60,11 @@ func EthAddress() ethcommon.Address {
return ethcommon.BytesToAddress(sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()).Bytes())
}

func EthAddressRandom(r *rand.Rand) ethcommon.Address {
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
return ethcommon.BytesToAddress(sdk.AccAddress(PubKey(r).Address()).Bytes())

}

// BtcAddressP2WPKH returns a sample btc P2WPKH address
func BtcAddressP2WPKH(t *testing.T, net *chaincfg.Params) string {
privateKey, err := btcec.NewPrivateKey()
2 changes: 1 addition & 1 deletion x/fungible/simulation/operations.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ import (
const (
// #nosec G101 not a hardcoded credential
OpWeightMsgDeploySystemContracts = "op_weight_msg_deploy_system_contracts"
DefaultWeightMsgDeploySystemContracts = 10
DefaultWeightMsgDeploySystemContracts = 5
)

// DeployedSystemContracts Use a flag to ensure that the system contracts are deployed only once
5 changes: 1 addition & 4 deletions x/fungible/types/genesis.go
Original file line number Diff line number Diff line change
@@ -8,10 +8,7 @@ import (
func DefaultGenesis() *GenesisState {
return &GenesisState{
ForeignCoinsList: []ForeignCoins{},
SystemContract: &SystemContract{
SystemContract: "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921",
ConnectorZevm: "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67",
},
SystemContract: &SystemContract{},
}
}

2 changes: 1 addition & 1 deletion x/observer/simulation/operations.go
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ const (
// to ensure that it is present in the block more number of times than any operation that changes the validator set

// Arrived at this number based on the weights used in the cosmos sdk staking module and through some trial and error
DefaultWeightMsgTypeMsgEnableCCTX = 2650
DefaultWeightMsgTypeMsgEnableCCTX = 3650
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
)

// WeightedOperations for observer module