Skip to content

Add Migration.sol action upgrade contract #15

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Conversation

zacshowa
Copy link
Member

@zacshowa zacshowa commented Jul 31, 2024

This PR:

This PR adds an initial upgrade action contract that will point a rollups ChallengeManager at a new OSPEntry to allow it to function with the espresso network. Additionally the EspressoMigration.sol contract will point the rollups e to the new value needed after the migration.

This PR does not:

Add a test for the scheduled upgrade as that needs to be tested outside of solidity.

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/utils/Address.sol";

contract{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you are missing the name of the contract here

address currentOspEntry
) public{
//Handle assertions in the perform functoin as we shouldn't be storing local state for delegated calls.
require(newWasmModuleRoot != bytes32(0), "_newWasmModuleRoot cannot be empty");
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think we should use custom errors to save gas as we have quite a lot of require's here

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that this would be rather helpful to reduce the gas used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think for these contracts the gas usage is not of much concern because each chain only does the upgrade once, and we can just go for whatever is simplest to write.

import "../precompiles/ArbOwner.sol";

contract SetEspressoChainConfig {
function perform(string calldata serialiazedEspressoConfig) public {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can anyone call this function or should we add some access control here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The setChainConfig function has built in access control, but I think it could be beneficial to add some additional access control to this function as well.

I think a good approach would be to add a custom error and a revert based on the ArbOwner.isChainOwner function.

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/utils/Address.sol";

contract Migration{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be named something like ChallengeManagerUpgrader or can it upgrade other contract as well?

Copy link
Member Author

@zacshowa zacshowa Aug 8, 2024

Choose a reason for hiding this comment

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

I agree that the contract should be renamed. Likely in line with README.md from this repo

@zacshowa zacshowa marked this pull request as ready for review August 8, 2024 01:28
@zacshowa zacshowa requested a review from nomaxg as a code owner August 8, 2024 01:28

import "../precompiles/ArbOwner.sol";

contract ScheduleEspressoUpgrade {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you considered re-using what's here: https://github.com/OffchainLabs/orbit-actions/tree/main/scripts/foundry/arbos-upgrades/at-timestamp? I wonder if it would make sense to fork the orbit-actions repo instead of putting the contracts into this repo.

Copy link
Member Author

@zacshowa zacshowa Aug 8, 2024

Choose a reason for hiding this comment

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

I think it might be beneficial to have a fork of the orbit-actions repo for the migration. I don't believe we need to include them in the integration repo like I had originally expected.

If we do decide to move these contracts to a fork of the orbit-action repo we can just close this PR correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I made a fork here: https://github.com/EspressoSystems/orbit-actions i think you can make a PR in that repo and reference this PR in the new one.

import "@openzeppelin/contracts/utils/Address.sol";

contract EspressoMigration{
function perform(
Copy link
Collaborator

Choose a reason for hiding this comment

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

In https://github.com/OffchainLabs/orbit-actions/blob/dc54bae1c40faefb4cdfff82af321cccb9b89a6e/contracts/parent-chain/contract-upgrades/NitroContracts1Point2Point1UpgradeAction.sol#L31

There are some "constants" that are set in the constructor instead of having everything passed to perform. I think this makes sense because someone can then deploy then deploy a correctly configured action contract (setting the correct wasm root and OSP implementation) and the the rollup owner only needs to pass what is custom to the rollup.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that we should put as much into the constructor as possible. I suppose the question then becomes what constants we can set in the constructor? To me it seems like we could set the new OSP implememtation address in the constructor, and I'm tempted to say the wasmModuleRoot.

However, there is a case that has me concerned. What if an orbit chain has some pre-existing changes to their STF that they want to merge with ours? If we declare an immutable wasmModuleRoot in the constructor, suddenly we can't use the deployed contract to help upgrade this hypothetical orbit chain as the wasmModuleRoot might be different when merging their changes with ours.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That rollup would then have to deploy their own upgrade action where they set the root as needed.

import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import "@openzeppelin/contracts/utils/Address.sol";

contract EspressoMigration{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants