Skip to content

Commit

Permalink
updated ITS
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy committed Aug 24, 2024
1 parent d8e0091 commit 3f9d043
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 35 deletions.
13 changes: 6 additions & 7 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { IGatewayCaller } from './interfaces/IGatewayCaller.sol';
import { Create3AddressFixed } from './utils/Create3AddressFixed.sol';

import { Operator } from './utils/Operator.sol';
import { IAxelarGMPGatewayWithToken } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGMPGatewayWithToken.sol';

/**
* @title The Interchain Token Service
Expand All @@ -39,8 +38,8 @@ contract InterchainTokenService is
Create3AddressFixed,
ExpressExecutorTracker,
InterchainAddressTracker,
AxelarGMPExecutableWithToken,
IInterchainTokenService
IInterchainTokenService,
AxelarGMPExecutableWithToken
{
using AddressBytes for bytes;
using AddressBytes for address;
Expand Down Expand Up @@ -382,7 +381,7 @@ contract InterchainTokenService is
revert InvalidExpressMessageType(messageType);
}

if (IAxelarGMPGatewayWithToken(gatewayAddress).isCommandExecuted(commandId)) revert AlreadyExecuted();
if (gateway().isCommandExecuted(commandId)) revert AlreadyExecuted();

address expressExecutor = msg.sender;
bytes32 payloadHash = keccak256(payload);
Expand Down Expand Up @@ -676,7 +675,7 @@ contract InterchainTokenService is
(, bytes32 tokenId, , , uint256 amountInPayload) = abi.decode(payload, (uint256, bytes32, uint256, uint256, uint256));

if (
validTokenAddress(tokenId) != IAxelarGMPGatewayWithToken(gatewayAddress).tokenAddresses(tokenSymbol) ||
validTokenAddress(tokenId) != gateway().tokenAddresses(tokenSymbol) ||
amount != amountInPayload
) revert InvalidGatewayTokenTransfer(tokenId, payload, tokenSymbol, amount);
}
Expand Down Expand Up @@ -872,7 +871,7 @@ contract InterchainTokenService is
string calldata sourceChain,
string calldata sourceAddress,
bytes calldata payload
) internal override whenNotPaused {
) internal override {
bytes32 payloadHash = keccak256(payload);
uint256 messageType;
string memory originalSourceChain;
Expand All @@ -898,7 +897,7 @@ contract InterchainTokenService is
bytes calldata payload,
string calldata tokenSymbol,
uint256 amount
) internal override whenNotPaused {
) internal override {
bytes32 payloadHash = keccak256(payload);
uint256 messageType;
string memory originalSourceChain;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/Imports.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
pragma solidity ^0.8.0;

// solhint-disable no-unused-import
import { MockGateway } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/test/mocks/MockGateway.sol';
import { MockGMPGatewayWithToken } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/test/mocks/MockGMPGatewayWithToken.sol';
import { AxelarGasService } from '@axelar-network/axelar-cgp-solidity/contracts/gas-service/AxelarGasService.sol';
8 changes: 4 additions & 4 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async function deployContract(wallet, contractName, args = []) {
return contract;
}

async function deployMockGateway(wallet) {
const gateway = await deployContract(wallet, 'MockGateway');
async function deployMockGMPGatewayWithToken(wallet) {
const gateway = await deployContract(wallet, 'MockGMPGatewayWithToken');
return gateway;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ async function deployAll(
const create3Deployer = await new ethers.ContractFactory(Create3Deployer.abi, Create3Deployer.bytecode, wallet)
.deploy()
.then((d) => d.deployed());
const gateway = await deployMockGateway(wallet);
const gateway = await deployMockGMPGatewayWithToken(wallet);
const gasService = await deployGasService(wallet);

const interchainTokenServiceAddress = await getCreate3Address(create3Deployer.address, wallet, deploymentKey);
Expand Down Expand Up @@ -140,7 +140,7 @@ async function deployAll(

module.exports = {
deployContract,
deployMockGateway,
deployMockGMPGatewayWithToken,
deployGasService,
deployInterchainTokenService,
deployAll,
Expand Down
22 changes: 2 additions & 20 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ describe('Interchain Token Service', () => {
gasOptions,
),
service,
'ZeroAddress',
'InvalidAddress',
);
});

Expand Down Expand Up @@ -1342,7 +1342,7 @@ describe('Interchain Token Service', () => {
await expectRevert(
(gasOptions) => service.execute(commandId, sourceChain, wallet.address, '0x', gasOptions),
service,
'NotRemoteService',
'InvalidPayload',
);
});

Expand Down Expand Up @@ -1389,24 +1389,6 @@ describe('Interchain Token Service', () => {
await deployFunctions.gateway(tokenName, tokenSymbol, tokenDecimals);
});

it('Should revert on execute with token if remote address validation fails', async () => {
const commandId = await approveContractCallWithMint(
gateway,
sourceChain,
wallet.address,
service.address,
'0x',
tokenSymbol,
amount,
);

await expectRevert(
(gasOptions) => service.executeWithToken(commandId, sourceChain, wallet.address, '0x', tokenSymbol, amount, gasOptions),
service,
'NotRemoteService',
);
});

it('Should revert on execute with token if the service is paused', async () => {
await service.setPauseStatus(true).then((tx) => tx.wait);

Expand Down
18 changes: 15 additions & 3 deletions test/InterchainTokenServiceUpgradeFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
const { getCreate3Address } = require('@axelar-network/axelar-gmp-sdk-solidity');
const { approveContractCall } = require('../scripts/utils');
const { isHardhat, waitFor, getRandomBytes32, getPayloadAndProposalHash, getContractJSON } = require('./utils');
const { deployContract, deployMockGateway, deployGasService, deployInterchainTokenService } = require('../scripts/deploy');
const { deployContract, deployMockGMPGatewayWithToken, deployGasService, deployInterchainTokenService } = require('../scripts/deploy');
const { getBytecodeHash } = require('@axelar-network/axelar-chains-config');
const AxelarServiceGovernance = getContractJSON('AxelarServiceGovernance');
const Create3Deployer = getContractJSON('Create3Deployer');
Expand Down Expand Up @@ -65,12 +65,14 @@ describe('Interchain Token Service Upgrade Flow', () => {

buffer = isHardhat ? 10 * 60 * 60 : 10;

console.log("ahram1");

const create3DeployerFactory = await ethers.getContractFactory(Create3Deployer.abi, Create3Deployer.bytecode, wallet);
const create3Deployer = await create3DeployerFactory.deploy().then((d) => d.deployed());
const interchainTokenServiceAddress = await getCreate3Address(create3Deployer.address, wallet, deploymentKey);
const interchainToken = await deployContract(wallet, 'InterchainToken', [interchainTokenServiceAddress]);

gateway = await deployMockGateway(wallet);
gateway = await deployMockGMPGatewayWithToken(wallet);
gasService = await deployGasService(wallet);
tokenManagerDeployer = await deployContract(wallet, 'TokenManagerDeployer', []);
interchainTokenDeployer = await deployContract(wallet, 'InterchainTokenDeployer', [interchainToken.address]);
Expand All @@ -85,6 +87,8 @@ describe('Interchain Token Service Upgrade Flow', () => {
wallet,
);

console.log("ahram2");

axelarServiceGovernance = await axelarServiceGovernanceFactory
.deploy(
gateway.address,
Expand All @@ -96,6 +100,8 @@ describe('Interchain Token Service Upgrade Flow', () => {
)
.then((d) => d.deployed());

console.log("ahram3");

service = await deployInterchainTokenService(
wallet,
create3Deployer.address,
Expand All @@ -112,14 +118,18 @@ describe('Interchain Token Service Upgrade Flow', () => {
deploymentKey,
axelarServiceGovernance.address,
);

console.log("ahram4");
});

Check failure on line 124 in test/InterchainTokenServiceUpgradeFlow.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected exclusive mocha test
it('should upgrade Interchain Token Service through AxelarServiceGovernance timeLock proposal', async () => {
it.only('should upgrade Interchain Token Service through AxelarServiceGovernance timeLock proposal', async () => {
const commandID = 0;
const target = service.address;
const nativeValue = 0;
const timeDelay = isHardhat ? 12 * 60 * 60 : 12;

console.log("ahram5");

const targetInterface = new Interface(service.interface.fragments);
const newServiceImplementation = await deployContract(wallet, 'InterchainTokenService', [
tokenManagerDeployer.address,
Expand All @@ -140,6 +150,8 @@ describe('Interchain Token Service Upgrade Flow', () => {
setupParams,
]);

console.log(newServiceImplementationCodeHash);

const [payload, proposalHash, eta] = await getPayloadAndProposalHash(commandID, target, nativeValue, calldata, timeDelay);

const commandIdGateway = getRandomBytes32();
Expand Down

0 comments on commit 3f9d043

Please sign in to comment.