Skip to content

[Multi ZNS] Multi zNS Prototype [WIP] #118

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 125 commits into
base: rc/multi-zns-main
Choose a base branch
from

Conversation

Whytecrowe
Copy link
Collaborator

@Whytecrowe Whytecrowe commented Sep 19, 2024

rc/multi-zns-main needs to be merged into this branch to update the code with all the previous changes !!!

@Whytecrowe Whytecrowe changed the base branch from rc/zns-meowchain to zns-zchain-final September 19, 2024 21:51
Copy link

openzeppelin-code bot commented Sep 19, 2024

[Multi ZNS] Multi zNS Prototype [WIP]

Generated at commit: b2701971cdbfa8f132fc0a3f8364b29051674286

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
2
0
2
20
27
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@Whytecrowe Whytecrowe changed the title Multi zNS Prototype [WIP] Multi zNS Prototype Sep 26, 2024
@Whytecrowe Whytecrowe changed the base branch from rc/multi-zns-main to zns-zchain-final December 18, 2024 00:59

function destZnsPortal() external view returns (address);

function rootRegistrar() external view returns (IZNSRootRegistrarTrunk);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider moving this and a few of the other items that are shared between this contract and IZNSEthereumPortal to a higher level IZNSPortal, to avoid code duplication

import { IZNSRootRegistrarTrunk } from "../registrar/IZNSRootRegistrarTrunk.sol";
import { IZNSSubRegistrarTrunk } from "../registrar/IZNSSubRegistrarTrunk.sol";
import { IZNSTreasury } from "../treasury/IZNSTreasury.sol";
import { PaymentConfig } from "../treasury/IZNSTreasury.sol";
Copy link
Collaborator

Choose a reason for hiding this comment

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

same import file as what's used above, just do import { X, Y } from ....

polygonZkEVMBridge.bridgeMessage(
destNetworkId,
destZnsPortal,
// TODO multi: figure out what this is and how to better pass it !!!
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this comment in reference to a similar comment for forceGlobalExitRoot above on L74?

Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit confusing having the opposite chain in the name of the contract to me. This is the portal to ZChain, but it is not the portal on ZChain, and calling it ZChainPortal gives the opposite implication


interface IZNSZChainPortal is IDistributionConfig {

struct ZNSContractInput {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You put this in a struct but the other contract has the same arguments, except for IZNSAccessController, might make more sense to use this struct as an initializer argument for both contracts and just have the one additional argument of the access controller contract be given in the ZNSZChainPortal contract

);
}

// TODO multi: analyze how to make these strings better !!!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Enums?

enum ResolverTypes {
  CHAIN,
  ADDRESS,
  STRING
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the downside here is that every time this enum is extended, we need to upgrade all contracts that use it

domainHash,
destChainId,
destChainName,
address(0),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we not care about setting znsRegistryOnChain?

bytes32 parentHash
) internal {
// TODO multi: do we actually want to stake on BOTH sides? What other payment option can we do ???!!!
// TODO multi: if we leave this option (stake as Portal address) this needs to be optimized!!!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not include the registrant address and have the portal use stake payment on the registrant's behalf?

import { IBridgeMessageReceiver } from "@zero-tech/zkevm-contracts/contracts/interfaces/IBridgeMessageReceiver.sol";
import { ERC20Mock } from "../../token/mocks/ERC20Mock.sol";
import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
// import { PolygonZkEVMBridgeV2 } from "@zero-tech/zkevm-contracts/contracts/v2/PolygonZkEVMBridgeV2.sol";
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete unneeded comments

revert MessageFailed();
}

emit ClaimEvent(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think of a better name for the events here and above. MessageClaimed and MessageBridged or just Claimed and Bridged would be better

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a mock of a Polygon Bridge contract. the names here are Polygon names.

});

// override from local .env file if anything is present
require("dotenv").config({ override: true });
Copy link
Collaborator

Choose a reason for hiding this comment

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

This part might be doing nothing, because env vars are loaded at run time, when a script that uses this function is called, all the process.env vars are mapped, then we override those with the defaults above in the Object.entries loop

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure what you mean. we use the defaults from the file on the line above this, then this one overrides all the default from the env file if present.
env vars from .env file are loaded whenever this line is called. or am I misunderstanding?

export const findMissingEnvVars = () => {
const missing = required.filter(
key =>
process.env[key] === undefined || process.env[key] === ""
Copy link
Collaborator

@JamesEarle JamesEarle Dec 18, 2024

Choose a reason for hiding this comment

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

small nitpick, you often add line breaks at arbitrary points that don't really make sense to me, like here, where it clearly isn't going past the character limit specified by the linter, whereas above in the required array or below on L18 you aren't using the same rule

Ideally we just abide by the rules specified in the linter so that we're both always on the same page, and if you prefer to shorten the max line length enforced we can do that instead

Copy link
Collaborator Author

@Whytecrowe Whytecrowe Feb 24, 2025

Choose a reason for hiding this comment

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

this is just basic readability to me rather then thinking about line length. here I am separating function param and def from the function code on the next line. we can split here or not split, it's not a big deal, it was just more readable to me this way, so I decided to do it.
Also, shorter lines make it easier to read code on smaller screens.

chainId: 2012605151,
urls: {
apiURL: "https://wilderworld-dev-erigon1-blockscout.eu-north-2.gateway.fm/api/",
browserURL: "https://wilderworld-dev-erigon1-blockscout.eu-north-2.gateway.fm/",
Copy link
Collaborator

Choose a reason for hiding this comment

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

put these values in env vars

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are public links that users would use. is there a reason for make them env vars?

@Whytecrowe Whytecrowe changed the base branch from zns-zchain-final to rc/multi-zns-main December 18, 2024 22:55
@@ -91,57 +92,48 @@ contract ZNSSubRegistrar is AAccessControlled, ARegistryWired, UUPSUpgradeable,
DistributionConfig calldata distrConfig,
PaymentConfig calldata paymentConfig
) external override returns (bytes32) {
return _coreSubdomainRegister(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and in other places it would be nicer if the internal _core functions were consistent with the naming of the public callers as much as they can be, so _coreRegisterSubdomain, this is clearer as well as the name describes the action the function is taking

@@ -182,7 +166,7 @@ contract ZNSRootRegistrar is
registry.createDomainRecord(args.domainHash, args.registrant, "address");

IZNSAddressResolver(registry.getDomainResolver(args.domainHash))
.setAddress(args.domainHash, args.domainAddress);
.setAddress(args.domainHash, args.domainAddress);
Copy link
Collaborator

Choose a reason for hiding this comment

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

For formatting like this where lines from a single function call have to broken into multiple for the sake of line length, it makes more sense to have the extra indentation here. It shows visually that this line is not independent, I would undo this change and any other similar changes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. no idea how this changed tbh :)

!mintlist[args.parentHash]
.list
[mintlist[args.parentHash].ownerIndex]
[msg.sender]
Copy link
Collaborator

Choose a reason for hiding this comment

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

indent these for clarity

using StringUtils for string;

IZNSPricer public rootPricer;
IZNSTreasury public treasury;
IZNSDomainToken public domainToken;
IZNSSubRegistrar public subRegistrar;
IZNSSubRegistrarTrunk public subRegistrar;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

why is this a Trunk contract? is this a mistake?..

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.

2 participants