fix panic

This commit is contained in:
Solovyov1796 2024-05-01 16:56:23 +08:00
parent d7101481c0
commit de94f36095
3 changed files with 140 additions and 20 deletions

1
.gitignore vendored
View File

@ -41,3 +41,4 @@ build/linux
# Go workspace files # Go workspace files
go.work go.work
go.work.sum go.work.sum
.build/0gchaind

119
localtestnet.sh Executable file
View File

@ -0,0 +1,119 @@
#! /bin/bash
set -e
validatorMnemonic="equip town gesture square tomorrow volume nephew minute witness beef rich gadget actress egg sing secret pole winter alarm law today check violin uncover"
# kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c
# kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0
faucetMnemonic="crash sort dwarf disease change advice attract clump avoid mobile clump right junior axis book fresh mask tube front require until face effort vault"
# kava1adkm6svtzjsxxvg7g6rshg6kj9qwej8gwqadqd
evmFaucetMnemonic="hundred flash cattle inquiry gorilla quick enact lazy galaxy apple bitter liberty print sun hurdle oak town cash because round chalk marriage response success"
# 0x3C854F92F726A7897C8B23F55B2D6E2C482EF3E0
# kava18jz5lyhhy6ncjlyty064kttw93yzaulq7rlptu
userMnemonic="news tornado sponsor drastic dolphin awful plastic select true lizard width idle ability pigeon runway lift oppose isolate maple aspect safe jungle author hole"
# 0x7Bbf300890857b8c241b219C6a489431669b3aFA
# kava10wlnqzyss4accfqmyxwx5jy5x9nfkwh6qm7n4t
relayerMnemonic="never reject sniff east arctic funny twin feed upper series stay shoot vivid adapt defense economy pledge fetch invite approve ceiling admit gloom exit"
# 0xa2F728F997f62F47D4262a70947F6c36885dF9fa
# kava15tmj37vh7ch504px9fcfglmvx6y9m70646ev8t
DATA=~/.0gchain
# remove any old state and config
rm -rf $DATA
BINARY=0gchaind
# Create new data directory, overwriting any that alread existed
chainID="zgchain_8888-1"
$BINARY init validator --chain-id $chainID
# hacky enable of rest api
sed -in-place='' 's/enable = false/enable = true/g' $DATA/config/app.toml
# Set evm tracer to json
sed -in-place='' 's/tracer = ""/tracer = "json"/g' $DATA/config/app.toml
# Enable full error trace to be returned on tx failure
sed -in-place='' '/iavl-cache-size/a\
trace = true' $DATA/config/app.toml
# Set client chain id
sed -in-place='' 's/chain-id = ""/chain-id = "zgchain_8888-1"/g' $DATA/config/client.toml
# avoid having to use password for keys
$BINARY config keyring-backend test
# Create validator keys and add account to genesis
validatorKeyName="validator"
printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --recover
$BINARY add-genesis-account $validatorKeyName 2000000000000000000000neuron
# Create faucet keys and add account to genesis
faucetKeyName="faucet"
printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --recover
$BINARY add-genesis-account $faucetKeyName 1000000000000000000000neuron
evmFaucetKeyName="evm-faucet"
printf "$evmFaucetMnemonic\n" | $BINARY keys add $evmFaucetKeyName --eth --recover
$BINARY add-genesis-account $evmFaucetKeyName 1000000000000000000000neuron
userKeyName="user"
printf "$userMnemonic\n" | $BINARY keys add $userKeyName --eth --recover
$BINARY add-genesis-account $userKeyName 1000000000000000000000neuron,1000000000usdx
relayerKeyName="relayer"
printf "$relayerMnemonic\n" | $BINARY keys add $relayerKeyName --eth --recover
$BINARY add-genesis-account $relayerKeyName 1000000000000000000000neuron
storageContractAcc="0g1vsjpjgw8p5f4x0nwp8ernl9lkszewcqqss7r5d"
$BINARY add-genesis-account $storageContractAcc 1000000000000000000000neuron
# Create a delegation tx for the validator and add to genesis
$BINARY gentx $validatorKeyName 1000000000000000000000neuron --keyring-backend test --chain-id $chainID
$BINARY collect-gentxs
# Replace stake with ukava
sed -in-place='' 's/stake/neuron/g' $DATA/config/genesis.json
# Replace the default evm denom of aphoton with neuron
sed -in-place='' 's/aphoton/neuron/g' $DATA/config/genesis.json
GENESIS=$DATA/config/genesis.json
TMP_GENESIS=$DATA/config/tmp_genesis.json
cat $GENESIS | jq '.consensus_params.block.max_gas = "25000000"' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# Zero out the total supply so it gets recalculated during InitGenesis
cat $GENESIS | jq '.app_state.bank.supply = []' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# Disable fee market
cat $GENESIS | jq '.app_state.feemarket.params.no_base_fee = true' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# Disable london fork
cat $GENESIS | jq '.app_state.evm.params.chain_config.london_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.evm.params.chain_config.arrow_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.evm.params.chain_config.gray_glacier_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.evm.params.chain_config.merge_netsplit_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.evm.params.chain_config.shanghai_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
cat $GENESIS | jq '.app_state.evm.params.chain_config.cancun_block = null' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# Add earn vault
# cat $GENESIS | jq '.app_state.earn.params.allowed_vaults = [
# {
# denom: "usdx",
# strategies: ["STRATEGY_TYPE_HARD"],
# },
# {
# denom: "bkava",
# strategies: ["STRATEGY_TYPE_SAVINGS"],
# }]' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
# cat $GENESIS | jq '.app_state.savings.params.supported_denoms = ["bkava-kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0"]' >$TMP_GENESIS && mv $TMP_GENESIS $GENESIS
$BINARY config broadcast-mode sync
$BINARY start --home $DATA

View File

@ -52,28 +52,28 @@ func init() {
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
// Proposals // Proposals
cdc.RegisterInterface((*PubProposal)(nil), nil) cdc.RegisterInterface((*PubProposal)(nil), nil)
cdc.RegisterConcrete(CommitteeChangeProposal{}, "0gchain/CommitteeChangeProposal", nil) cdc.RegisterConcrete(CommitteeChangeProposal{}, "0g-chain/CommitteeChangeProposal", nil)
cdc.RegisterConcrete(CommitteeDeleteProposal{}, "0gchain/CommitteeDeleteProposal", nil) cdc.RegisterConcrete(CommitteeDeleteProposal{}, "0g-chain/CommitteeDeleteProposal", nil)
// Committees // Committees
cdc.RegisterInterface((*Committee)(nil), nil) cdc.RegisterInterface((*Committee)(nil), nil)
cdc.RegisterConcrete(BaseCommittee{}, "0gchain/BaseCommittee", nil) cdc.RegisterConcrete(BaseCommittee{}, "0g-chain/BaseCommittee", nil)
cdc.RegisterConcrete(MemberCommittee{}, "0gchain/MemberCommittee", nil) cdc.RegisterConcrete(MemberCommittee{}, "0g-chain/MemberCommittee", nil)
cdc.RegisterConcrete(TokenCommittee{}, "0gchain/TokenCommittee", nil) cdc.RegisterConcrete(TokenCommittee{}, "0g-chain/TokenCommittee", nil)
// Permissions // Permissions
cdc.RegisterInterface((*Permission)(nil), nil) cdc.RegisterInterface((*Permission)(nil), nil)
cdc.RegisterConcrete(GodPermission{}, "0gchain/GodPermission", nil) cdc.RegisterConcrete(GodPermission{}, "0g-chain/GodPermission", nil)
cdc.RegisterConcrete(TextPermission{}, "0gchain/TextPermission", nil) cdc.RegisterConcrete(TextPermission{}, "0g-chain/TextPermission", nil)
cdc.RegisterConcrete(SoftwareUpgradePermission{}, "0gchain/SoftwareUpgradePermission", nil) cdc.RegisterConcrete(SoftwareUpgradePermission{}, "0g-chain/SoftwareUpgradePermission", nil)
cdc.RegisterConcrete(ParamsChangePermission{}, "0gchain/ParamsChangePermission", nil) cdc.RegisterConcrete(ParamsChangePermission{}, "0g-chain/ParamsChangePermission", nil)
cdc.RegisterConcrete(CommunityCDPRepayDebtPermission{}, "0gchain/CommunityCDPRepayDebtPermission", nil) cdc.RegisterConcrete(CommunityCDPRepayDebtPermission{}, "0g-chain/CommunityCDPRepayDebtPermission", nil)
cdc.RegisterConcrete(CommunityCDPWithdrawCollateralPermission{}, "0gchain/CommunityCDPWithdrawCollateralPermission", nil) cdc.RegisterConcrete(CommunityCDPWithdrawCollateralPermission{}, "0g-chain/CommunityCDPWithdrawCollateralPermission", nil)
cdc.RegisterConcrete(CommunityPoolLendWithdrawPermission{}, "0gchain/CommunityPoolLendWithdrawPermission", nil) cdc.RegisterConcrete(CommunityPoolLendWithdrawPermission{}, "0g-chain/CommunityPoolLendWithdrawPermission", nil)
// Msgs // Msgs
legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "0gchain/MsgSubmitProposal") legacy.RegisterAminoMsg(cdc, &MsgSubmitProposal{}, "0g-chain/MsgSubmitProposal")
legacy.RegisterAminoMsg(cdc, &MsgVote{}, "0gchain/MsgVote") legacy.RegisterAminoMsg(cdc, &MsgVote{}, "0g-chain/MsgVote")
} }
// RegisterProposalTypeCodec allows external modules to register their own pubproposal types on the // RegisterProposalTypeCodec allows external modules to register their own pubproposal types on the
@ -91,7 +91,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
registry.RegisterInterface( registry.RegisterInterface(
"0gchain.committee.v1beta1.Committee", "0g-chain.committee.v1beta1.Committee",
(*Committee)(nil), (*Committee)(nil),
&BaseCommittee{}, &BaseCommittee{},
&TokenCommittee{}, &TokenCommittee{},
@ -99,21 +99,21 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
) )
registry.RegisterInterface( registry.RegisterInterface(
"0gchain.committee.v1beta1.Permission", "0g-chain.committee.v1beta1.Permission",
(*Permission)(nil), (*Permission)(nil),
&GodPermission{}, &GodPermission{},
&TextPermission{}, &TextPermission{},
&SoftwareUpgradePermission{}, &SoftwareUpgradePermission{},
&ParamsChangePermission{}, &ParamsChangePermission{},
&CommunityCDPRepayDebtPermission{}, // &CommunityCDPRepayDebtPermission{},
&CommunityCDPWithdrawCollateralPermission{}, // &CommunityCDPWithdrawCollateralPermission{},
&CommunityPoolLendWithdrawPermission{}, // &CommunityPoolLendWithdrawPermission{},
) )
// Need to register PubProposal here since we use this as alias for the x/gov Content interface for all the proposal implementations used in this module. // Need to register PubProposal here since we use this as alias for the x/gov Content interface for all the proposal implementations used in this module.
// Note that all proposals supported by x/committee needed to be registered here, including the proposals from x/gov. // Note that all proposals supported by x/committee needed to be registered here, including the proposals from x/gov.
registry.RegisterInterface( registry.RegisterInterface(
"0gchain.committee.v1beta1.PubProposal", "0g-chain.committee.v1beta1.PubProposal",
(*PubProposal)(nil), (*PubProposal)(nil),
&Proposal{}, &Proposal{},
&distrtypes.CommunityPoolSpendProposal{}, &distrtypes.CommunityPoolSpendProposal{},