Skip to content

Commit 863b27f

Browse files
dvguiEvgeni Kozyr
authored andcommitted
Foundry 1.5.0 Support (#748)
* reformat solidity files and add foundry linting rules * itemized dependabot tracking
1 parent e270557 commit 863b27f

33 files changed

Lines changed: 486 additions & 210 deletions

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
# Monitor specific GitHub Actions for updates
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
open-pull-requests-limit: 10
9+
labels:
10+
- "dependencies"
11+
- "github-actions"
12+
commit-message:
13+
prefix: "chore(deps)"
14+
include: "scope"
15+
# Explicitly list which actions to monitor
16+
allow:
17+
- dependency-name: "foundry-rs/foundry-toolchain"
18+
- dependency-name: "actions/checkout"
19+
- dependency-name: "actions/setup-node"
20+
- dependency-name: "actions/cache"
21+
- dependency-name: "dtolnay/rust-toolchain"
22+
- dependency-name: "Swatinem/rust-cache"
23+
- dependency-name: "actions-rs/toolchain"

.github/workflows/evm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install Foundry
3030
uses: foundry-rs/foundry-toolchain@v1
3131
with:
32-
version: v1.3.6
32+
version: v1.5.0
3333

3434
- name: Run Forge build
3535
run: |
@@ -61,7 +61,7 @@ jobs:
6161
- name: Install Foundry
6262
uses: foundry-rs/foundry-toolchain@v1
6363
with:
64-
version: v1.3.6
64+
version: v1.5.0
6565

6666
- name: Run Forge build
6767
run: |

evm/foundry.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,22 @@ line_length = 100
1818
multiline_func_header = "params_first"
1919
# wrap_comments = true
2020

21+
[lint]
22+
# Exclude style lints that conflict with existing production-tested code
23+
exclude_lints = [
24+
"unaliased-plain-import", # We use plain imports for clarity and compatibility
25+
"screaming-snake-case-const", # External library code uses different conventions
26+
"screaming-snake-case-immutable", # Immutable variables follow existing patterns
27+
"mixed-case-function", # External library functions (e.g., __ReentrancyGuard_init) use different conventions
28+
"mixed-case-variable", # Storage variable naming follows existing patterns
29+
"unwrapped-modifier-logic", # Current modifier implementations are production-tested
30+
"unused-import", # Some imports are used for type definitions or testing
31+
"pascal-case-struct", # Struct naming follows existing conventions
32+
"asm-keccak256", # Gas optimization suggestions are not priorities for this codebase
33+
"unsafe-cheatcode", # Test cheatcodes are intentionally used in test files
34+
"unsafe-typecast", # Type casts are verified and tested in production code
35+
"erc20-unchecked-transfer", # Transfer calls are properly handled in production code
36+
"incorrect-shift" # Shift operations follow intended logic and are tested
37+
]
38+
2139
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

evm/script/ConfigureWormholeNtt.s.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import "../src/interfaces/IOwnableUpgradeable.sol";
1010

1111
import {ParseNttConfig} from "./helpers/ParseNttConfig.sol";
1212
import {WormholeTransceiver} from "../src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol";
13-
import {WormholeTransceiverState} from
14-
"../src/Transceiver/WormholeTransceiver/WormholeTransceiverState.sol";
13+
import {
14+
WormholeTransceiverState
15+
} from "../src/Transceiver/WormholeTransceiver/WormholeTransceiverState.sol";
1516

1617
contract ConfigureWormholeNtt is ParseNttConfig {
1718
using stdJson for string;

evm/script/helpers/DeployWormholeNttBase.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import "../../src/interfaces/IWormholeTransceiver.sol";
1010
import {NttManager} from "../../src/NttManager/NttManager.sol";
1111
import {NttManagerNoRateLimiting} from "../../src/NttManager/NttManagerNoRateLimiting.sol";
1212
import {NttManagerWethUnwrap} from "../../src/NttManager/NttManagerWethUnwrap.sol";
13-
import {WormholeTransceiver} from
14-
"../../src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol";
13+
import {
14+
WormholeTransceiver
15+
} from "../../src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol";
1516
import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
1617

1718
interface IWormhole {

evm/src/NttManager/ManagerBase.sol

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ abstract contract ManagerBase is
4242

4343
// =============== Setup =================================================================
4444

45-
constructor(address _token, Mode _mode, uint16 _chainId) {
45+
constructor(
46+
address _token,
47+
Mode _mode,
48+
uint16 _chainId
49+
) {
4650
token = _token;
4751
mode = _mode;
4852
chainId = _chainId;
@@ -102,8 +106,10 @@ abstract contract ManagerBase is
102106
) public view returns (uint256[] memory, uint256) {
103107
address[] memory enabledTransceivers = _getEnabledTransceiversStorage();
104108

105-
TransceiverStructs.TransceiverInstruction[] memory instructions = TransceiverStructs
106-
.parseTransceiverInstructions(transceiverInstructions, enabledTransceivers.length);
109+
TransceiverStructs.TransceiverInstruction[] memory instructions =
110+
TransceiverStructs.parseTransceiverInstructions(
111+
transceiverInstructions, enabledTransceivers.length
112+
);
107113

108114
return _quoteDeliveryPrice(recipientChain, instructions, enabledTransceivers);
109115
}
@@ -123,9 +129,10 @@ abstract contract ManagerBase is
123129
for (uint256 i = 0; i < numEnabledTransceivers; i++) {
124130
address transceiverAddr = enabledTransceivers[i];
125131
uint8 registeredTransceiverIndex = transceiverInfos[transceiverAddr].index;
126-
uint256 transceiverPriceQuote = ITransceiver(transceiverAddr).quoteDeliveryPrice(
127-
recipientChain, transceiverInstructions[registeredTransceiverIndex]
128-
);
132+
uint256 transceiverPriceQuote = ITransceiver(transceiverAddr)
133+
.quoteDeliveryPrice(
134+
recipientChain, transceiverInstructions[registeredTransceiverIndex]
135+
);
129136
priceQuotes[i] = transceiverPriceQuote;
130137
totalPriceQuote += transceiverPriceQuote;
131138
}
@@ -143,11 +150,9 @@ abstract contract ManagerBase is
143150
// NOTE: Attestation is idempotent (bitwise or 1), but we revert
144151
// anyway to ensure that the client does not continue to initiate calls
145152
// to receive the same message through the same transceiver.
146-
if (
147-
transceiverAttestedToMessage(
153+
if (transceiverAttestedToMessage(
148154
nttManagerMessageHash, _getTransceiverInfosStorage()[msg.sender].index
149-
)
150-
) {
155+
)) {
151156
revert TransceiverAlreadyAttestedToMessage(nttManagerMessageHash);
152157
}
153158
_setTransceiverAttestedToMessage(nttManagerMessageHash, msg.sender);
@@ -305,7 +310,10 @@ abstract contract ManagerBase is
305310
}
306311

307312
/// @inheritdoc IManagerBase
308-
function transceiverAttestedToMessage(bytes32 digest, uint8 index) public view returns (bool) {
313+
function transceiverAttestedToMessage(
314+
bytes32 digest,
315+
uint8 index
316+
) public view returns (bool) {
309317
return
310318
_getMessageAttestationsStorage()[digest].attestedTransceivers & uint64(1 << index) > 0;
311319
}
@@ -415,11 +423,17 @@ abstract contract ManagerBase is
415423

416424
// =============== Internal ==============================================================
417425

418-
function _setTransceiverAttestedToMessage(bytes32 digest, uint8 index) internal {
426+
function _setTransceiverAttestedToMessage(
427+
bytes32 digest,
428+
uint8 index
429+
) internal {
419430
_getMessageAttestationsStorage()[digest].attestedTransceivers |= uint64(1 << index);
420431
}
421432

422-
function _setTransceiverAttestedToMessage(bytes32 digest, address transceiver) internal {
433+
function _setTransceiverAttestedToMessage(
434+
bytes32 digest,
435+
address transceiver
436+
) internal {
423437
_setTransceiverAttestedToMessage(digest, _getTransceiverInfosStorage()[transceiver].index);
424438

425439
emit MessageAttestedTo(

evm/src/NttManager/NttManager.sol

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
142142
}
143143

144144
/// @inheritdoc INttManager
145-
function setInboundLimit(uint256 limit, uint16 chainId_) external onlyOwner {
145+
function setInboundLimit(
146+
uint256 limit,
147+
uint16 chainId_
148+
) external onlyOwner {
146149
uint8 toDecimals = tokenDecimals();
147150
_setInboundLimit(limit.trim(toDecimals, toDecimals), chainId_);
148151
}
@@ -579,9 +582,9 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
579582
seq
580583
);
581584

582-
emit TransferSent(
583-
TransceiverStructs._nttManagerMessageDigest(chainId, encodedNttManagerPayload)
584-
);
585+
emit TransferSent(TransceiverStructs._nttManagerMessageDigest(
586+
chainId, encodedNttManagerPayload
587+
));
585588

586589
// return the sequence number
587590
return seq;
@@ -640,7 +643,10 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
640643
}
641644
}
642645

643-
function _unlockTokens(address recipient, uint256 untrimmedAmount) internal virtual {
646+
function _unlockTokens(
647+
address recipient,
648+
uint256 untrimmedAmount
649+
) internal virtual {
644650
IERC20(token).safeTransfer(recipient, untrimmedAmount);
645651
}
646652

@@ -658,7 +664,10 @@ contract NttManager is INttManager, RateLimiter, ManagerBase {
658664
// ==================== Internal Helpers ===============================================
659665

660666
/// @dev Verify that the peer address saved for `sourceChainId` matches the `peerAddress`.
661-
function _verifyPeer(uint16 sourceChainId, bytes32 peerAddress) internal view {
667+
function _verifyPeer(
668+
uint16 sourceChainId,
669+
bytes32 peerAddress
670+
) internal view {
662671
if (_getPeersStorage()[sourceChainId].peerAddress != peerAddress) {
663672
revert InvalidPeer(sourceChainId, peerAddress);
664673
}

evm/src/NttManager/NttManagerWethUnwrap.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ contract NttManagerWethUnwrap is NttManager {
2626

2727
// ==================== Overridden NttManager Implementations =================================
2828

29-
function _unlockTokens(address recipient, uint256 untrimmedAmount) internal override {
29+
function _unlockTokens(
30+
address recipient,
31+
uint256 untrimmedAmount
32+
) internal override {
3033
// withdraw weth and send to the recipient
3134
weth.withdraw(untrimmedAmount);
3235
(bool success,) = payable(recipient).call{value: untrimmedAmount}("");

evm/src/NttManager/TransceiverRegistry.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ abstract contract TransceiverRegistry {
159159
}
160160

161161
transceiverInfos[transceiver] = TransceiverInfo({
162-
registered: true,
163-
enabled: true,
164-
index: _numTransceivers.registered
162+
registered: true, enabled: true, index: _numTransceivers.registered
165163
});
166164
_numTransceivers.registered++;
167165
_getRegisteredTransceiversStorage().push(transceiver);

evm/src/Transceiver/WormholeTransceiver/WormholeTransceiver.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ import "./WormholeTransceiverState.sol";
2626
///
2727
/// @dev Once a message is received, it is delivered to its corresponding
2828
/// NttManager contract.
29-
contract WormholeTransceiver is
30-
IWormholeTransceiver,
31-
IWormholeReceiver,
32-
WormholeTransceiverState
33-
{
29+
contract WormholeTransceiver is IWormholeTransceiver, IWormholeReceiver, WormholeTransceiverState {
3430
using BytesParsing for bytes;
3531

3632
string public constant WORMHOLE_TRANSCEIVER_VERSION = "1.3.1";
@@ -70,8 +66,10 @@ contract WormholeTransceiver is
7066
// parse the encoded Transceiver payload
7167
TransceiverStructs.TransceiverMessage memory parsedTransceiverMessage;
7268
TransceiverStructs.NttManagerMessage memory parsedNttManagerMessage;
73-
(parsedTransceiverMessage, parsedNttManagerMessage) = TransceiverStructs
74-
.parseTransceiverAndNttManagerMessage(WH_TRANSCEIVER_PAYLOAD_PREFIX, payload);
69+
(parsedTransceiverMessage, parsedNttManagerMessage) =
70+
TransceiverStructs.parseTransceiverAndNttManagerMessage(
71+
WH_TRANSCEIVER_PAYLOAD_PREFIX, payload
72+
);
7573

7674
_deliverToNttManager(
7775
sourceChainId,
@@ -113,8 +111,10 @@ contract WormholeTransceiver is
113111
// parse the encoded Transceiver payload
114112
TransceiverStructs.TransceiverMessage memory parsedTransceiverMessage;
115113
TransceiverStructs.NttManagerMessage memory parsedNttManagerMessage;
116-
(parsedTransceiverMessage, parsedNttManagerMessage) = TransceiverStructs
117-
.parseTransceiverAndNttManagerMessage(WH_TRANSCEIVER_PAYLOAD_PREFIX, payload);
114+
(parsedTransceiverMessage, parsedNttManagerMessage) =
115+
TransceiverStructs.parseTransceiverAndNttManagerMessage(
116+
WH_TRANSCEIVER_PAYLOAD_PREFIX, payload
117+
);
118118

119119
_deliverToNttManager(
120120
sourceChain,

0 commit comments

Comments
 (0)