From cd5a2ee30ecac39ba7c0fdd9da24bd0f8434475b Mon Sep 17 00:00:00 2001 From: brewmaster012 <88689859+brewmaster012@users.noreply.github.com> Date: Fri, 5 Jul 2024 02:14:00 -0500 Subject: [PATCH] WIP: fixed gas price report; withdraw tx still fails --- e2e/e2etests/test_solana_deposit.go | 7 +++-- zetaclient/chains/solana/observer/observer.go | 29 +++++++++++++++++++ zetaclient/zetacore/tx.go | 3 +- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/e2e/e2etests/test_solana_deposit.go b/e2e/e2etests/test_solana_deposit.go index 1854883d8a..c8e8e9025b 100644 --- a/e2e/e2etests/test_solana_deposit.go +++ b/e2e/e2etests/test_solana_deposit.go @@ -250,7 +250,7 @@ func TestSolanaWithdraw(r *runner.E2ERunner, args []string) { r.Logger.Print("TestSolanaWithdraw...sol zrc20 %s", r.SOLZRC20Addr.String()) solZRC20 := r.SOLZRC20 - supply, err := solZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress()) + supply, err := solZRC20.BalanceOf(&bind.CallOpts{}, r.ZEVMAuth.From) if err != nil { r.Logger.Error("Error getting total supply of sol zrc20: %v", err) panic(err) @@ -258,8 +258,9 @@ func TestSolanaWithdraw(r *runner.E2ERunner, args []string) { r.Logger.Print(" supply of %s sol zrc20: %d", r.EVMAddress(), supply) amount := big.NewInt(1337) - - tx, err := r.SOLZRC20.Approve(r.ZEVMAuth, r.SOLZRC20Addr, amount) + approveAmount := big.NewInt(1e18) + //r.Logger.Print("Approving %s sol zrc20 to spend %d", r.ZEVMAuth.From.Hex(), approveAmount) + tx, err := r.SOLZRC20.Approve(r.ZEVMAuth, r.SOLZRC20Addr, approveAmount) require.NoError(r, err) receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) utils.RequireTxSuccessful(r, receipt) diff --git a/zetaclient/chains/solana/observer/observer.go b/zetaclient/chains/solana/observer/observer.go index fcf2556cd7..5cb66dc169 100644 --- a/zetaclient/chains/solana/observer/observer.go +++ b/zetaclient/chains/solana/observer/observer.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "fmt" "sync" + "time" sdkmath "cosmossdk.io/math" "github.com/davecgh/go-spew/spew" @@ -64,6 +65,8 @@ func NewObserver( //ob.coreContext = appContext.ZetacoreContext() ob.chainParams = chainParams + // FIXME: config this + ob.chain = chains.SolanaLocalnet ob.stop = make(chan struct{}) ob.Mu = &sync.Mutex{} ob.zetacoreClient = zetacoreClient @@ -135,6 +138,8 @@ func (o *Observer) WatchInboundTracker() { func (o *Observer) Start() { o.logger.Info().Msgf("observer starting...") go o.WatchInbound() + go o.WatchGasPrice() + } func (o *Observer) Stop() { @@ -262,3 +267,27 @@ func (o *Observer) ObserveInbound() error { } return nil } + +func (o *Observer) WatchGasPrice() { + ticker := time.NewTicker(10 * time.Second) + defer ticker.Stop() + for { + select { + case <-ticker.C: + slot, err := o.solanaClient.GetSlot(context.Background(), rpc.CommitmentConfirmed) + if err != nil { + o.logger.Err(err).Msg("GetSlot error") + continue + } + txhash, err := o.zetacoreClient.PostGasPrice(o.chain, 1, "", slot) + if err != nil { + o.logger.Err(err).Msg("PostGasPrice error") + continue + } + o.logger.Info().Msgf("gas price posted: %s", txhash) + case <-o.stop: + o.logger.Info().Msgf("WatchGasPrice stopped for chain %d", o.chain.ChainId) + return + } + } +} diff --git a/zetaclient/zetacore/tx.go b/zetaclient/zetacore/tx.go index 2ef142d03f..647af5d603 100644 --- a/zetaclient/zetacore/tx.go +++ b/zetaclient/zetacore/tx.go @@ -66,8 +66,9 @@ func GasPriceMultiplier(chain chains.Chain) (float64, error) { return clientcommon.EVMOutboundGasPriceMultiplier, nil } else if chain.IsBitcoinChain() { return clientcommon.BTCOutboundGasPriceMultiplier, nil + } else { + return 1.0, nil // default to 1x multiplier, why not? } - return 0, fmt.Errorf("cannot get gas price multiplier for unknown chain %d", chain.ChainId) } // WrapMessageWithAuthz wraps a message with an authz message