From 4316b5eb7626b7fada2d49a00d150051f018afff Mon Sep 17 00:00:00 2001 From: Masanori Yoshida Date: Tue, 8 Oct 2024 23:40:33 +0900 Subject: [PATCH] fix proposeAppVersion to always set false initially to AppInfo.consumed Signed-off-by: Masanori Yoshida --- contracts/IBCContractUpgradableModule.sol | 10 ++++--- contracts/IIBCContractUpgradableModule.sol | 2 +- .../iibccontractupgradablemodule.go | 26 +++++++++---------- pkg/relay/ethereum/upgrade.go | 6 ++--- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/contracts/IBCContractUpgradableModule.sol b/contracts/IBCContractUpgradableModule.sol index 546f04a..9045f27 100644 --- a/contracts/IBCContractUpgradableModule.sol +++ b/contracts/IBCContractUpgradableModule.sol @@ -44,12 +44,12 @@ abstract contract IBCContractUpgradableModuleBase is /** * @dev See {IIBCContractUpgradableModule-proposeAppVersion} */ - function proposeAppVersion(string calldata version, AppInfo calldata appInfo_) + function proposeAppVersion(string calldata version, address implementation, bytes calldata initialCalldata) external override(IIBCContractUpgradableModule) onlyContractUpgrader { - if (appInfo_.implementation == address(0)) { + if (implementation == address(0)) { revert IBCContractUpgradableModuleAppInfoProposedWithZeroImpl(); } @@ -58,7 +58,11 @@ abstract contract IBCContractUpgradableModuleBase is revert IBCContractUpgradableModuleAppInfoIsAlreadySet(); } - appInfos[version] = appInfo_; + appInfos[version] = AppInfo({ + implementation: implementation, + initialCalldata: initialCalldata, + consumed: false + }); } /** diff --git a/contracts/IIBCContractUpgradableModule.sol b/contracts/IIBCContractUpgradableModule.sol index 15e5639..fd0f04b 100644 --- a/contracts/IIBCContractUpgradableModule.sol +++ b/contracts/IIBCContractUpgradableModule.sol @@ -40,7 +40,7 @@ interface IIBCContractUpgradableModule { * To upgrade the IBC module contract along with a channel upgrade, the upgrader must * call this function before calling `channelUpgradeInit` or `channelUpgradeTry` of the IBC handler. */ - function proposeAppVersion(string calldata version, AppInfo calldata appInfo) external; + function proposeAppVersion(string calldata version, address implementation, bytes calldata initialCalldata) external; } diff --git a/pkg/contract/iibccontractupgradablemodule/iibccontractupgradablemodule.go b/pkg/contract/iibccontractupgradablemodule/iibccontractupgradablemodule.go index 7fb3aef..23d63ff 100644 --- a/pkg/contract/iibccontractupgradablemodule/iibccontractupgradablemodule.go +++ b/pkg/contract/iibccontractupgradablemodule/iibccontractupgradablemodule.go @@ -38,7 +38,7 @@ type IIBCContractUpgradableModuleAppInfo struct { // IibccontractupgradablemoduleMetaData contains all meta data concerning the Iibccontractupgradablemodule contract. var IibccontractupgradablemoduleMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"getAppInfoProposal\",\"inputs\":[{\"name\":\"version\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIIBCContractUpgradableModule.AppInfo\",\"components\":[{\"name\":\"implementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"initialCalldata\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"consumed\",\"type\":\"bool\",\"internalType\":\"bool\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proposeAppVersion\",\"inputs\":[{\"name\":\"version\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"appInfo\",\"type\":\"tuple\",\"internalType\":\"structIIBCContractUpgradableModule.AppInfo\",\"components\":[{\"name\":\"implementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"initialCalldata\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"consumed\",\"type\":\"bool\",\"internalType\":\"bool\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"}]", + ABI: "[{\"type\":\"function\",\"name\":\"getAppInfoProposal\",\"inputs\":[{\"name\":\"version\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIIBCContractUpgradableModule.AppInfo\",\"components\":[{\"name\":\"implementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"initialCalldata\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"consumed\",\"type\":\"bool\",\"internalType\":\"bool\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"proposeAppVersion\",\"inputs\":[{\"name\":\"version\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"implementation\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"initialCalldata\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"}]", } // IibccontractupgradablemoduleABI is the input ABI used to generate the binding from. @@ -218,23 +218,23 @@ func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleCallerSession) return _Iibccontractupgradablemodule.Contract.GetAppInfoProposal(&_Iibccontractupgradablemodule.CallOpts, version) } -// ProposeAppVersion is a paid mutator transaction binding the contract method 0x347501f8. +// ProposeAppVersion is a paid mutator transaction binding the contract method 0xd7c317e9. // -// Solidity: function proposeAppVersion(string version, (address,bytes,bool) appInfo) returns() -func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleTransactor) ProposeAppVersion(opts *bind.TransactOpts, version string, appInfo IIBCContractUpgradableModuleAppInfo) (*types.Transaction, error) { - return _Iibccontractupgradablemodule.contract.Transact(opts, "proposeAppVersion", version, appInfo) +// Solidity: function proposeAppVersion(string version, address implementation, bytes initialCalldata) returns() +func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleTransactor) ProposeAppVersion(opts *bind.TransactOpts, version string, implementation common.Address, initialCalldata []byte) (*types.Transaction, error) { + return _Iibccontractupgradablemodule.contract.Transact(opts, "proposeAppVersion", version, implementation, initialCalldata) } -// ProposeAppVersion is a paid mutator transaction binding the contract method 0x347501f8. +// ProposeAppVersion is a paid mutator transaction binding the contract method 0xd7c317e9. // -// Solidity: function proposeAppVersion(string version, (address,bytes,bool) appInfo) returns() -func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleSession) ProposeAppVersion(version string, appInfo IIBCContractUpgradableModuleAppInfo) (*types.Transaction, error) { - return _Iibccontractupgradablemodule.Contract.ProposeAppVersion(&_Iibccontractupgradablemodule.TransactOpts, version, appInfo) +// Solidity: function proposeAppVersion(string version, address implementation, bytes initialCalldata) returns() +func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleSession) ProposeAppVersion(version string, implementation common.Address, initialCalldata []byte) (*types.Transaction, error) { + return _Iibccontractupgradablemodule.Contract.ProposeAppVersion(&_Iibccontractupgradablemodule.TransactOpts, version, implementation, initialCalldata) } -// ProposeAppVersion is a paid mutator transaction binding the contract method 0x347501f8. +// ProposeAppVersion is a paid mutator transaction binding the contract method 0xd7c317e9. // -// Solidity: function proposeAppVersion(string version, (address,bytes,bool) appInfo) returns() -func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleTransactorSession) ProposeAppVersion(version string, appInfo IIBCContractUpgradableModuleAppInfo) (*types.Transaction, error) { - return _Iibccontractupgradablemodule.Contract.ProposeAppVersion(&_Iibccontractupgradablemodule.TransactOpts, version, appInfo) +// Solidity: function proposeAppVersion(string version, address implementation, bytes initialCalldata) returns() +func (_Iibccontractupgradablemodule *IibccontractupgradablemoduleTransactorSession) ProposeAppVersion(version string, implementation common.Address, initialCalldata []byte) (*types.Transaction, error) { + return _Iibccontractupgradablemodule.Contract.ProposeAppVersion(&_Iibccontractupgradablemodule.TransactOpts, version, implementation, initialCalldata) } diff --git a/pkg/relay/ethereum/upgrade.go b/pkg/relay/ethereum/upgrade.go index 417ff7e..6c557e6 100644 --- a/pkg/relay/ethereum/upgrade.go +++ b/pkg/relay/ethereum/upgrade.go @@ -136,10 +136,8 @@ func (c *Chain) ProposeAppVersion( tx, err := mockApp.ProposeAppVersion( txOpts, version, - iibccontractupgradablemodule.IIBCContractUpgradableModuleAppInfo{ - Implementation: implementation, - InitialCalldata: initialCalldata, - }, + implementation, + initialCalldata, ) return processSendTxResult(ctx, logger, c, tx, err)