Skip to content
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

Audit Issue 9: Remove unused code #1317

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion contracts/src/AgentExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {SubstrateTypes} from "./SubstrateTypes.sol";

import {IERC20} from "./interfaces/IERC20.sol";
import {SafeTokenTransfer, SafeNativeTransfer} from "./utils/SafeTransfer.sol";
import {Gateway} from "./Gateway.sol";

/// @title Code which will run within an `Agent` using `delegatecall`.
/// @dev This is a singleton contract, meaning that all agents will execute the same code.
Expand Down
5 changes: 0 additions & 5 deletions contracts/src/Assets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,4 @@ library Assets {
}
return $.tokenAddressOf[tokenID];
}

function _isTokenRegistered(address token) internal view returns (bool) {
AssetsStorage.Layout storage $ = AssetsStorage.layout();
return $.tokenRegistry[token].isRegistered;
}
}
21 changes: 0 additions & 21 deletions contracts/src/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
error ChannelAlreadyCreated();
error ChannelDoesNotExist();
error InvalidChannelUpdate();
error AgentExecutionFailed(bytes returndata);
error InvalidAgentExecutionPayload();
error InvalidConstructorParams();
error AlreadyInitialized();
error TokenNotRegistered();

// Message handlers can only be dispatched by the gateway itself
Expand All @@ -111,15 +109,6 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
_;
}

// handler functions are privileged from agent only
modifier onlyAgent(bytes32 agentID) {
bytes32 _agentID = _ensureAgentAddress(msg.sender);
if (_agentID != agentID) {
revert Unauthorized();
}
_;
}

constructor(
address beefyClient,
address agentExecutor,
Expand Down Expand Up @@ -583,14 +572,6 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
}
}

/// @dev Ensure that the specified address is an valid agent
function _ensureAgentAddress(address agent) internal view returns (bytes32 agentID) {
agentID = CoreStorage.layout().agentAddresses[agent];
if (agentID == bytes32(0)) {
revert AgentDoesNotExist();
}
}

/// @dev Invoke some code within an agent
function _invokeOnAgent(address agent, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = (Agent(payable(agent)).invoke(AGENT_EXECUTOR, data));
Expand Down Expand Up @@ -650,7 +631,6 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
// Initialize agent for BridgeHub
address bridgeHubAgent = address(new Agent(BRIDGE_HUB_AGENT_ID));
core.agents[BRIDGE_HUB_AGENT_ID] = bridgeHubAgent;
core.agentAddresses[bridgeHubAgent] = BRIDGE_HUB_AGENT_ID;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rather leave these in, in case we need this data later. I also understand we can't remove the storage mapping without a migration, so it might not be worthwhile to remove this in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also dont we still need agents for Transact support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yeah. I'll revert these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in d15b6df.


// Initialize channel for primary governance track
core.channels[PRIMARY_GOVERNANCE_CHANNEL_ID] =
Expand All @@ -663,7 +643,6 @@ contract Gateway is IGateway, IInitializable, IUpgradable {
// Initialize agent for for AssetHub
address assetHubAgent = address(new Agent(config.assetHubAgentID));
core.agents[config.assetHubAgentID] = assetHubAgent;
core.agentAddresses[assetHubAgent] = config.assetHubAgentID;

// Initialize channel for AssetHub
core.channels[config.assetHubParaID.into()] =
Expand Down
Loading