-
Notifications
You must be signed in to change notification settings - Fork 2
[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
base: rc/multi-zns-main
Are you sure you want to change the base?
Conversation
[Multi ZNS] Multi zNS Prototype [WIP]
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
|
||
function destZnsPortal() external view returns (address); | ||
|
||
function rootRegistrar() external view returns (IZNSRootRegistrarTrunk); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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 !!! |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 !!! |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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!!! |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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] === "" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
@@ -91,57 +92,48 @@ contract ZNSSubRegistrar is AAccessControlled, ARegistryWired, UUPSUpgradeable, | |||
DistributionConfig calldata distrConfig, | |||
PaymentConfig calldata paymentConfig | |||
) external override returns (bytes32) { | |||
return _coreSubdomainRegister( |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?..
rc/multi-zns-main
needs to be merged into this branch to update the code with all the previous changes !!!