Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom gas token updates #164

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { OptimismMintableERC20Factory } from "src/universal/OptimismMintableERC2
import { OptimismMintableERC721Factory } from "src/universal/OptimismMintableERC721Factory.sol";
import { BaseFeeVault } from "src/L2/BaseFeeVault.sol";
import { L1FeeVault } from "src/L2/L1FeeVault.sol";
import { L2ToL1MessagePasser } from "src/L2/L2ToL1MessagePasser.sol";
import { GovernanceToken } from "src/governance/GovernanceToken.sol";
import { L1CrossDomainMessenger } from "src/L1/L1CrossDomainMessenger.sol";
import { L1StandardBridge } from "src/L1/L1StandardBridge.sol";
Expand Down Expand Up @@ -634,6 +635,13 @@ contract L2Genesis is Deployer {

vm.resetNonce(address(kontract));
_setupProxy(precompile, address(kontract));

console.log("setting L2ToL1MessagePasser");
L2ToL1MessagePasser l2ToL1MessagePasser = L2ToL1MessagePasser(payable(Predeploys.L2_TO_L1_MESSAGE_PASSER));
vm.startPrank(l2ToL1MessagePasser.owner());
l2ToL1MessagePasser.setCeloToken(address(kontract));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this address should be the proxy, not the implementation.

Suggested change
l2ToL1MessagePasser.setCeloToken(address(kontract));
l2ToL1MessagePasser.setCeloToken(precompile);

vm.stopPrank();
console.log("done setting L2ToL1MessagePasser");
}

function setCeloFeeHandler() internal {
Expand Down Expand Up @@ -740,7 +748,7 @@ contract L2Genesis is Deployer {

SortedOracles sortedOracles = SortedOracles(CeloPredeploys.SORTED_ORACLES);

console.log("beofre add oracle");
console.log("before add oracle");

vm.startPrank(sortedOracles.owner());
sortedOracles.addOracle(cusdProxyAddress, deployer);
Expand Down
16 changes: 15 additions & 1 deletion packages/contracts-bedrock/src/L2/L2ToL1MessagePasser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import { Hashing } from "src/libraries/Hashing.sol";
import { Encoding } from "src/libraries/Encoding.sol";
import { Burn } from "src/libraries/Burn.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { ICeloToken } from "src/celo/interfaces/ICeloToken.sol";

/// @custom:proxied
/// @custom:predeploy 0x4200000000000000000000000000000000000016
/// @title L2ToL1MessagePasser
/// @notice The L2ToL1MessagePasser is a dedicated contract where messages that are being sent from
/// L2 to L1 can be stored. The storage root of this contract is pulled up to the top level
/// of the L2 output to reduce the cost of proving the existence of sent messages.
contract L2ToL1MessagePasser is ISemver {
contract L2ToL1MessagePasser is ISemver, Ownable {
/// @notice The L1 gas limit set when eth is withdrawn using the receive() function.
uint256 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;

Expand All @@ -26,6 +28,8 @@ contract L2ToL1MessagePasser is ISemver {
/// @notice A unique value hashed with each withdrawal.
uint240 internal msgNonce;

ICeloToken public celoToken;

/// @notice Emitted any time a withdrawal is initiated.
/// @param nonce Unique value corresponding to each withdrawal.
/// @param sender The L2 account address which initiated the withdrawal.
Expand All @@ -51,6 +55,8 @@ contract L2ToL1MessagePasser is ISemver {
/// @custom:semver 1.1.0
string public constant version = "1.1.0";

constructor() Ownable() {}

/// @notice Allows users to withdraw ETH by sending directly to this contract.
receive() external payable {
initiateWithdrawal(msg.sender, RECEIVE_DEFAULT_GAS_LIMIT, bytes(""));
Expand Down Expand Up @@ -89,6 +95,9 @@ contract L2ToL1MessagePasser is ISemver {
unchecked {
++msgNonce;
}
if (address(celoToken) != address(0)) {
celoToken.withdrawAmount(msg.value);
}
}

/// @notice Retrieves the next message nonce. Message version will be added to the upper two
Expand All @@ -98,4 +107,9 @@ contract L2ToL1MessagePasser is ISemver {
function messageNonce() public view returns (uint256) {
return Encoding.encodeVersionedNonce(msgNonce, MESSAGE_VERSION);
}

/// @notice Sets the Celo token contract address.
function setCeloToken(address _celoToken) external onlyOwner {
celoToken = ICeloToken(_celoToken);
}
}
Loading