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

Commit e8315c4

Browse files
authored
Gmpv3 p2 (#63)
1 parent 083bb20 commit e8315c4

18 files changed

+30
-48
lines changed

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ forge-std = "1.9.7"
8080
"@openzeppelin-contracts-upgradeable" = "5.3.0"
8181
"@openzeppelin-contracts" = "5.3.0"
8282
frost-evm = { version = "0.1.0", git = "https://github.com/Analog-Labs/frost-evm.git", rev = "63a217a8d0a6f186dab69f070ea45c28099885df" }
83-
gmp = "0.0.1"
83+
gmp = { version = "0.0.1", path = "../gmp" }
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/gmp/src/IGateway.sol renamed to gmp/src/IGateway.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ interface IGateway {
1414
* @param destinationAddress the target address on the destination chain.
1515
* @param destinationNetwork the target chain where the contract call will be made.
1616
* @param gasLimit the gas limit available for the contract call
17-
* @param gasCost the gas limit available for the contract call
1817
* @param nonce Sequence number per sender, used to guarantee each message is unique.
1918
* @param data message data with no specified format
2019
*/
@@ -24,7 +23,6 @@ interface IGateway {
2423
address indexed destinationAddress,
2524
uint16 destinationNetwork,
2625
uint64 gasLimit,
27-
uint64 gasCost,
2826
uint64 nonce,
2927
bytes data
3028
);
File renamed without changes.

remappings.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.3.0/
22
@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.3.0/
3-
forge-std/=dependencies/forge-std-1.9.7/src
4-
frost-evm/=dependencies/frost-evm-0.1.0/
5-
gmp/=dependencies/gmp-0.0.1/
3+
forge-std/=dependencies/forge-std-1.9.7/src/
4+
frost-evm/=dependencies/frost-evm-0.1.0/sol/
5+
gmp/=gmp/src/
66
src/=src/

src/Gateway.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
pragma solidity >=0.8.0;
55

6-
import {Schnorr} from "frost-evm/sol/Schnorr.sol";
6+
import {Schnorr} from "frost-evm/Schnorr.sol";
77
import {GasUtils} from "./GasUtils.sol";
88
import {RouteStore} from "./storage/Routes.sol";
99
import {ShardStore} from "./storage/Shards.sol";
10-
import {IGateway} from "gmp/src/IGateway.sol";
11-
import {IGmpReceiver} from "gmp/src/IGmpReceiver.sol";
10+
import {IGateway} from "gmp/IGateway.sol";
11+
import {IGmpReceiver} from "gmp/IGmpReceiver.sol";
1212
import {
1313
Command,
1414
Batch,
@@ -218,7 +218,7 @@ contract Gateway is IGateway, UUPSUpgradeable, OwnableUpgradeable {
218218

219219
bytes32 messageId = message.messageId();
220220
emit GmpCreated(
221-
messageId, source, destinationAddress, network, gasLimit, uint64(gas), nextNonce, message.data
221+
messageId, source, destinationAddress, network, gasLimit, nextNonce, message.data
222222
);
223223
return messageId;
224224
}
@@ -326,7 +326,7 @@ contract Gateway is IGateway, UUPSUpgradeable, OwnableUpgradeable {
326326
assembly {
327327
publicKey := params.offset
328328
}
329-
operationHash = PrimitiveUtils.hash(publicKey.yParity, publicKey.xCoord);
329+
operationHash = PrimitiveUtils.hash(publicKey.yParity, publicKey.xCoord, publicKey.numSessions);
330330

331331
if (dry) {
332332
return operationHash;
@@ -344,7 +344,7 @@ contract Gateway is IGateway, UUPSUpgradeable, OwnableUpgradeable {
344344
assembly {
345345
publicKey := params.offset
346346
}
347-
operationHash = PrimitiveUtils.hash(publicKey.yParity, publicKey.xCoord);
347+
operationHash = PrimitiveUtils.hash(publicKey.yParity, publicKey.xCoord, publicKey.numSessions);
348348

349349
if (dry) {
350350
return operationHash;

src/GmpProxy.sol

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

44
pragma solidity >=0.8.0;
55

6-
import {IGmpReceiver} from "gmp/src/IGmpReceiver.sol";
7-
import {IGateway} from "gmp/src/IGateway.sol";
6+
import {IGmpReceiver} from "gmp/IGmpReceiver.sol";
7+
import {IGateway} from "gmp/IGateway.sol";
88
import {console} from "forge-std/console.sol";
99

1010
contract GmpProxy is IGmpReceiver {

src/Primitives.sol

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,6 @@ library PrimitiveUtils {
176176
}
177177
}
178178

179-
/**
180-
* @dev Hashes two 256-bit words without memory allocation, uses the memory between 0x00~0x40.
181-
*/
182-
function hash(uint256 a, uint256 b) internal pure returns (bytes32 h) {
183-
assembly ("memory-safe") {
184-
mstore(0x00, a)
185-
mstore(0x20, b)
186-
h := keccak256(0x00, 0x40)
187-
}
188-
}
189-
190179
/**
191180
* @dev Hashes three 256-bit words without memory allocation, uses the memory between 0x00~0x60.
192181
*
@@ -297,12 +286,6 @@ library PrimitiveUtils {
297286
}
298287
}
299288

300-
function opHash(GmpMessage memory message) internal pure returns (bytes32) {
301-
bytes32 msgId = PrimitiveUtils.messageId(message);
302-
bytes32 dataHash = keccak256(message.data);
303-
return keccak256(abi.encode(msgId, dataHash));
304-
}
305-
306289
/**
307290
* @dev Converts the `GmpMessage` into a `GmpCallback` struct, which contains all fields from
308291
* `GmpMessage`, plus the EIP-712 hash and `IGmpReceiver.onGmpReceived` callback.

0 commit comments

Comments
 (0)