Skip to content

Commit

Permalink
WIP: fixed gas price report; withdraw tx still fails
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 committed Jul 5, 2024
1 parent 8b1dffe commit cd5a2ee
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
7 changes: 4 additions & 3 deletions e2e/e2etests/test_solana_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,17 @@ 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)
}
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)
Expand Down
29 changes: 29 additions & 0 deletions zetaclient/chains/solana/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"sync"
"time"

sdkmath "cosmossdk.io/math"
"github.com/davecgh/go-spew/spew"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}
}
}
3 changes: 2 additions & 1 deletion zetaclient/zetacore/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ func GasPriceMultiplier(chain chains.Chain) (float64, error) {
return clientcommon.EVMOutboundGasPriceMultiplier, nil
} else if chain.IsBitcoinChain() {
return clientcommon.BTCOutboundGasPriceMultiplier, nil
} else {

Check failure on line 69 in zetaclient/zetacore/tx.go

View workflow job for this annotation

GitHub Actions / lint

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
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
Expand Down

0 comments on commit cd5a2ee

Please sign in to comment.