-
Notifications
You must be signed in to change notification settings - Fork 14
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
GMP V2 #23
base: main
Are you sure you want to change the base?
GMP V2 #23
Conversation
/** | ||
* @dev Return the log in base 2 of a positive value rounded towards zero. | ||
* Returns 0 if given 0. | ||
*/ | ||
function log2(uint256 x) internal pure returns (uint256 r) { | ||
function log2(uint256 x) internal pure returns (uint256) { |
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.
There's no logical changes here, just updated the documentation to match the PR I opened on OpenZeppelin SDK:
OpenZeppelin/openzeppelin-contracts#5236
A few questions from team here @Lohann
|
Good point, this interface currently doesn't supports on-chain shard listing, currently the only way to list the shards is off-chain by listening to all Why? Unless there's a requirement to know the current Shard Set on-chain, my suggestion to this dilema is create the |
Signatures works as follow: bytes32 constant private DOMAIN_SEPARATOR = ...; // EIP-712 domain separator
bytes32 constant private INBOUND_MESSAGE_TYPE_HASH = keccak256("InboundMessage(uint64 nonce,uint64 maxDispatchGas,uint256 maxFeePerGas,uint256 command,bytes params)");
InboundMessage memory inbound = ...;
bytes32 paramsHash = keccak256(inbound.params);
bytes32 messageHash = keccak256(abi.encode(
INBOUND_MESSAGE_TYPE_HASH,
inbound.nonce,
inbound.maxDispatchGas,
inbound.maxFeePerGas,
inbound.command,
paramsHash
));
bytes32 sigBytes = abi.encodePacked(
hex"1901",
DOMAIN_SEPARATOR,
messageHash
);
bytes32 sighash = keccak256(sigBytes);
Signature memory signature = sign(sighash); The shards signs the |
My mistake, removed the copy. |
You mean the Btw notice that even so rust doesn't support Also |
This have the same role as the nonce in a transaction, is sequence number, issued by the timechain, used to prevent message replay and guarantee consistency. This is crucial, because assuming an asynchoronous unidirecional channel, the order on which the messages are processed ALTERS the final result, example: Execute a Register/Revoke in a different order, makes the final Shard Set be different, this is not desired, that's why the gateway enforces sequence. |
Currently the |
There's an exaustive documentation in the Universal Factory repo, with comments and code examples: The documentation assumes the reader have some basic understand of Ethereum Protocol and smart-contract development, such as EIP-1014 CREATE2, Upgradeable Proxy Pattern, EIP-1153 Transient Storage VS regular Storage, transaction execution flow, reentrancy attacks, etc. There was also an hands-on meeting in which @penumbra23, @ManojJiSharma, @BogiLoco and @foravneet and anyone interested participated. |
New Design
The new design supports batching and easier signature verification, the only entry point for all timechain messages is the
submitV1
method, that accept an "generic"InboundMessage
as parameter, this design is inspired in Snowbridge Gateway Contract. theInboundMessage.params
is parsed based onInboundMessage.command
.Commands parameters
GMP
:GmpMessage[]
.SetShards
:TssKey[]
this method delete all existing set of keys, and replace by this new one.SetRoute
SetRoute[]
update or create all provided routes.Migrate
(address implementation, bytes callback)
contains the new implementation address, and an optional callback for migration purposes, the thebytes
is empty, no callback is called. Obs: the gateway verifies if theimplementation
exists.The method
submitV1
ONLY verifies the signature in theInboundMessage.signature
if themsg.sender != admin()
, it basically means that the admin account can freely submit InboundMessages without replay protection, etc.Permissionless Deployment
Motivation
@penumbra23 frequently get blocked due error prone manual steps required to deploy the Gateway + GatewayProxy for testing, and setup a new network currently rely in a Vanity privake-key hold by me, if this key ever get leaked or we do an mistake and use the
nonce 0
of this key, we lose that address forever in the given network.Also deploying a contract using a regular EOA doesn't emit any event, much less tell us what code was deployed.
Solution
This PR also includes some important changes that allows permissionless deployments of the gateway contract in any existing or future network, it allows chronicles or actually any person to deploy the gateway at an deterministic address in any future network, for that we use the novel Universal Factory together with Counterfactual Interactions, example:
https://github.com/Analog-Labs/universal-factory/tree/main/test/examples#2-callbacks-and-custom-owned-addresses