-
Notifications
You must be signed in to change notification settings - Fork 105
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(ethexe): Support slash commitments in router #4403
base: master
Are you sure you want to change the base?
Conversation
@@ -34,6 +36,7 @@ contract DeploymentScript is Script { | |||
|
|||
address mirrorAddress = vm.computeCreateAddress(deployerAddress, vm.getNonce(deployerAddress) + 2); | |||
address mirrorProxyAddress = vm.computeCreateAddress(deployerAddress, vm.getNonce(deployerAddress) + 3); | |||
address middlewareAddress = vm.computeCreateAddress(deployerAddress, vm.getNonce(deployerAddress) + 4); |
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.
vm.computeCreateAddress(deployerAddress, deployerNonce)
is used to compute the future contract address. after mirrorProxy = new MirrorProxy(address(router))
you need to create middleware
to make this address valid.
@@ -154,6 +154,7 @@ impl Ethereum { | |||
_mirror: mirror_address, | |||
_mirrorProxy: mirror_proxy_address, | |||
_wrappedVara: wvara_address, | |||
_middleware: Address::default(), |
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 place should be the same as ethexe/contracts/script/Deployment.s.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.
I think you can do it in the next PR such as #4403 for the Rust part, and do the Solidity part in this PR
event RequestSlashCommitmentProcessed(bytes32 indexed commitmentHash, IMiddleware.SlashData[] slashData); | ||
|
||
/** | ||
* @dev Emitted when a slash request is executed by the middleware. | ||
* @param slashId An array of SlashIdentifier structures containing details of the slash execution. | ||
*/ | ||
event ExecuteSlashCommitmentProcessed(bytes32 indexed commitmentHash, IMiddleware.SlashIdentifier[] slashId); |
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.
indexed
is not needed, because the observer is watching many events at once
event RequestSlashCommitmentProcessed(bytes32 indexed commitmentHash, IMiddleware.SlashData[] slashData); | |
/** | |
* @dev Emitted when a slash request is executed by the middleware. | |
* @param slashId An array of SlashIdentifier structures containing details of the slash execution. | |
*/ | |
event ExecuteSlashCommitmentProcessed(bytes32 indexed commitmentHash, IMiddleware.SlashIdentifier[] slashId); | |
event RequestSlashCommitmentProcessed(bytes32 commitmentHash, IMiddleware.SlashData[] slashData); | |
/** | |
* @dev Emitted when a slash request is executed by the middleware. | |
* @param slashId An array of SlashIdentifier structures containing details of the slash execution. | |
*/ | |
event ExecuteSlashCommitmentProcessed(bytes32 commitmentHash, IMiddleware.SlashIdentifier[] slashId); |
vm.startPrank(admin); | ||
{ | ||
middleware.changeSlashRequester(address(router)); | ||
middleware.changeSlashExecutor(address(router)); | ||
} | ||
vm.stopPrank(); | ||
|
||
// For understanding where symbiotic ecosystem is using | ||
sym = POCBaseTest(address(this)); |
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 used ?
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; | ||
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; | ||
import "forge-std/Test.sol"; | ||
|
||
import {POCBaseTest} from "symbiotic-core/test/POCBase.t.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.
Not used ?
@@ -101,6 +103,16 @@ library Gear { | |||
Message[] messages; | |||
} | |||
|
|||
struct RequestSlashCommitment { |
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.
Looks like better to use naming SlashRequestCommitment, SlashExecuteCommitment and the same in other places. Because when read function names like requestSlashCommitmentHash
- this understands like a calling some function which send a request for hash.
uint256 currentEraIndex = (block.timestamp - router.genesisBlock.timestamp) / router.timelines.era; | ||
|
||
// Validate the era index | ||
require(commitment.eraIndex == currentEraIndex, "commitment era index is invalid"); |
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 not possible to sent a slash for the previous era? for example we found that validator from the previous era did something wrong - why we cannot to sent a slash for the funds it had in the previous era?
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.
Ah now I can see. I think era param should be removed from commitment. Cannot see why do we need it. Slashes have already all informations about timestamps.
uint256 eraStart = router.genesisBlock.timestamp + router.timelines.era * currentEraIndex; | ||
require(block.timestamp >= eraStart, "current era has not started yet"); |
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 mathematically impossible case
|
||
// Ensure middleware is set | ||
address middlewareAddress = router.implAddresses.middleware; | ||
require(middlewareAddress != address(0), "Middleware address not set"); |
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 important: Looks like over-checking. This must be checked in constructor
// Call the middleware's `requestSlash` function | ||
middlewareInstance.requestSlash(commitment.slashes); | ||
|
||
emit RequestSlashCommitmentProcessed(commitmentHash, commitment.slashes); |
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.
I think is enough to sent a commitmentHash. This is cheaper. And validators could save their slashes in db by hash and access them if they need in future.
uint256 currentEraIndex = (block.timestamp - router.genesisTimestamp()) / eraDuration; | ||
uint256 nextEraIndex = currentEraIndex + 1; | ||
|
||
// Move to the election period for the next era |
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.
Your are not going to election period
Resolves #4383 .
IMiddleware
@reviewer-or-team