Skip to content

Commit e3a6b97

Browse files
committed
feedback
1 parent 7984c2d commit e3a6b97

File tree

4 files changed

+35
-39
lines changed

4 files changed

+35
-39
lines changed

packages/protocol/contracts/bridge/Bridge.sol

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,9 @@ contract Bridge is EssentialContract, IBridge {
358358
whenNotPaused
359359
sameChain(message.destChainId)
360360
{
361-
// If isLastAttempt is true, the caller must be the message.owner.
362-
// TODO(Brecht): why not allow anyone to call when message.gasLimit == 0?
363-
// There is no fee to be earned, and there won't be any gas limit anyway.
364-
if (isLastAttempt) {
361+
// If the gasLimit is set to 0 or isLastAttempt is true, the caller must
362+
// be the message.owner.
363+
if (message.gasLimit == 0 || isLastAttempt) {
365364
if (msg.sender != message.owner) revert B_PERMISSION_DENIED();
366365
}
367366

@@ -544,37 +543,13 @@ contract Bridge is EssentialContract, IBridge {
544543
}
545544
}
546545

547-
/// @notice Checks if the signal was received.
548-
/// @param signalService The signalService
549-
/// @param signal The signal.
550-
/// @param chainId The ID of the chain the signal is stored on
551-
/// @param proof The merkle inclusion proof.
552-
/// @return True if the message was received.
553-
function _proveSignalReceived(
554-
address signalService,
555-
bytes32 signal,
556-
uint64 chainId,
557-
bytes calldata proof
558-
)
559-
private
560-
view
561-
returns (bool)
562-
{
563-
bytes memory data = abi.encodeCall(
564-
ISignalService.proveSignalReceived,
565-
(chainId, resolve(chainId, "bridge", false), signal, proof)
566-
);
567-
(bool success, bytes memory ret) = signalService.staticcall(data);
568-
return success ? abi.decode(ret, (bool)) : false;
569-
}
570-
571546
/// @notice Resets the call context
572-
function _resetContext() internal {
547+
function _resetContext() private {
573548
_storeContext(bytes32(0), address(0), uint64(0));
574549
}
575550

576551
/// @notice Stores the call context
577-
function _storeContext(bytes32 msgHash, address from, uint64 srcChainId) internal {
552+
function _storeContext(bytes32 msgHash, address from, uint64 srcChainId) private {
578553
assembly {
579554
tstore(_CTX_SLOT, msgHash)
580555
tstore(add(_CTX_SLOT, 1), from)
@@ -583,7 +558,7 @@ contract Bridge is EssentialContract, IBridge {
583558
}
584559

585560
/// @notice Loads the call context
586-
function _loadContext() internal view returns (Context memory) {
561+
function _loadContext() private view returns (Context memory) {
587562
bytes32 msgHash;
588563
address from;
589564
uint64 srcChainId;
@@ -594,4 +569,28 @@ contract Bridge is EssentialContract, IBridge {
594569
}
595570
return Context({ msgHash: msgHash, from: from, srcChainId: srcChainId });
596571
}
572+
573+
/// @notice Checks if the signal was received.
574+
/// @param signalService The signalService
575+
/// @param signal The signal.
576+
/// @param chainId The ID of the chain the signal is stored on
577+
/// @param proof The merkle inclusion proof.
578+
/// @return True if the message was received.
579+
function _proveSignalReceived(
580+
address signalService,
581+
bytes32 signal,
582+
uint64 chainId,
583+
bytes calldata proof
584+
)
585+
private
586+
view
587+
returns (bool)
588+
{
589+
bytes memory data = abi.encodeCall(
590+
ISignalService.proveSignalReceived,
591+
(chainId, resolve(chainId, "bridge", false), signal, proof)
592+
);
593+
(bool success, bytes memory ret) = signalService.staticcall(data);
594+
return success ? abi.decode(ret, (bool)) : false;
595+
}
597596
}

packages/protocol/contracts/common/OwnerUUPSUpgradable.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ abstract contract OwnerUUPSUpgradable is UUPSUpgradeable, OwnableUpgradeable {
9393
}
9494

9595
// Stores the reentry lock
96-
function _storeReentryLock(uint8 reentry) internal {
96+
function _storeReentryLock(uint8 reentry) private {
9797
assembly {
9898
tstore(_REENTRY_SLOT, reentry)
9999
}
100100
}
101101

102102
// Loads the reentry lock
103-
function _loadReentryLock() internal view returns (uint8 reentry) {
103+
function _loadReentryLock() private view returns (uint8 reentry) {
104104
assembly {
105105
reentry := tload(_REENTRY_SLOT)
106106
}

packages/protocol/contracts/tokenvault/BridgedERC20Base.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ abstract contract BridgedERC20Base is EssentialContract, IBridgedERC20 {
8585
return super.owner();
8686
}
8787

88+
function _mintToken(address account, uint256 amount) internal virtual;
89+
function _burnToken(address from, uint256 amount) internal virtual;
90+
8891
function _isMigratingOut() internal view returns (bool) {
8992
return migratingAddress != address(0) && !migratingInbound;
9093
}
91-
92-
function _mintToken(address account, uint256 amount) internal virtual;
93-
function _burnToken(address from, uint256 amount) internal virtual;
9494
}

packages/protocol/contracts/tokenvault/ERC20Vault.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ contract ERC20Vault is BaseVault {
131131

132132
btokenOld = canonicalToBridged[ctoken.chainId][ctoken.addr];
133133

134-
// TODO(Brecht): if the ctoken is on the current chain, should we check the
135-
// symbol/name/decimals against the actual token?
136-
137134
if (btokenOld != address(0)) {
138135
CanonicalERC20 memory _ctoken = bridgedToCanonical[btokenOld];
139136

0 commit comments

Comments
 (0)