Skip to content

Commit

Permalink
added agent executor
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Apr 1, 2024
1 parent cac7b08 commit 4b63700
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
14 changes: 9 additions & 5 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract Gateway is IGateway, IInitializable {
address internal immutable AGENT_EXECUTOR;

// Verification state
address public immutable BEEFY_CLIENT;
address internal immutable BEEFY_CLIENT;

// BridgeHub
ParaID internal immutable BRIDGE_HUB_PARA_ID;
Expand Down Expand Up @@ -97,8 +97,8 @@ contract Gateway is IGateway, IInitializable {
}

constructor(
address beefyLightClient,
address agentExecutor,
address beefyClient_,
address agentExecutor_,
ParaID bridgeHubParaID,
bytes32 bridgeHubAgentID,
uint8 foreignTokenDecimals
Expand All @@ -107,8 +107,8 @@ contract Gateway is IGateway, IInitializable {
revert InvalidConstructorParams();
}

BEEFY_CLIENT = beefyLightClient;
AGENT_EXECUTOR = agentExecutor;
BEEFY_CLIENT = beefyClient_;
AGENT_EXECUTOR = agentExecutor_;
BRIDGE_HUB_PARA_ID_ENCODED = ScaleCodec.encodeU32(uint32(ParaID.unwrap(bridgeHubParaID)));
BRIDGE_HUB_PARA_ID = bridgeHubParaID;
BRIDGE_HUB_AGENT_ID = bridgeHubAgentID;
Expand Down Expand Up @@ -228,6 +228,10 @@ contract Gateway is IGateway, IInitializable {
return BEEFY_CLIENT;
}

function agentExecutor() external view returns (address) {
return AGENT_EXECUTOR;
}

function operatingMode() external view returns (OperatingMode) {
return CoreStorage.layout().mode;
}
Expand Down
3 changes: 3 additions & 0 deletions contracts/src/interfaces/IGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ interface IGateway {
/// @dev the address of the BEEFY light client used to verify messages.
function beefyClient() external view returns (address);

// @dev the address of the agent executor implementaiton.
function agentExecutor() external view returns (address);

/// @dev Check whether a token is registered
function isTokenRegistered(address token) external view returns (bool);

Expand Down
11 changes: 7 additions & 4 deletions contracts/test/Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ contract GatewayTest is Test {
bytes32[] public proof = [bytes32(0x2f9ee6cfdf244060dc28aa46347c5219e303fc95062dd672b4e406ca5c29764b)];
bytes public parachainHeaderProof = bytes("validProof");

AgentExecutor public executor;
GatewayMock public gatewayLogic;
GatewayProxy public gateway;

Expand Down Expand Up @@ -93,7 +94,7 @@ contract GatewayTest is Test {
UD60x18 public multiplier = ud60x18(1e18);

function setUp() public {
AgentExecutor executor = new AgentExecutor();
executor = new AgentExecutor();
gatewayLogic =
new GatewayMock(address(0), address(executor), bridgeHubParaID, bridgeHubAgentID, foreignTokenDecimals);
Gateway.Config memory config = Gateway.Config({
Expand Down Expand Up @@ -487,7 +488,6 @@ contract GatewayTest is Test {

function testUpgradeInitializerRunsOnlyOnce() public {
// Upgrade to this current logic contract
AgentExecutor executor = new AgentExecutor();
GatewayMock currentLogic =
new GatewayMock(address(0), address(executor), bridgeHubParaID, bridgeHubAgentID, foreignTokenDecimals);

Expand Down Expand Up @@ -525,7 +525,6 @@ contract GatewayTest is Test {
assertNotEq(GatewayMock(address(gateway)).agentOf(agentID), address(0));

// Upgrade to this current logic contract
AgentExecutor executor = new AgentExecutor();
GatewayMock currentLogic =
new GatewayMock(address(0), address(executor), bridgeHubParaID, bridgeHubAgentID, foreignTokenDecimals);

Expand Down Expand Up @@ -910,7 +909,11 @@ contract GatewayTest is Test {
IGateway(address(gateway)).sendToken{value: fee}(address(token), destPara, recipientAddress32, 0, 1);
}

function testGatewayExposesBeefyCleint() public {
function testGatewayExposesBeefyClient() public {
assertEq(IGateway(address(gateway)).beefyClient(), address(0));
}

function testGatewayExposesAgentExecutor() public {
assertEq(IGateway(address(gateway)).agentExecutor(), address(executor));
}
}
4 changes: 4 additions & 0 deletions contracts/test/mocks/GatewayUpgradeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ contract GatewayUpgradeMock is IGateway, IInitializable {
return address(0);
}

function agentExecutor() external pure returns (address) {
return address(0);
}

function isTokenRegistered(address) external pure returns (bool) {
return true;
}
Expand Down

0 comments on commit 4b63700

Please sign in to comment.