From 1f9284c7f976ba0322b321025689e0732e856e9a Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 14 Feb 2023 17:24:52 +0800 Subject: [PATCH 1/3] featI(protocol): delete commit records differently --- packages/protocol/contracts/L1/libs/LibProposing.sol | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/L1/libs/LibProposing.sol index c76b7e53cd..284742e02e 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/L1/libs/LibProposing.sol @@ -51,6 +51,7 @@ library LibProposing { if (state.commits[msg.sender][commitSlot] == hash) revert L1_COMMITTED(); + state.commits[msg.sender][commitSlot] = hash; emit BlockCommitted({ @@ -236,9 +237,14 @@ library LibProposing { }) ) revert L1_NOT_COMMITTED(); - if (meta.commitSlot == 0) { - // Special handling of slot 0 for refund; non-zero slots - // are supposed to managed by node software for reuse. + if (meta.commitSlot % 2 == 0) { + // Using an even muber as the commit slot will make + // the corresponding block proposal cheaper as the + // commit record will be deleted when block is + // proposed; + // Using an odd number will allows another block commmit + // to reuse a previous commit's storage thus new commits + // are cheaper. delete state.commits[msg.sender][meta.commitSlot]; } } From b0e8d541169074218d6dee72b561cb73bdab7598 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 14 Feb 2023 17:28:42 +0800 Subject: [PATCH 2/3] Update LibProposing.sol --- .../protocol/contracts/L1/libs/LibProposing.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/L1/libs/LibProposing.sol index 284742e02e..5ecb8e9369 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/L1/libs/LibProposing.sol @@ -238,13 +238,13 @@ library LibProposing { ) revert L1_NOT_COMMITTED(); if (meta.commitSlot % 2 == 0) { - // Using an even muber as the commit slot will make - // the corresponding block proposal cheaper as the - // commit record will be deleted when block is - // proposed; - // Using an odd number will allows another block commmit - // to reuse a previous commit's storage thus new commits - // are cheaper. + // Using an even number as the commit slot will + // make the corresponding block proposal cheaper + // as the commit record will be deleted when the + // block is proposed; + // Using an odd number will allow new commits to + // reuse a previous commit's storage thus new + // commits are cheaper. delete state.commits[msg.sender][meta.commitSlot]; } } From 7d9f4bf4f1e11cbf930bd73490129bcb0393b7f1 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Tue, 14 Feb 2023 21:28:31 +0800 Subject: [PATCH 3/3] Update LibProposing.sol --- packages/protocol/contracts/L1/libs/LibProposing.sol | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/L1/libs/LibProposing.sol index 5ecb8e9369..3ce587aff3 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/L1/libs/LibProposing.sol @@ -236,17 +236,6 @@ library LibProposing { commitHash: commitHash }) ) revert L1_NOT_COMMITTED(); - - if (meta.commitSlot % 2 == 0) { - // Using an even number as the commit slot will - // make the corresponding block proposal cheaper - // as the commit record will be deleted when the - // block is proposed; - // Using an odd number will allow new commits to - // reuse a previous commit's storage thus new - // commits are cheaper. - delete state.commits[msg.sender][meta.commitSlot]; - } } function _validateMetadata(