Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeating committed Feb 12, 2024
1 parent cac5979 commit 5fb57cd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/WormholeL1ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ contract WormholeL1ERC20Bridge is WormholeL1VotePool, WormholeSender, WormholeRe
L2_TOKEN_ADDRESS,
mintCalldata,
0, // no receiver value needed since we're just passing a message
GAS_LIMIT,
gasLimit,
REFUND_CHAIN,
msg.sender
);
Expand Down
2 changes: 1 addition & 1 deletion src/WormholeL1GovernorMetadataBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract WormholeL1GovernorMetadataBridge is WormholeSender {
L2_GOVERNOR_ADDRESS,
proposalCalldata,
0, // no receiver value needed since we're just passing a message
GAS_LIMIT,
gasLimit,
REFUND_CHAIN,
msg.sender
);
Expand Down
2 changes: 1 addition & 1 deletion src/WormholeL2ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ contract WormholeL2ERC20 is ERC20Votes, WormholeReceiver, WormholeSender {
L1_BRIDGE_ADDRESS,
withdrawCalldata,
0, // no receiver value needed since we're just passing a message
GAS_LIMIT,
gasLimit,
REFUND_CHAIN,
msg.sender
);
Expand Down
2 changes: 1 addition & 1 deletion src/WormholeL2VoteAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contract WormholeL2VoteAggregator is WormholeSender, L2VoteAggregator, WormholeL
L1_BRIDGE_ADDRESS,
proposalCalldata,
0, // no receiver value needed since we're just passing a message
GAS_LIMIT,
gasLimit,
REFUND_CHAIN,
msg.sender
);
Expand Down
17 changes: 12 additions & 5 deletions src/WormholeSender.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ abstract contract WormholeSender is WormholeBase {
uint16 public immutable REFUND_CHAIN;

/// @notice The gas limit for cross chain transactions.
uint256 public GAS_LIMIT = 200_000;
uint256 public gasLimit = 200_000;

/// @notice Emitted when the gas limit has been updated
/// @param oldValue The old gas limit value.
/// @param newValue The new gas limit value.
/// @param caller The address changing the gas limit.
event GasLimitUpdate(uint256 oldValue, uint256 newValue, address caller);

/// @param _refundChain The chain id of the chain sending the messages.
/// @param _targetChain The chain id of the chain receiving the messages.
Expand All @@ -22,12 +28,13 @@ abstract contract WormholeSender is WormholeBase {

/// @param targetChain The chain id of the chain receiving the messages.
function quoteDeliveryCost(uint16 targetChain) public view virtual returns (uint256 cost) {
(cost,) = WORMHOLE_RELAYER.quoteEVMDeliveryPrice(targetChain, 0, GAS_LIMIT);
(cost,) = WORMHOLE_RELAYER.quoteEVMDeliveryPrice(targetChain, 0, gasLimit);
}

/// @param gasLimit The new gas limit value which is used to estimate the delivery cost for
/// @param _gasLimit The new gas limit value which is used to estimate the delivery cost for
/// sending messages cross chain.
function updateGasLimit(uint256 gasLimit) public onlyOwner {
GAS_LIMIT = gasLimit;
function updateGasLimit(uint256 _gasLimit) public onlyOwner {
emit GasLimitUpdate(gasLimit, _gasLimit, msg.sender);
gasLimit = _gasLimit;
}
}
5 changes: 3 additions & 2 deletions test/WormholeBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {WormholeBase} from "src/WormholeBase.sol";
import {TestConstants} from "test/Constants.sol";

contract Constructor is Test, TestConstants {
function testForkFuzz_CorrectlySetsAllArgs(address _wormholeRelayer) public {
WormholeBase base = new WormholeBase(_wormholeRelayer, msg.sender);
function testForkFuzz_CorrectlySetsAllArgs(address _wormholeRelayer, address _owner) public {
WormholeBase base = new WormholeBase(_wormholeRelayer, _owner);

assertEq(
address(base.WORMHOLE_RELAYER()), _wormholeRelayer, "Wormhole relayer is not set correctly"
);
assertEq(address(base.owner()), _owner, "Contract ownewr is incorrect");
}
}
12 changes: 11 additions & 1 deletion test/WormholeSender.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ contract WormholeSenderHarness is WormholeSender {
contract WormholeSenderTest is TestConstants, WormholeRelayerBasicTest {
WormholeSender wormholeSender;

event GasLimitUpdate(uint256 oldValue, uint256 newValue, address caller);

constructor() {
setForkChains(TESTNET, L1_CHAIN.wormholeChainId, L2_CHAIN.wormholeChainId);
}
Expand Down Expand Up @@ -64,7 +66,15 @@ contract QuoteDeliveryCost is WormholeSenderTest {

contract UpdateGasLimit is WormholeSenderTest {
function testFuzz_CorrectlyUpdateGasLimit(uint256 gasLimit) public {
vm.expectEmit();
emit GasLimitUpdate(200_000, gasLimit, address(this));

wormholeSender.updateGasLimit(gasLimit);
assertEq(wormholeSender.gasLimit(), gasLimit, "The gas limit is incorrect");
}

function testFuzz_RevertIf_CalledByNonOwner(address owner, uint256 gasLimit) public {
vm.prank(owner);
wormholeSender.updateGasLimit(gasLimit);
assertEq(wormholeSender.GAS_LIMIT(), gasLimit, "The gas limit is incorrect");
}
}

0 comments on commit 5fb57cd

Please sign in to comment.