Skip to content

Commit

Permalink
chore: deleted dispatch timestamp info event
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikelle committed Jun 6, 2024
1 parent 0a84caf commit 08a135d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 220 deletions.
25 changes: 0 additions & 25 deletions contracts-abi/abi/PreConfCommitmentStore.abi
Original file line number Diff line number Diff line change
Expand Up @@ -1140,31 +1140,6 @@
],
"anonymous": false
},
{
"type": "event",
"name": "DispatchTimestampInfo",
"inputs": [
{
"name": "dispatchTimestamp",
"type": "uint64",
"indexed": false,
"internalType": "uint64"
},
{
"name": "blockTimestamp",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "commitmentDispatchWindow",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"type": "event",
"name": "EncryptedCommitmentStored",
Expand Down

Large diffs are not rendered by default.

16 changes: 1 addition & 15 deletions contracts/contracts/PreConfCommitmentStore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
uint64 blockNumber
);

event DispatchTimestampInfo(
uint64 dispatchTimestamp,
uint256 blockTimestamp,
uint256 commitmentDispatchWindow
);

/**
* @dev fallback to revert all the calls.
*/
Expand Down Expand Up @@ -516,15 +510,7 @@ contract PreConfCommitmentStore is OwnableUpgradeable {
uint256 minTime = block.timestamp - commitmentDispatchWindow;

// Check if the dispatch timestamp is within the allowed dispatch window
if (dispatchTimestamp < minTime) {
// Emit an event if the dispatch timestamp is too old
emit DispatchTimestampInfo(
dispatchTimestamp,
block.timestamp,
commitmentDispatchWindow
);
return 0x0; // Return 0x0 if the dispatch timestamp is invalid
}
require(dispatchTimestamp > minTime, "Invalid dispatch timestamp");

address commiterAddress = commitmentDigest.recover(commitmentSignature);

Expand Down
30 changes: 5 additions & 25 deletions contracts/test/PreConfirmationConfTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ contract TestPreConfCommitmentStore is Test {

BidderRegistry internal bidderRegistry;

event DispatchTimestampInfo(
uint64 dispatchTimestamp,
uint256 blockTimestamp,
uint256 commitmentDispatchWindow
);

function setUp() public {
_testCommitmentAliceBob = TestCommitment(
2,
Expand Down Expand Up @@ -184,13 +178,8 @@ contract TestPreConfCommitmentStore is Test {
vm.prank(committer);

vm.warp(1000);
uint64 commitmentDispatchWindow = 500;
// Expect the DispatchTimestampInfo event
vm.expectEmit(true, true, true, true);
emit DispatchTimestampInfo(
_testCommitmentAliceBob.dispatchTimestamp,
block.timestamp,
commitmentDispatchWindow
vm.expectRevert(
"Invalid dispatch timestamp"
);

preConfCommitmentStore.storeEncryptedCommitment(
Expand All @@ -212,21 +201,12 @@ contract TestPreConfCommitmentStore is Test {
);
bytes memory commitmentSignature = abi.encodePacked(r, s, v);

// Update the commitment dispatch window
vm.prank(preConfCommitmentStore.owner());
preConfCommitmentStore.updateCommitmentDispatchWindow(200);

// Warp to a time outside the new commitment dispatch window
vm.warp(201 + _testCommitmentAliceBob.dispatchTimestamp);

// Expect the DispatchTimestampInfo event
vm.expectEmit(true, true, true, true);
emit DispatchTimestampInfo(
_testCommitmentAliceBob.dispatchTimestamp,
block.timestamp,
preConfCommitmentStore.commitmentDispatchWindow()
vm.warp(200 + _testCommitmentAliceBob.dispatchTimestamp);
vm.expectRevert(
"Invalid dispatch timestamp"
);

preConfCommitmentStore.storeEncryptedCommitment(
commitmentDigest,
commitmentSignature,
Expand Down
18 changes: 0 additions & 18 deletions p2p/pkg/preconfirmation/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type Tracker struct {
newL1Blocks chan *blocktracker.BlocktrackerNewL1Block
enryptedCmts chan *preconfcommstore.PreconfcommitmentstoreEncryptedCommitmentStored
commitments chan *preconfcommstore.PreconfcommitmentstoreCommitmentStored
dtis chan *preconfcommstore.PreconfcommitmentstoreDispatchTimestampInfo
winners map[int64]*blocktracker.BlocktrackerNewL1Block
metrics *metrics
logger *slog.Logger
Expand Down Expand Up @@ -80,7 +79,6 @@ func NewTracker(
newL1Blocks: make(chan *blocktracker.BlocktrackerNewL1Block),
enryptedCmts: make(chan *preconfcommstore.PreconfcommitmentstoreEncryptedCommitmentStored),
commitments: make(chan *preconfcommstore.PreconfcommitmentstoreCommitmentStored),
dtis: make(chan *preconfcommstore.PreconfcommitmentstoreDispatchTimestampInfo),
winners: make(map[int64]*blocktracker.BlocktrackerNewL1Block),
metrics: newMetrics(),
logger: logger,
Expand Down Expand Up @@ -111,15 +109,6 @@ func (t *Tracker) Start(ctx context.Context) <-chan struct{} {
}
},
),
events.NewEventHandler(
"DispatchTimestampInfo",
func(dti *preconfcommstore.PreconfcommitmentstoreDispatchTimestampInfo) {
select {
case <-egCtx.Done():
case t.dtis <- dti:
}
},
),
}

if t.peerType == p2p.PeerTypeBidder {
Expand Down Expand Up @@ -185,13 +174,6 @@ func (t *Tracker) Start(ctx context.Context) <-chan struct{} {
if err := t.handleCommitmentStored(egCtx, cs); err != nil {
return err
}
case dti := <-t.dtis:
t.logger.Info(
"dispatch timestamp info",
"dispatchTimestamp", dti.DispatchTimestamp,
"blockTimestamp", dti.BlockTimestamp,
"commitmentDispatchWindow", dti.CommitmentDispatchWindow,
)
}
}
})
Expand Down

0 comments on commit 08a135d

Please sign in to comment.