Skip to content

Commit

Permalink
switch back to L1Gas
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Mar 11, 2024
1 parent ae27b98 commit e3db4b2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 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")
}

txm.lggr.Infow("Fee estimate", "unit", friEstimate.FeeUnit)
txm.lggr.Infow("Fee estimate", "in units", friEstimate.FeeUnit)

// pad estimate to 140% (add extra because estimate did not include validation)
// pad estimate to 120% (add extra because estimate did not include validation)
gasConsumed := friEstimate.GasConsumed.BigInt(new(big.Int))
expandedGas := new(big.Int).Mul(gasConsumed, big.NewInt(140))
expandedGas := new(big.Int).Mul(gasConsumed, big.NewInt(120))
maxGas := new(big.Int).Div(expandedGas, big.NewInt(100))
tx.ResourceBounds.L2Gas.MaxAmount = starknetrpc.U64(starknetutils.BigIntToFelt(maxGas).String())
tx.ResourceBounds.L1Gas.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.L2Gas.MaxPricePerUnit = starknetrpc.U128(starknetutils.BigIntToFelt(maxGasPrice).String())
tx.ResourceBounds.L1Gas.MaxPricePerUnit = starknetrpc.U128(starknetutils.BigIntToFelt(maxGasPrice).String())

txm.lggr.Infow("Set resource bounds", "L2MaxAmount", tx.ResourceBounds.L2Gas.MaxAmount, "L2MaxPricePerUnit", tx.ResourceBounds.L2Gas.MaxPricePerUnit)
txm.lggr.Infow("Set resource bounds", "L1MaxAmount", tx.ResourceBounds.L1Gas.MaxAmount, "L1MaxPricePerUnit", tx.ResourceBounds.L1Gas.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 e3db4b2

Please sign in to comment.