Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FOUNDRY_PROFILE=default
FORGE=FOUNDRY_PROFILE=$(FOUNDRY_PROFILE) forge
SOLC_VERSION=0.8.24
EVM_VERSION=paris
EVM_VERSION=cancun
DOCKER=docker
ABIGEN="$(DOCKER) run -v .:/workspace -w /workspace -it ethereum/client-go:alltools-v1.11.6 abigen"
SOLHINT=npx solhint
Expand All @@ -16,7 +16,7 @@ TEST_UPGRADEABLE=false

.PHONY: build
build:
$(FORGE) build --sizes --skip test --use solc:$(SOLC_VERSION)
$(FORGE) build --sizes --skip test --use solc:$(SOLC_VERSION) --evm-version $(EVM_VERSION)

.PHONY: clean
clean:
Expand All @@ -33,7 +33,7 @@ lint:

.PHONY: test
test:
TEST_UPGRADEABLE=$(TEST_UPGRADEABLE) $(FORGE) test -vvvv --gas-report --isolate --use solc:$(SOLC_VERSION)
TEST_UPGRADEABLE=$(TEST_UPGRADEABLE) $(FORGE) test -vvvv --gas-report --isolate --use solc:$(SOLC_VERSION) --evm-version $(EVM_VERSION)

.PHONY: snapshot
snapshot:
Expand Down
3 changes: 2 additions & 1 deletion chains/ibft2/chain0/ibftConfigFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"genesis": {
"config": {
"chainId": 2018,
"muirglacierblock": 0,
"cancunTime": 0,
"zeroBaseFee": true,
"ibft2": {
"blockperiodseconds": 1,
"epochlength": 30000,
Expand Down
3 changes: 2 additions & 1 deletion chains/ibft2/chain1/ibftConfigFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"genesis": {
"config": {
"chainId": 3018,
"muirglacierblock": 0,
"cancunTime": 0,
"zeroBaseFee": true,
"ibft2": {
"blockperiodseconds": 1,
"epochlength": 30000,
Expand Down
2 changes: 1 addition & 1 deletion chains/qbft/chain0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/besu:24.3.0
FROM hyperledger/besu:24.10.0

USER root

Expand Down
3 changes: 2 additions & 1 deletion chains/qbft/chain0/qbftConfigFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"genesis": {
"config": {
"chainId": 2018,
"muirglacierblock": 0,
"cancunTime": 0,
"zeroBaseFee": true,
"qbft": {
"blockperiodseconds": 1,
"epochlength": 30000,
Expand Down
2 changes: 1 addition & 1 deletion chains/qbft/chain1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/besu:24.3.0
FROM hyperledger/besu:24.10.0

USER root

Expand Down
3 changes: 2 additions & 1 deletion chains/qbft/chain1/qbftConfigFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"genesis": {
"config": {
"chainId": 3018,
"muirglacierblock": 0,
"cancunTime": 0,
"zeroBaseFee": true,
"qbft": {
"blockperiodseconds": 1,
"epochlength": 30000,
Expand Down
5 changes: 2 additions & 3 deletions contracts/core/04-channel/IBCChannelPacketSendRecv.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ contract IBCChannelPacketSendRecv is
revert IBCChannelUnexpectedPacketSource(msg_.packet.sourcePort, msg_.packet.sourceChannel);
}

if (msg_.packet.timeoutHeight.revision_height != 0 && block.number >= msg_.packet.timeoutHeight.revision_height)
{
revert IBCChannelTimeoutPacketHeight(block.number, msg_.packet.timeoutHeight.revision_height);
if (!msg_.packet.timeoutHeight.isZero() && hostHeight().gte(msg_.packet.timeoutHeight)) {
revert IBCChannelTimeoutPacketHeight(hostHeight(), msg_.packet.timeoutHeight);
}
if (msg_.packet.timeoutTimestamp != 0 && hostTimestamp() >= msg_.packet.timeoutTimestamp) {
revert IBCChannelTimeoutPacketTimestamp(hostTimestamp(), msg_.packet.timeoutTimestamp);
Expand Down
18 changes: 10 additions & 8 deletions contracts/core/04-channel/IBCChannelUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Height} from "../../proto/Client.sol";
import {ConnectionEnd} from "../../proto/Connection.sol";
import {Channel, ChannelCounterparty, Upgrade, UpgradeFields, ErrorReceipt, Timeout} from "../../proto/Channel.sol";
import {ILightClient} from "../02-client/ILightClient.sol";
import {IBCHeight} from "../02-client/IBCHeight.sol";
import {IBCConnectionLib} from "../03-connection/IBCConnectionLib.sol";
import {IIBCConnectionErrors} from "../03-connection/IIBCConnectionErrors.sol";
import {IIBCChannelErrors} from "./IIBCChannelErrors.sol";
Expand Down Expand Up @@ -219,6 +220,8 @@ contract IBCChannelUpgradeInitTryAck is
IIBCConnectionErrors,
IIBCChannelErrors
{
using IBCHeight for Height.Data;

/**
* @dev See {IIBCChannelUpgrade-channelUpgradeInit}
*/
Expand Down Expand Up @@ -421,9 +424,9 @@ contract IBCChannelUpgradeInitTryAck is

// counterparty-specified timeout must not have exceeded
// if it has, then restore the channel and abort upgrade handshake
Timeout.Data calldata timeout = msg_.counterpartyUpgrade.timeout;
Timeout.Data memory timeout = msg_.counterpartyUpgrade.timeout;
if (
(timeout.height.revision_height != 0 && block.number >= timeout.height.revision_height)
(!timeout.height.isZero() && hostHeight().gte(timeout.height))
|| (timeout.timestamp != 0 && hostTimestamp() >= timeout.timestamp)
) {
restoreChannel(msg_.portId, msg_.channelId, UpgradeHandshakeError.Timeout);
Expand Down Expand Up @@ -547,6 +550,8 @@ contract IBCChannelUpgradeConfirmOpenTimeoutCancel is
IBCChannelUpgradeCommon,
IIBCChannelUpgradeConfirmOpenTimeoutCancel
{
using IBCHeight for Height.Data;

/**
* @dev See {IIBCChannelUpgrade-channelUpgradeConfirm}
*/
Expand Down Expand Up @@ -586,9 +591,9 @@ contract IBCChannelUpgradeConfirmOpenTimeoutCancel is

// counterparty-specified timeout must not have exceeded
// if it has, then restore the channel and abort upgrade handshake
Timeout.Data calldata timeout = msg_.counterpartyUpgrade.timeout;
Timeout.Data memory timeout = msg_.counterpartyUpgrade.timeout;
if (
(timeout.height.revision_height != 0 && block.number >= timeout.height.revision_height)
(!timeout.height.isZero() && hostHeight().gte(timeout.height))
|| (timeout.timestamp != 0 && hostTimestamp() >= timeout.timestamp)
) {
restoreChannel(msg_.portId, msg_.channelId, UpgradeHandshakeError.Timeout);
Expand Down Expand Up @@ -764,10 +769,7 @@ contract IBCChannelUpgradeConfirmOpenTimeoutCancel is
// Either timeoutHeight or timeoutTimestamp must be defined.
// if timeoutHeight is defined and proof is from before
// timeout height then abort transaction
if (
upgrade.timeout.height.revision_height != 0
&& msg_.proofHeight.revision_height < upgrade.timeout.height.revision_height
) {
if (!upgrade.timeout.height.isZero() && msg_.proofHeight.lt(upgrade.timeout.height)) {
revert IBCChannelUpgradeTimeoutHeightNotReached();
}
// if timeoutTimestamp is defined then the consensus time
Expand Down
4 changes: 2 additions & 2 deletions contracts/core/04-channel/IIBCChannelErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ interface IIBCChannelErrors {

error IBCChannelAckAlreadyProcessedInPreviousUpgrade(uint64 sequence, uint64 ackStartSequence);

/// @param currentBlockNumber current block number
/// @param currentHeight current height
/// @param timeoutHeight packet timeout height
error IBCChannelTimeoutPacketHeight(uint256 currentBlockNumber, uint64 timeoutHeight);
error IBCChannelTimeoutPacketHeight(Height.Data currentHeight, Height.Data timeoutHeight);

/// @param currentTimestamp current timestamp
/// @param timeoutTimestamp packet timeout timestamp
Expand Down
4 changes: 4 additions & 0 deletions contracts/core/25-handler/IBCQuerier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ contract IBCQuerier is IBCModuleManager, IIBCQuerier {
return _getCommitmentPrefix();
}

function getRevisionNumber() public view override returns (uint64) {
return _getRevisionNumber();
}

function getCommitmentsSlot() public pure override returns (bytes32) {
return COMMITMENT_STORAGE_LOCATION;
}
Expand Down
2 changes: 2 additions & 0 deletions contracts/core/25-handler/IIBCQuerier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {IIBCModule, IIBCModuleInitializer} from "../26-router/IIBCModule.sol";
interface IIBCQuerier {
function getCommitmentPrefix() external view returns (bytes memory);

function getRevisionNumber() external view returns (uint64);

function getCommitmentsSlot() external pure returns (bytes32);

function getCommitment(bytes32 hashedPath) external view returns (bytes32);
Expand Down
33 changes: 32 additions & 1 deletion pkg/contract/ibchandler/ibchandler.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pkg/testing/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ func (chain *Chain) WaitForReceiptAndGet(ctx context.Context, tx *gethtypes.Tran
func (chain *Chain) WaitIfNoError(ctx context.Context, txName string) func(tx *gethtypes.Transaction, err error) error {
return func(tx *gethtypes.Transaction, err error) error {
if err != nil {
return fmt.Errorf("failed to call transaction: tx=%v err='%v'", txName, err)
return fmt.Errorf("failed to call transaction: tx=%v txPayload=%#v err='%v'", txName, tx, err)
}
return chain.WaitForReceiptAndGet(ctx, tx, txName)
}
Expand Down Expand Up @@ -1290,6 +1290,8 @@ func makeGenTxOpts(chainID *big.Int, prv *ecdsa.PrivateKey) func(ctx context.Con
// Set non-zero value to avoid call `estimateGas`
// This allows we can extract the revert reason from the transaction receipt if the transaction fails.
GasLimit: 6382056,
// Use legacy tx
GasPrice: big.NewInt(0),
Signer: func(address common.Address, tx *gethtypes.Transaction) (*gethtypes.Transaction, error) {
if address != addr {
return nil, errors.New("not authorized to sign this account")
Expand Down
4 changes: 2 additions & 2 deletions tests/foundry/src/ICS04Packet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ contract TestICS04Packet is
vm.expectRevert(
abi.encodeWithSelector(
IIBCChannelErrors.IBCChannelTimeoutPacketHeight.selector,
getBlockNumber(),
p0.timeoutHeight.revision_height
H(getBlockNumber()),
p0.timeoutHeight
)
);
counterpartyHandler.recvPacket(msg_);
Expand Down