Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Split SubnetActor #411

Merged
merged 9 commits into from
Dec 21, 2023
Merged

Split SubnetActor #411

merged 9 commits into from
Dec 21, 2023

Conversation

dnkolegov
Copy link
Contributor

This PR :

  • Splits Subnet Actor manager
  • Fixes Pausable contract

@dnkolegov dnkolegov requested review from raulk and snissn December 21, 2023 11:00
@dnkolegov dnkolegov changed the title WIP: Split SubnetActor Split SubnetActor Dec 21, 2023
Copy link
Contributor

@raulk raulk left a comment

Choose a reason for hiding this comment

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

Generally LGTM, my comments are not blockers (except for the apparent merge snafu) and we can address them in the monorepo.

@@ -49,3 +48,53 @@ interface ISubnetActor {
/// The reword includes the fixed reward for a relayer defined in the contract and `amount` of fees from the cross-messages.
function distributeRewardToRelayers(uint256 height, uint256 amount, QuorumObjKind kind) external payable;
}

interface ISubnetActorXX {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems duplicated, @dnkolegov? Is this a merge snafu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry! will fix

import {LibSubnetActor} from "../lib/LibSubnetActor.sol";
import {Pausable} from "../lib/LibPausable.sol";

contract SubnetActorCheckpointingFacet is SubnetActorModifiers, ReentrancyGuard, Pausable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just drop the SubnetActor prefix from the contract name, since the scope is already implied by the import path? I find it too verbose.

Copy link
Contributor Author

@dnkolegov dnkolegov Dec 21, 2023

Choose a reason for hiding this comment

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

Do you mean renaming to Checkpointingfacet ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then we will have two contracts with the same name: router/Checkpointingfacet and subnet/CheckpointinfFacet

src/subnet/SubnetActorPauseFacet.sol Outdated Show resolved Hide resolved
import {LibStaking} from "../lib/LibStaking.sol";
import {LibSubnetActor} from "../lib/LibSubnetActor.sol";

contract SubnetActorRewardFacet is IRelayerRewardDistributor, SubnetActorModifiers, ReentrancyGuard, Pausable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain the rationale for introducing a new interface here? (IRelayerRewardDistributor)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the same interface actually. We did not need that bif ISubnetActor interface, we needed only one function. I added that one function to IRelayerRewardDistributor

IDiamond.FacetCut({
facetAddress: address(louper),
action: IDiamond.FacetCutAction.Add,
functionSelectors: gwLoupeSelectors
functionSelectors: saLouperSelectors
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these selectors and the cutter selectors sa or gw dependent? They are general-purpose, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct, but that was incorrect either way due to gw prefix

src/lib/LibPausable.sol Outdated Show resolved Hide resolved
@@ -86,9 +99,9 @@ abstract contract Pausable {
*
* - The contract must be paused.
*/
function _unpause() internal {
_requirePaused();
function _unpause() internal {
PausableStorage storage s = pausableStorage();
Copy link
Contributor

Choose a reason for hiding this comment

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

What difference does this make?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use the same style across the codebase: first, get the storage, then do something.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO this general pattern is unsafe. You should only fetch storage immediately before using it. Otherwise you could be doing a dirty write if you call other functions in between that end up touching that storage. For example, what if _requirePaused() wrote to storage? (it doesn't in this case, but in the future it could). The previous was safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unchanged

@dnkolegov dnkolegov requested a review from raulk December 21, 2023 14:12
@dnkolegov dnkolegov merged commit 2531117 into dev Dec 21, 2023
9 checks passed
@dnkolegov dnkolegov deleted the split_sa_manager branch December 21, 2023 18:50
raulk added a commit that referenced this pull request Dec 21, 2023
raulk added a commit that referenced this pull request Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants