Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit b3b8493

Browse files
authored
Remove float. (#54)
1 parent bec014e commit b3b8493

18 files changed

+175
-1760
lines changed

.env.example

Lines changed: 0 additions & 7 deletions
This file was deleted.

run-migration.sh

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/utils/GasUtils.sol renamed to src/GasUtils.sol

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
pragma solidity >=0.8.20;
55

6-
import {UFloat9x56, UFloatMath} from "./Float9x56.sol";
7-
import {BranchlessMath} from "./BranchlessMath.sol";
6+
import {BranchlessMath} from "./utils/BranchlessMath.sol";
87

98
/**
109
* @dev Utilities for compute the GMP gas price, gas cost and gas needed.
@@ -43,7 +42,7 @@ library GasUtils {
4342
/**
4443
* @dev Base cost of the `IExecutor.execute` method.
4544
*/
46-
uint256 internal constant EXECUTION_BASE_COST = EXECUTION_SELECTOR_OVERHEAD + 46960 + 264 + 2180;
45+
uint256 internal constant EXECUTION_BASE_COST = EXECUTION_SELECTOR_OVERHEAD + 46960 + 69 + 2180;
4746

4847
/**
4948
* @dev Solidity's reserved location for the free memory pointer.
@@ -110,26 +109,6 @@ library GasUtils {
110109
}
111110
}
112111

113-
/**
114-
* @dev Estimate the price in wei for send an GMP message.
115-
* @param gasPrice The gas price in UFloat9x56 format.
116-
* @param baseFee The base fee in wei.
117-
* @param nonZeros The number of non-zero bytes in the gmp data.
118-
* @param zeros The number of zero bytes in the gmp data.
119-
* @param gasLimit The message gas limit.
120-
*/
121-
function estimateWeiCost(UFloat9x56 gasPrice, uint256 baseFee, uint16 nonZeros, uint16 zeros, uint256 gasLimit)
122-
internal
123-
pure
124-
returns (uint256)
125-
{
126-
// Add execution cost
127-
uint256 gasCost = estimateGas(nonZeros, zeros, gasLimit);
128-
129-
// Calculate the gas cost: gasPrice * gasCost + baseFee
130-
return UFloatMath.saturatingMul(gasPrice, gasCost).saturatingAdd(baseFee);
131-
}
132-
133112
/**
134113
* @dev Estimate the gas cost of a GMP message.
135114
* @param dataNonZeros The number of non-zero bytes in the gmp data.

src/Gateway.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
pragma solidity >=0.8.0;
55

66
import {Hashing} from "./utils/Hashing.sol";
7-
import {Schnorr} from "./utils/Schnorr.sol";
7+
import {Schnorr} from "../lib/frost-evm/sol/Schnorr.sol";
88
import {BranchlessMath} from "./utils/BranchlessMath.sol";
9-
import {GasUtils} from "./utils/GasUtils.sol";
10-
import {UFloat9x56, UFloatMath} from "./utils/Float9x56.sol";
9+
import {GasUtils} from "./GasUtils.sol";
1110
import {RouteStore} from "./storage/Routes.sol";
1211
import {ShardStore} from "./storage/Shards.sol";
1312
import {IGateway} from "./interfaces/IGateway.sol";
@@ -65,7 +64,6 @@ contract Gateway is IGateway, GatewayEIP712, UUPSUpgradeable, OwnableUpgradeable
6564
using PrimitiveUtils for GmpCallback;
6665
using PrimitiveUtils for address;
6766
using BranchlessMath for uint256;
68-
using UFloatMath for UFloat9x56;
6967
using ShardStore for ShardStore.MainStorage;
7068
using RouteStore for RouteStore.MainStorage;
7169
using RouteStore for RouteStore.NetworkInfo;
@@ -200,7 +198,7 @@ contract Gateway is IGateway, GatewayEIP712, UUPSUpgradeable, OwnableUpgradeable
200198
_checkGmpMessage(gmp);
201199
// Convert the `GmpMessage` into `GmpCallback`, which is a more efficient representation.
202200
// see `src/Primitives.sol` for more details.
203-
GmpCallback memory callback = gmp.intoCallback();
201+
GmpCallback memory callback = gmp.toCallback();
204202
operationHash = callback.opHash;
205203
_execute(callback);
206204
}
@@ -462,7 +460,7 @@ contract Gateway is IGateway, GatewayEIP712, UUPSUpgradeable, OwnableUpgradeable
462460

463461
// Convert the `GmpMessage` into `GmpCallback`, which is a more efficient representation.
464462
// see `src/Primitives.sol` for more details.
465-
GmpCallback memory callback = message.intoCallback();
463+
GmpCallback memory callback = message.toCallback();
466464

467465
// Verify the TSS Schnorr Signature
468466
_verifySignature(signature, callback.opHash);

0 commit comments

Comments
 (0)