Skip to content

Commit 0eb22b3

Browse files
committed
minor
1 parent ef49fb1 commit 0eb22b3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

pkg/ccip/bindings/feequoter/fee_quoter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ type UpdateFeeTokens struct {
274274
// UpdateTokenTransferFeeConfig is a value type stored in a dictionary, NOT a message.
275275
// It represents per-destination-chain token transfer fee config updates.
276276
type UpdateTokenTransferFeeConfig struct {
277-
Add *tlbe.Dict[uint64, TokenTransferFeeConfig] `tlb:"."` // map<address, TokenTransferFeeConfig>
278-
Remove common.SnakedCell[common.AddressWrap] `tlb:"^"` // SnakedCell<address>
277+
Add *tlbe.Dict[uint64, TokenTransferFeeConfig] `tlb:"."`
278+
Remove common.SnakedCell[common.AddressWrap] `tlb:"^"`
279279
}
280280

281281
// UpdateTokenTransferFeeConfigs is the message type for updating token transfer fee configs.

pkg/ccip/bindings/feequoter/gaspriceutils.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ var (
1818
ErrNilPackedPrice = errors.New("packed price cannot be nil")
1919
// ErrNegativePackedPrice is returned when a negative packed price is passed to UnpackGasPrice.
2020
ErrNegativePackedPrice = errors.New("packed price cannot be negative")
21+
22+
// Pre-computed bit masks for gas price packing/unpacking
23+
mask112 = maxUint(112) // 2^112 - 1, used for 112-bit values
24+
mask224 = maxUint(224) // 2^224 - 1, used for 224-bit packed values
2125
)
2226

2327
// maxUint returns 2^bits - 1, which is the maximum value for an unsigned integer of the given bit length.
@@ -43,10 +47,10 @@ func PackGasPrice(executionGasPrice, dataAvailabilityGasPrice *big.Int) (*big.In
4347
if executionGasPrice.Sign() < 0 || dataAvailabilityGasPrice.Sign() < 0 {
4448
return nil, ErrNegativeGasPrice
4549
}
46-
if executionGasPrice.Cmp(maxUint(112)) > 0 {
50+
if executionGasPrice.Cmp(mask112) > 0 {
4751
return nil, ErrGasPriceExceeds112Bits
4852
}
49-
if dataAvailabilityGasPrice.Cmp(maxUint(112)) > 0 {
53+
if dataAvailabilityGasPrice.Cmp(mask112) > 0 {
5054
return nil, ErrGasPriceExceeds112Bits
5155
}
5256

@@ -74,11 +78,11 @@ func UnpackGasPrice(packedPrice *big.Int) (executionGasPrice, dataAvailabilityGa
7478
if packedPrice.Sign() < 0 {
7579
return nil, nil, ErrNegativePackedPrice
7680
}
77-
if packedPrice.Cmp(maxUint(224)) > 0 {
81+
if packedPrice.Cmp(mask224) > 0 {
7882
return nil, nil, ErrPackedPriceExceeds224Bits
7983
}
8084

81-
executionGasPrice = new(big.Int).And(packedPrice, maxUint(112))
85+
executionGasPrice = new(big.Int).And(packedPrice, mask112)
8286
dataAvailabilityGasPrice = new(big.Int).Rsh(packedPrice, 112)
8387

8488
return executionGasPrice, dataAvailabilityGasPrice, nil

0 commit comments

Comments
 (0)