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

feat(contracts): registry updates #278

Merged
merged 54 commits into from
Oct 16, 2024

Conversation

mempirate
Copy link
Contributor

@mempirate mempirate commented Oct 7, 2024

@mempirate mempirate changed the base branch from unstable to nico/feat/commitment-registry October 7, 2024 13:34
.gitmodules Outdated Show resolved Hide resolved
Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

small nits, overall I love the design and how much it simplifies our current middlewares. great!

bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltManager.sol Show resolved Hide resolved
bolt-contracts/src/contracts/BoltManager.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltManager.sol Outdated Show resolved Hide resolved
@mempirate mempirate marked this pull request as ready for review October 15, 2024 09:01
Copy link
Contributor

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

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

Amazing work! Just some notes

Copy link
Contributor

Choose a reason for hiding this comment

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

Just one performance consideration: we're already concerned about the gas usage of the challenger and while some of these variables should be upgradable, some of them instead are pretty much known and immutable once the contract has been deployed.
In particular those are the ones that don't require an admin method:

  • EPOCH_DURATION
  • SLASHING_WINDOW
  • ETH2_GENESIS_TIMESTAMP
  • SLOT_TIME.
    These are used in the Challenger contract via a static call that consumes more gas than it should. I'd personally prefer rely on those via a library whose constant values are set manually before deploying. Ugly yes, but we can get around it with a script reminding us to do that before deploying.

Copy link
Collaborator

@merklefruit merklefruit Oct 15, 2024

Choose a reason for hiding this comment

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

One note is that gas usage in the challenger is way less of a concern than the registry.

I think this is fine as is for this use case.

fwiw, there is much lower hanging fruit for optimizing the opening / resolution process than this, so I suggest leaving it here as it makes the whole deployment simpler!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. My thinking was that other contracts might also need these values, but we can have a BoltConstants library per network (mainnet, holesky, helder, ...) that we can just use in all those contracts. Will update!

bolt-contracts/src/contracts/BoltManager.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltManager.sol Outdated Show resolved Hide resolved
bolt-contracts/test/BoltChallenger.t.sol Outdated Show resolved Hide resolved
bolt-contracts/test/BoltManager.EigenLayer.t.sol Outdated Show resolved Hide resolved
bolt-contracts/test/BoltManager.Symbiotic.t.sol Outdated Show resolved Hide resolved
testnets/holesky/.cb.env Outdated Show resolved Hide resolved
testnets/holesky/cb.docker-compose.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

Looking very good!

@@ -22,26 +30,41 @@ contract BoltChallenger is IBoltChallenger {

// ========= STORAGE =========

/// @notice Bolt Parameters contract.
IBoltParameters public parameters;

/// @notice The set of existing unique challenge IDs.
EnumerableSet.Bytes32Set internal challengeIDs;
Copy link
Collaborator

Choose a reason for hiding this comment

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

note: when counting storage layout, each variable should be counted for the amount of storage it uses.
In this case, EnumerableSet.Bytes32Set is defined as Set under the hood:

    struct Set {
        bytes32[] _values;
        mapping(bytes32 value => uint256) _positions;
    }

this occupies 2 slots: 1 for the array (pointer to its mem address) and 1 for the mapping.
reference: https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#mappings-and-dynamic-arrays

so TL;DR: storage layout marker would be 4 instead of 3 slots here. I didn't check other contracts but this is a good check to make everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Validated all storage layouts with forge inspect BoltParameters storage-layout --pretty

Added instructions on how to do it in the contract natspec documentation. The OpenZeppelin foundry upgrades toolkit can also validate it every time we do a new deployment.

bolt-contracts/src/contracts/BoltManager.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltParameters.sol Outdated Show resolved Hide resolved
@merklefruit merklefruit linked an issue Oct 16, 2024 that may be closed by this pull request
@mempirate mempirate linked an issue Oct 16, 2024 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@merklefruit merklefruit left a comment

Choose a reason for hiding this comment

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

LGTM

@mempirate mempirate merged commit c2df22e into nico/feat/commitment-registry Oct 16, 2024
5 checks passed
@mempirate mempirate deleted the jonas/feat/registry-updates branch October 16, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: smart-contracts Component: smart contracts T: feature Type: Feature
Projects
None yet
3 participants