From 331107f48651099fa3f119847cbc0f5d645469f4 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Thu, 8 Jun 2023 15:29:29 +0000 Subject: [PATCH 01/10] add revive method and ExpiredMerkleUpdate event to ArbRetryableTx --- src/precompiles/ArbRetryableTx.sol | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 3de17ea1..52a34851 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -40,6 +40,28 @@ interface ArbRetryableTx { */ function keepalive(bytes32 ticketId) external returns (uint256); + /** + * @notice Brings back to life ticketId. + * Donate gas to pay for the lifetime extension. + * If successful, emits LifetimeExtended event. + * Revert if wrong proof or ticketId was already revived. + * TODO(magic) + * @param ticketId unique ticket identifier + * @return new timeout of ticketId + */ + function revive( + bytes32 ticketId, + uint64 numTries, + address from, + address to, + uint256 callvalue, + address beneficiary, + bytes calldata retryData, + bytes32 rootHash, + uint64 leafIndex, + bytes32[] calldata proof + ) external returns (uint256); + /** * @notice Return the beneficiary of ticketId. * Revert if ticketId doesn't exist. @@ -96,6 +118,13 @@ interface ArbRetryableTx { /// @dev DEPRECATED in favour of new RedeemScheduled event after the nitro upgrade event Redeemed(bytes32 indexed userTxHash); + /** + * @notice logs a merkle branch for expired proof synthesis + * @param hash the merkle hash + * @param position = (level << 192) + leaf + */ + event ExpiredMerkleUpdate(bytes32 indexed hash, uint256 indexed position); + error NoTicketWithID(); error NotCallable(); } From 3e9a70dfa7b7fbe2de4938b49cd6f58e32fccaa0 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Thu, 15 Jun 2023 00:43:37 +0000 Subject: [PATCH 02/10] add RetryableExpired event --- src/precompiles/ArbRetryableTx.sol | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 52a34851..02e6c51f 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -125,6 +125,14 @@ interface ArbRetryableTx { */ event ExpiredMerkleUpdate(bytes32 indexed hash, uint256 indexed position); + /** + * @notice logs a merkle leaf for expired proof synthesis + * @param ticketId unique ticket identifier + * @param hash the merkle hash + * @param position = (level << 192) + leaf + */ + event RetryableExpired(bytes32 indexed ticketId, bytes32 indexed hash, uint256 indexed position); + error NoTicketWithID(); error NotCallable(); } From 88c37ad8687d0953e1087fcd7cb8c5c851667703 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Thu, 15 Jun 2023 01:09:06 +0000 Subject: [PATCH 03/10] fix whitespaces --- src/precompiles/ArbRetryableTx.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 02e6c51f..8cff7cd9 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -125,13 +125,17 @@ interface ArbRetryableTx { */ event ExpiredMerkleUpdate(bytes32 indexed hash, uint256 indexed position); - /** + /** * @notice logs a merkle leaf for expired proof synthesis * @param ticketId unique ticket identifier * @param hash the merkle hash * @param position = (level << 192) + leaf */ - event RetryableExpired(bytes32 indexed ticketId, bytes32 indexed hash, uint256 indexed position); + event RetryableExpired( + bytes32 indexed ticketId, + bytes32 indexed hash, + uint256 indexed position + ); error NoTicketWithID(); error NotCallable(); From 21a91d7baf95d72c05c0478d764e75240076cbbc Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Wed, 28 Jun 2023 16:59:10 +0000 Subject: [PATCH 04/10] add NumTries to RetryableExpired event --- src/precompiles/ArbRetryableTx.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 8cff7cd9..8406e31a 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -132,9 +132,10 @@ interface ArbRetryableTx { * @param position = (level << 192) + leaf */ event RetryableExpired( - bytes32 indexed ticketId, bytes32 indexed hash, - uint256 indexed position + uint256 indexed position, + bytes32 indexed ticketId, + uint64 numTries ); error NoTicketWithID(); From 791315ea879c5a1988ffae37145b319d3f05d70a Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Fri, 30 Jun 2023 02:29:52 +0000 Subject: [PATCH 05/10] add revival errors to ArbRetryableTx --- src/precompiles/ArbRetryableTx.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 8406e31a..3a26c62c 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -140,4 +140,7 @@ interface ArbRetryableTx { error NoTicketWithID(); error NotCallable(); + error AlreadyRevived(); + error InvalidRootHash(); + error WrongProof(); } From 871cee6daa4f764d1fb4fe29d2ef7e7b2eb89bf7 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Fri, 7 Jul 2023 16:28:14 +0000 Subject: [PATCH 06/10] add ExpiredMerkleRootSnapshot event --- src/precompiles/ArbRetryableTx.sol | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 257e402f..7f1b761d 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -125,11 +125,19 @@ interface ArbRetryableTx { */ event ExpiredMerkleUpdate(bytes32 indexed hash, uint256 indexed position); + /** + * @notice logs a merkle root snapshot for expired proof synthesis + * @param root the merkle root + * @param timestamp the snapshot timestamp + */ + event ExpiredMerkleRootSnapshot(bytes32 indexed root, uint64 indexed timestamp); + /** * @notice logs a merkle leaf for expired proof synthesis * @param ticketId unique ticket identifier * @param hash the merkle hash * @param position = (level << 192) + leaf + * @param numTries number of pre-expiry retries */ event RetryableExpired( bytes32 indexed hash, From e672b01c415c61afccbda623472704db7e7e0752 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 11 Jul 2023 13:44:55 +0000 Subject: [PATCH 07/10] add number of leaves to ExpiredMerkleRootSnapshot, update comment --- src/precompiles/ArbRetryableTx.sol | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 7f1b761d..9edb42c4 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -44,9 +44,16 @@ interface ArbRetryableTx { * @notice Brings back to life ticketId. * Donate gas to pay for the lifetime extension. * If successful, emits LifetimeExtended event. - * Revert if wrong proof or ticketId was already revived. - * TODO(magic) + * Revert if proof is wrong or ticketId was already revived. * @param ticketId unique ticket identifier + * @param numTries number of pre-expiry retries + * @param from address of the retryable submitter + * @param to retryable's recipient + * @param callvalue retryable's callvalue + * @param beneficiary retryable's benficiary + * @param rootHash the merkle root to prove against + * @param leafIndex merkle leaf index that is proved + * @param proof merkle proof of the retryable's inclusion in expired accumulator * @return new timeout of ticketId */ function revive( @@ -128,9 +135,10 @@ interface ArbRetryableTx { /** * @notice logs a merkle root snapshot for expired proof synthesis * @param root the merkle root - * @param timestamp the snapshot timestamp + * @param numLeaves number of leaves in the merkle accumulator + * @param timestamp the snapshot's timestamp */ - event ExpiredMerkleRootSnapshot(bytes32 indexed root, uint64 indexed timestamp); + event ExpiredMerkleRootSnapshot(bytes32 indexed root, uint64 indexed numLeaves, uint64 indexed timestamp); /** * @notice logs a merkle leaf for expired proof synthesis From 31473f5aeec9c9cff00f0f6aa2c39bea809c3aa1 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 11 Jul 2023 17:25:32 +0000 Subject: [PATCH 08/10] fix lint --- src/precompiles/ArbRetryableTx.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 9edb42c4..ba784171 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -138,7 +138,11 @@ interface ArbRetryableTx { * @param numLeaves number of leaves in the merkle accumulator * @param timestamp the snapshot's timestamp */ - event ExpiredMerkleRootSnapshot(bytes32 indexed root, uint64 indexed numLeaves, uint64 indexed timestamp); + event ExpiredMerkleRootSnapshot( + bytes32 indexed root, + uint64 indexed numLeaves, + uint64 indexed timestamp + ); /** * @notice logs a merkle leaf for expired proof synthesis From b73181034e5c560e2a0f7fb0aa28dd81ac432b63 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Wed, 12 Jul 2023 00:27:46 +0000 Subject: [PATCH 09/10] remove timestamp from ExpiredMerkleRootSnapshot event --- src/precompiles/ArbRetryableTx.sol | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index ba784171..7660ba4d 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -136,13 +136,8 @@ interface ArbRetryableTx { * @notice logs a merkle root snapshot for expired proof synthesis * @param root the merkle root * @param numLeaves number of leaves in the merkle accumulator - * @param timestamp the snapshot's timestamp */ - event ExpiredMerkleRootSnapshot( - bytes32 indexed root, - uint64 indexed numLeaves, - uint64 indexed timestamp - ); + event ExpiredMerkleRootSnapshot(bytes32 indexed root, uint64 indexed numLeaves); /** * @notice logs a merkle leaf for expired proof synthesis From 6cd38e743e88abc3b0c28276c276d8ccb7dab6af Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Thu, 13 Jul 2023 14:25:45 +0000 Subject: [PATCH 10/10] add getLastExpiredRootSnapshot method, remove ExpiredMerkleRootSnapshot event --- src/precompiles/ArbRetryableTx.sol | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/precompiles/ArbRetryableTx.sol b/src/precompiles/ArbRetryableTx.sol index 7660ba4d..6a296356 100644 --- a/src/precompiles/ArbRetryableTx.sol +++ b/src/precompiles/ArbRetryableTx.sol @@ -69,6 +69,11 @@ interface ArbRetryableTx { bytes32[] calldata proof ) external returns (uint256); + /** + * @notice Return root hash and tree size from last expired root snapshot + */ + function getLastExpiredRootSnapshot() external view returns (bytes32, uint64); + /** * @notice Return the beneficiary of ticketId. * Revert if ticketId doesn't exist. @@ -132,13 +137,6 @@ interface ArbRetryableTx { */ event ExpiredMerkleUpdate(bytes32 indexed hash, uint256 indexed position); - /** - * @notice logs a merkle root snapshot for expired proof synthesis - * @param root the merkle root - * @param numLeaves number of leaves in the merkle accumulator - */ - event ExpiredMerkleRootSnapshot(bytes32 indexed root, uint64 indexed numLeaves); - /** * @notice logs a merkle leaf for expired proof synthesis * @param ticketId unique ticket identifier