Skip to content

Commit

Permalink
feat(evm): aggressive optimization (#2965)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-aitlahcen authored Oct 7, 2024
2 parents 29ccbe8 + 9977f4f commit 02c57a5
Show file tree
Hide file tree
Showing 136 changed files with 4,713 additions and 111,905 deletions.
6 changes: 3 additions & 3 deletions app/scripts/abi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ nix build .#evm-contracts --print-build-logs

IBC_HANDLER=$(jq --slurp 'map(.abi) | add' \
result/out/IBCClient.sol/IBCClient.json \
result/out/IBCPacket.sol/IBCPacket.json \
result/out/IBCConnection.sol/IBCConnection.json \
result/out/IBCPacket.sol/IBCPacketImpl.json \
result/out/IBCConnection.sol/IBCConnectionImpl.json \
result/out/OwnableIBCHandler.sol/OwnableIBCHandler.json \
result/out/IBCChannelHandshake.sol/IBCChannelHandshake.json)
result/out/IBCChannel.sol/IBCChannelImpl.json)

echo "export const ibcHandlerAbi = <const>${IBC_HANDLER}" >| app/src/lib/abi/ibc-handler.ts

Expand Down
2 changes: 1 addition & 1 deletion evm/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sequenceDiagram
```

To relax the contract size limit of ethereum, each ICS implementation is split into [IBCClient](contracts/core/02-client/IBCClient.sol), [IBCConnection](contracts/core/03-connection/IBCConnection.sol), [IBCChannel](contracts/core/04-channel/IBCChannelHandshake.sol), [IBCPacket](contracts/core/04-channel/IBCPacket.sol), and [IBCHandler](contracts/core/25-handler/IBCHandler.sol) contracts, as shown in the above figure.
To relax the contract size limit of ethereum, each ICS implementation is split into [IBCClient](contracts/core/02-client/IBCClient.sol), [IBCConnection](contracts/core/03-connection/IBCConnection.sol), [IBCChannel](contracts/core/04-channel/IBCChannel.sol), [IBCPacket](contracts/core/04-channel/IBCPacket.sol), and [IBCHandler](contracts/core/25-handler/IBCHandler.sol) contracts, as shown in the above figure.

In general, such a design causes storage splitting, so it is required to implement unnecessary authentication and accessors for inter-contract calls.

Expand Down
39 changes: 0 additions & 39 deletions evm/contracts/Glue.sol

This file was deleted.

10 changes: 4 additions & 6 deletions evm/contracts/Multicall.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.8.23;
pragma solidity ^0.8.27;

struct Call3 {
address target;
Expand All @@ -14,11 +14,9 @@ struct Result {
event MulticallResult(Result[]);

contract Multicall {
function multicall(Call3[] calldata calls)
public
payable
returns (Result[] memory returnData)
{
function multicall(
Call3[] calldata calls
) public payable returns (Result[] memory returnData) {
uint256 length = calls.length;
returnData = new Result[](length);
Call3 calldata calli;
Expand Down
97 changes: 53 additions & 44 deletions evm/contracts/apps/Base.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pragma solidity ^0.8.23;
pragma solidity ^0.8.27;

import "../core/05-port/IIBCModule.sol";

library IBCAppLib {
error ErrNotIBC();
error ErrNotImplemented();
}

/**
Expand Down Expand Up @@ -35,56 +36,52 @@ abstract contract IBCAppBase is IIBCModule {
/**
* @dev See IIBCModule-onChanOpenInit
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onChanOpenInit(
IbcCoreChannelV1GlobalEnums.Order,
string[] calldata connectionHops,
string calldata portId,
string calldata channelId,
IbcCoreChannelV1Counterparty.Data calldata counterpartyEndpoint,
string calldata version,
address relayer
IBCChannelOrder,
uint32,
uint32,
IBCChannelCounterparty calldata,
bytes32,
address
) external virtual override onlyIBC {}

/**
* @dev See IIBCModule-onChanOpenTry
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onChanOpenTry(
IbcCoreChannelV1GlobalEnums.Order,
string[] calldata connectionHops,
string calldata portId,
string calldata channelId,
IbcCoreChannelV1Counterparty.Data calldata counterpartyEndpoint,
string calldata version,
string calldata counterpartyVersion,
address relayer
IBCChannelOrder,
uint32,
uint32,
IBCChannelCounterparty calldata,
bytes32,
bytes32,
address
) external virtual override onlyIBC {}

/**
* @dev See IIBCModule-onChanOpenAck
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onChanOpenAck(
string calldata portId,
string calldata channelId,
string calldata counterpartyChannelId,
string calldata counterpartyVersion,
address relayer
uint32,
uint32,
bytes32,
address
) external virtual override onlyIBC {}

/**
* @dev See IIBCModule-onChanOpenConfirm
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onChanOpenConfirm(
string calldata portId,
string calldata channelId,
address relayer
uint32,
address
) external virtual override onlyIBC {}

/**
Expand All @@ -93,9 +90,8 @@ abstract contract IBCAppBase is IIBCModule {
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onChanCloseInit(
string calldata portId,
string calldata channelId,
address relayer
uint32,
address
) external virtual override onlyIBC {}

/**
Expand All @@ -104,19 +100,19 @@ abstract contract IBCAppBase is IIBCModule {
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onChanCloseConfirm(
string calldata portId,
string calldata channelId,
address relayer
uint32,
address
) external virtual override onlyIBC {}

/**
* @dev See IIBCModule-onRecvPacket
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onRecvPacket(
IbcCoreChannelV1Packet.Data calldata packet,
address relayer
IBCPacket calldata,
address,
bytes calldata
)
external
virtual
Expand All @@ -125,24 +121,37 @@ abstract contract IBCAppBase is IIBCModule {
returns (bytes memory acknowledgement)
{}

/**
* @dev See IIBCModule-onRecvIntentPacket
*
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onRecvIntentPacket(
IBCPacket calldata,
address,
bytes calldata
) external virtual override onlyIBC returns (bytes memory) {
revert IBCAppLib.ErrNotImplemented();
}

/**
* @dev See IIBCModule-onAcknowledgementPacket
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onAcknowledgementPacket(
IbcCoreChannelV1Packet.Data calldata packet,
bytes calldata acknowledgement,
address relayer
IBCPacket calldata,
bytes calldata,
address
) external virtual override onlyIBC {}

/**
* @dev See IIBCModule-onTimeoutPacket
*
* NOTE: You should apply an `onlyIBC` modifier to the function if a derived contract overrides it.
* NOTE: You must apply an `onlyIBC` modifier to the function if a derived contract overrides it.
*/
function onTimeoutPacket(
IbcCoreChannelV1Packet.Data calldata packet,
address relayer
IBCPacket calldata,
address
) external virtual override onlyIBC {}
}
Loading

0 comments on commit 02c57a5

Please sign in to comment.