Skip to content

Commit

Permalink
set l2 instead of l1 gas info
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Mar 11, 2024
1 parent 5dfb386 commit 4d7f0ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions relayer/pkg/chainlink/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,21 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun
return txhash, fmt.Errorf("failed to get FRI estimate")
}

// TODO: does v3 tx uses fri instead of wei? check feeEstimate[0].FeeUnit?
txm.lggr.Infow("Fee estimate token units", friEstimate.FeeUnit)

// pad estimate to 140% (add extra because estimate did not include validation)
gasConsumed := friEstimate.GasConsumed.BigInt(new(big.Int))
expandedGas := new(big.Int).Mul(gasConsumed, big.NewInt(140))
maxGas := new(big.Int).Div(expandedGas, big.NewInt(100))
tx.ResourceBounds.L1Gas.MaxAmount = starknetrpc.U64(starknetutils.BigIntToFelt(maxGas).String())
tx.ResourceBounds.L2Gas.MaxAmount = starknetrpc.U64(starknetutils.BigIntToFelt(maxGas).String())

// pad by 120%
gasPrice := friEstimate.GasPrice.BigInt(new(big.Int))
expandedGasPrice := new(big.Int).Mul(gasPrice, big.NewInt(120))
maxGasPrice := new(big.Int).Div(expandedGasPrice, big.NewInt(100))
tx.ResourceBounds.L1Gas.MaxPricePerUnit = starknetrpc.U128(starknetutils.BigIntToFelt(maxGasPrice).String())
tx.ResourceBounds.L2Gas.MaxPricePerUnit = starknetrpc.U128(starknetutils.BigIntToFelt(maxGasPrice).String())

txm.lggr.Infow("Set resource bounds", "L1MaxAmount", tx.ResourceBounds.L1Gas.MaxAmount, "L1MaxPricePerUnit", tx.ResourceBounds.L1Gas.MaxPricePerUnit)
txm.lggr.Infow("Set resource bounds", "L2MaxAmount", tx.ResourceBounds.L2Gas.MaxAmount, "L2MaxPricePerUnit", tx.ResourceBounds.L2Gas.MaxPricePerUnit)

// Re-sign transaction now that we've determined MaxFee
// TODO: SignInvokeTransaction for V3 is missing so we do it by hand
Expand Down

0 comments on commit 4d7f0ec

Please sign in to comment.