Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
girazoki committed Jan 24, 2025
1 parent 1368bb1 commit d8b10ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions overridden_contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ contract Gateway is IOGateway, IInitializable, IUpgradable {
// We need to put all this inside a generic try-catch, since we dont want to revert decoding nor anything
try Gateway(this).reportSlashes{gas: maxDispatchGas}(message.params) {}
catch Error(string memory err) {
emit UnableToProcessSlashMessage(err);
emit UnableToProcessSlashMessageS(err);
success = false;
} catch (bytes memory err) {
emit UnableToProcessSlashMessage(err);
emit UnableToProcessSlashMessageB(err);
success = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions overridden_contracts/src/interfaces/IOGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ interface IOGateway is IGateway {
);

// Emitted when the middleware fails to apply the slash message
event UnableToProcessSlashMessage(bytes error);
event UnableToProcessSlashMessageB(bytes error);

// Emitted when the middleware fails to apply the slash message
event UnableToProcessSlashMessage(string error);
event UnableToProcessSlashMessageS(string error);

// Slash struct, used to decode slashes, which are identified by
// operatorKey to be slashed
Expand Down
14 changes: 7 additions & 7 deletions overridden_contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ contract GatewayTest is Test {
return (Command.CreateAgent, abi.encode((keccak256("6666"))));
}

function makeReportSlashesCommand() public pure returns (Command, bytes memory) {
function _makeReportSlashesCommand() public pure returns (Command, bytes memory) {
IOGateway.Slash[] memory slashes = new IOGateway.Slash[](1);
slashes[0] = IOGateway.Slash({operatorKey: bytes32(uint256(1)), slashFraction: 500_000, timestamp: 1});
uint256 eraIndex = 1;
Expand Down Expand Up @@ -1022,10 +1022,10 @@ contract GatewayTest is Test {
function testSubmitSlashesWithoutMiddleware() public {
deal(assetHubAgent, 50 ether);

(Command command, bytes memory params) = makeReportSlashesCommand();
(Command command, bytes memory params) = _makeReportSlashesCommand();

vm.expectEmit(true, true, true, true);
emit IOGateway.UnableToProcessSlashMessage(abi.encodeWithSelector(Gateway.MiddlewareNotSet.selector));
emit IOGateway.UnableToProcessSlashMessageB(abi.encodeWithSelector(Gateway.MiddlewareNotSet.selector));
// Expect the gateway to emit `InboundMessageDispatched`
vm.expectEmit(true, true, true, true);
emit IGateway.InboundMessageDispatched(assetHubParaID.into(), 1, messageID, false);
Expand All @@ -1042,7 +1042,7 @@ contract GatewayTest is Test {
function testSubmitSlashesWithMiddlewareNotComplyingInterface() public {
deal(assetHubAgent, 50 ether);

(Command command, bytes memory params) = makeReportSlashesCommand();
(Command command, bytes memory params) = _makeReportSlashesCommand();

IOGateway(address(gateway)).setMiddleware(0x0123456789012345678901234567890123456789);

Expand All @@ -1051,7 +1051,7 @@ contract GatewayTest is Test {
// For some reason when you are loading an address not complying an interface, you get an empty message
// It still serves us to know that this is the reason
vm.expectEmit(true, true, true, true);
emit IOGateway.UnableToProcessSlashMessage(empty);
emit IOGateway.UnableToProcessSlashMessageB(empty);
vm.expectEmit(true, true, true, true);
emit IGateway.InboundMessageDispatched(assetHubParaID.into(), 1, messageID, false);

Expand All @@ -1067,7 +1067,7 @@ contract GatewayTest is Test {
function testSubmitSlashesWithMiddlewareComplyingInterfaceAndSlashRevert() public {
deal(assetHubAgent, 50 ether);

(Command command, bytes memory params) = makeReportSlashesCommand();
(Command command, bytes memory params) = _makeReportSlashesCommand();

bytes memory expectedError = bytes("no process slash");

Expand Down Expand Up @@ -1101,7 +1101,7 @@ contract GatewayTest is Test {
function testSubmitSlashesWithMiddlewareComplyingInterfaceAndSlashProcessed() public {
deal(assetHubAgent, 50 ether);

(Command command, bytes memory params) = makeReportSlashesCommand();
(Command command, bytes memory params) = _makeReportSlashesCommand();

// We mock the call so that it does not revert
vm.mockCall(address(1), abi.encodeWithSelector(IMiddlewareBasic.slash.selector), abi.encode(10));
Expand Down

0 comments on commit d8b10ed

Please sign in to comment.