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

fix(zetaclient): tolerate priorityFee > gasFee #2950

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion zetaclient/chains/evm/signer/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ func gasFromCCTX(cctx *types.CrossChainTx, logger zerolog.Logger) (Gas, error) {
case err != nil:
return Gas{}, errors.Wrap(err, "unable to parse priorityFee")
case gasPrice.Cmp(priorityFee) == -1:
swift1337 marked this conversation as resolved.
Show resolved Hide resolved
return Gas{}, fmt.Errorf("gasPrice (%d) is less than priorityFee (%d)", gasPrice.Int64(), priorityFee.Int64())
logger.Warn().
Str("cctx.initial_priority_fee", priorityFee.String()).
Str("cctx.forced_priority_fee", gasPrice.String()).
Msg("gasPrice is less than priorityFee, setting priorityFee = gasPrice")

priorityFee = big.NewInt(0).Set(gasPrice)
}

return Gas{
Expand Down
13 changes: 10 additions & 3 deletions zetaclient/chains/evm/signer/gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ func TestGasFromCCTX(t *testing.T) {
errorContains: "unable to parse priorityFee: big.Int is negative",
},
{
name: "gasPrice is less than priorityFee",
cctx: makeCCTX(123_000, gwei(4).String(), gwei(5).String()),
errorContains: "gasPrice (4000000000) is less than priorityFee (5000000000)",
name: "gasPrice is less than priorityFee",
cctx: makeCCTX(123_000, gwei(4).String(), gwei(5).String()),
assert: func(t *testing.T, g Gas) {
assert.False(t, g.isLegacy())
assertGasEquals(t, Gas{
Limit: 123_000,
Price: gwei(4),
PriorityFee: gwei(4),
}, g)
},
},
{
name: "gasPrice is invalid",
Expand Down
Loading