diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index bab4924167..0e770b951f 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -139,6 +139,7 @@ func start(_ *cobra.Command, _ []string) error { err := telemetryServer.Start() if err != nil { startLogger.Error().Err(err).Msg("telemetryServer error") + panic("telemetryServer error") } }() diff --git a/contrib/localnet/orchestrator/smoketest/main.go b/contrib/localnet/orchestrator/smoketest/main.go index 9dd12669e0..7d01a5cadf 100644 --- a/contrib/localnet/orchestrator/smoketest/main.go +++ b/contrib/localnet/orchestrator/smoketest/main.go @@ -292,7 +292,7 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { smokeTest.CheckZRC20ReserveAndSupply() smokeTest.TestBitcoinWithdraw() - //smokeTest.CheckZRC20ReserveAndSupply() + smokeTest.CheckZRC20ReserveAndSupply() smokeTest.TestCrosschainSwap() smokeTest.CheckZRC20ReserveAndSupply() diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go index 44a45dacc9..26e43983e3 100644 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go +++ b/x/fungible/keeper/begin_blocker_deploy_system_contracts_mock_mainnet.go @@ -5,9 +5,91 @@ package keeper import ( "context" + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/zeta-chain/zetacore/common" ) -func (k Keeper) BlockOneDeploySystemContracts(_ context.Context) error { +func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { + ctx := sdk.UnwrapSDKContext(goCtx) + + // setup uniswap v2 factory + uniswapV2Factory, err := k.DeployUniswapV2Factory(ctx) + if err != nil { + return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Factory") + } + ctx.EventManager().EmitEvent( + sdk.NewEvent(sdk.EventTypeMessage, + sdk.NewAttribute("UniswapV2Factory", uniswapV2Factory.String()), + ), + ) + + // setup WZETA contract + wzeta, err := k.DeployWZETA(ctx) + if err != nil { + return sdkerrors.Wrapf(err, "failed to DeployWZetaContract") + } + ctx.EventManager().EmitEvent( + sdk.NewEvent(sdk.EventTypeMessage, + sdk.NewAttribute("DeployWZetaContract", wzeta.String()), + ), + ) + + router, err := k.DeployUniswapV2Router02(ctx, uniswapV2Factory, wzeta) + if err != nil { + return sdkerrors.Wrapf(err, "failed to DeployUniswapV2Router02") + } + ctx.EventManager().EmitEvent( + sdk.NewEvent(sdk.EventTypeMessage, + sdk.NewAttribute("DeployUniswapV2Router02", router.String()), + ), + ) + + connector, err := k.DeployConnectorZEVM(ctx, wzeta) + if err != nil { + return sdkerrors.Wrapf(err, "failed to DeployConnectorZEVM") + } + ctx.EventManager().EmitEvent( + sdk.NewEvent(sdk.EventTypeMessage, + sdk.NewAttribute("DeployConnectorZEVM", connector.String()), + ), + ) + ctx.Logger().Info("Deployed Connector ZEVM at " + connector.String()) + + SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) + if err != nil { + return sdkerrors.Wrapf(err, "failed to SystemContractAddress") + } + ctx.EventManager().EmitEvent( + sdk.NewEvent(sdk.EventTypeMessage, + sdk.NewAttribute("SystemContractAddress", SystemContractAddress.String()), + ), + ) + + // set the system contract + system, _ := k.GetSystemContract(ctx) + system.SystemContract = SystemContractAddress.String() + k.SetSystemContract(ctx, system) + //err = k.SetGasPrice(ctx, big.NewInt(1337), big.NewInt(1)) + if err != nil { + return err + } + _, err = k.SetupChainGasCoinAndPool(ctx, common.EthChain().ChainId, "ETH", "ETH", 18) + if err != nil { + return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.EthChain().ChainName)) + } + + _, err = k.SetupChainGasCoinAndPool(ctx, common.BscMainnetChain().ChainId, "BNB", "BNB", 18) + if err != nil { + return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.BscMainnetChain().ChainName)) + } + _, err = k.SetupChainGasCoinAndPool(ctx, common.BtcMainnetChain().ChainId, "BTC", "BTC", 8) + if err != nil { + return errorsmod.Wrapf(err, fmt.Sprintf("failed to setupChainGasCoinAndPool for %s", common.BtcMainnetChain().ChainName)) + } return nil } func (k Keeper) TestUpdateSystemContractAddress(_ context.Context) error { diff --git a/zetaclient/bitcoin_client.go b/zetaclient/bitcoin_client.go index 83e75d5a53..42a31c39dd 100644 --- a/zetaclient/bitcoin_client.go +++ b/zetaclient/bitcoin_client.go @@ -464,13 +464,13 @@ func (ob *BitcoinChainClient) WatchGasPrice() { } func (ob *BitcoinChainClient) PostGasPrice() error { - if ob.chain.ChainId == 18444 { //bitcoin regtest + if ob.chain.ChainId == 18444 { //bitcoin regtest; hardcode here since this RPC is not available on regtest bn, err := ob.rpcClient.GetBlockCount() if err != nil { return err } // #nosec G701 always in range - zetaHash, err := ob.zetaClient.PostGasPrice(ob.chain, 1000, "100", uint64(bn)) + zetaHash, err := ob.zetaClient.PostGasPrice(ob.chain, 1, "100", uint64(bn)) if err != nil { ob.logger.WatchGasPrice.Err(err).Msg("PostGasPrice:") return err @@ -504,8 +504,6 @@ func (ob *BitcoinChainClient) PostGasPrice() error { return err } _ = zetaHash - //ob.logger.WatchGasPrice.Debug().Msgf("PostGasPrice zeta tx: %s", zetaHash) - _ = feeResult return nil } diff --git a/zetaclient/btc_signer.go b/zetaclient/btc_signer.go index ffc0d56a67..f426fee681 100644 --- a/zetaclient/btc_signer.go +++ b/zetaclient/btc_signer.go @@ -120,7 +120,6 @@ func (signer *BTCSigner) SignWithdrawTx(to *btcutil.AddressWitnessPubKeyHash, am // fee calculation // #nosec G701 always in range (checked above) fees := new(big.Int).Mul(big.NewInt(int64(txSize)), gasPrice) - fees.Div(fees, big.NewInt(bytesPerKB)) signer.logger.Info().Msgf("bitcoin outTx nonce %d gasPrice %s size %d fees %s", nonce, gasPrice.String(), txSize, fees.String()) // calculate remaining btc to TSS self