-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Config Change] Removes HardReorg config from InboxReader #2542
base: master
Are you sure you want to change the base?
Changes from 3 commits
2737e35
94a07f0
176ffb3
4f8f862
fa075bf
80bfa33
6eb2896
241aed5
22bd828
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,22 @@ func TestSequencerReorgFromDelayed(t *testing.T) { | |
}, | ||
}, | ||
} | ||
err = tracker.AddDelayedMessages([]*DelayedInboxMessage{initMsgDelayed, userDelayed}, false) | ||
delayedRequestId2 := common.BigToHash(common.Big2) | ||
userDelayed2 := &DelayedInboxMessage{ | ||
BlockHash: [32]byte{}, | ||
BeforeInboxAcc: userDelayed.AfterInboxAcc(), | ||
Message: &arbostypes.L1IncomingMessage{ | ||
Header: &arbostypes.L1IncomingMessageHeader{ | ||
Kind: arbostypes.L1MessageType_EndOfBlock, | ||
Poster: [20]byte{}, | ||
BlockNumber: 0, | ||
Timestamp: 0, | ||
RequestId: &delayedRequestId2, | ||
L1BaseFee: common.Big0, | ||
}, | ||
}, | ||
} | ||
err = tracker.AddDelayedMessages([]*DelayedInboxMessage{initMsgDelayed, userDelayed, userDelayed2}) | ||
Require(t, err) | ||
|
||
serializedInitMsgBatch := make([]byte, 40) | ||
|
@@ -75,8 +90,8 @@ func TestSequencerReorgFromDelayed(t *testing.T) { | |
SequenceNumber: 1, | ||
BeforeInboxAcc: [32]byte{1}, | ||
AfterInboxAcc: [32]byte{2}, | ||
AfterDelayedAcc: userDelayed.AfterInboxAcc(), | ||
AfterDelayedCount: 2, | ||
AfterDelayedAcc: userDelayed2.AfterInboxAcc(), | ||
AfterDelayedCount: 3, | ||
TimeBounds: bridgegen.IBridgeTimeBounds{}, | ||
rawLog: types.Log{}, | ||
dataLocation: 0, | ||
|
@@ -89,8 +104,8 @@ func TestSequencerReorgFromDelayed(t *testing.T) { | |
SequenceNumber: 2, | ||
BeforeInboxAcc: [32]byte{2}, | ||
AfterInboxAcc: [32]byte{3}, | ||
AfterDelayedAcc: userDelayed.AfterInboxAcc(), | ||
AfterDelayedCount: 2, | ||
AfterDelayedAcc: userDelayed2.AfterInboxAcc(), | ||
AfterDelayedCount: 3, | ||
TimeBounds: bridgegen.IBridgeTimeBounds{}, | ||
rawLog: types.Log{}, | ||
dataLocation: 0, | ||
|
@@ -100,20 +115,61 @@ func TestSequencerReorgFromDelayed(t *testing.T) { | |
err = tracker.AddSequencerBatches(ctx, nil, []*SequencerInboxBatch{initMsgBatch, userMsgBatch, emptyBatch}) | ||
Require(t, err) | ||
|
||
// Reorg out the user delayed message | ||
err = tracker.ReorgDelayedTo(1, true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of just removing this test, we should instead have this test insert an alternative delayed message at position 1 which would cause the same reorg. Instead of getting the delayed count below, we could then get the delayed message to ensure it changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I adjusted the test to trigger a reorg by adding an alternative delayed message through AddDelayedMessages as you mentioned, but the strategy that I implemented is a little bit different than the one you described. |
||
msgCount, err := streamer.GetMessageCount() | ||
Require(t, err) | ||
if msgCount != 3 { | ||
Fail(t, "Unexpected tx streamer message count", msgCount, "(expected 3)") | ||
} | ||
|
||
msgCount, err := streamer.GetMessageCount() | ||
delayedCount, err := tracker.GetDelayedCount() | ||
Require(t, err) | ||
if delayedCount != 3 { | ||
Fail(t, "Unexpected tracker delayed message count", delayedCount, "(expected 3)") | ||
} | ||
|
||
// By modifying the timestamp of the userDelayed message, and adding it again, we remove userDelayed2 message. | ||
userDelayedModified := &DelayedInboxMessage{ | ||
BlockHash: [32]byte{}, | ||
BeforeInboxAcc: initMsgDelayed.AfterInboxAcc(), | ||
Message: &arbostypes.L1IncomingMessage{ | ||
Header: &arbostypes.L1IncomingMessageHeader{ | ||
Kind: arbostypes.L1MessageType_EndOfBlock, | ||
Poster: [20]byte{}, | ||
BlockNumber: 0, | ||
Timestamp: userDelayed.Message.Header.Timestamp + 1, | ||
RequestId: &delayedRequestId, | ||
L1BaseFee: common.Big0, | ||
}, | ||
}, | ||
} | ||
err = tracker.AddDelayedMessages([]*DelayedInboxMessage{userDelayedModified}) | ||
joshuacolvin0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Require(t, err) | ||
|
||
// userMsgBatch, and emptyBatch will be deleted since their AfterDelayedAcc are not valid anymore after the reorg | ||
msgCount, err = streamer.GetMessageCount() | ||
Require(t, err) | ||
if msgCount != 1 { | ||
Fail(t, "Unexpected tx streamer message count", msgCount, "(expected 1)") | ||
} | ||
|
||
delayedCount, err := tracker.GetDelayedCount() | ||
// userDelayed2 will be deleted since its AfterDelayedAcc is not valid anymore after the reorg | ||
delayedCount, err = tracker.GetDelayedCount() | ||
Require(t, err) | ||
if delayedCount != 1 { | ||
Fail(t, "Unexpected tracker delayed message count", delayedCount, "(expected 1)") | ||
if delayedCount != 2 { | ||
Fail(t, "Unexpected tracker delayed message count", delayedCount, "(expected 2)") | ||
} | ||
|
||
// guarantees that delayed msg 1 is userDelayedModified and not userDelayed | ||
msg, err := tracker.GetDelayedMessage(ctx, 1) | ||
Require(t, err) | ||
if msg.Header.RequestId.Cmp(*userDelayedModified.Message.Header.RequestId) != 0 { | ||
Fail(t, "Unexpected delayed message requestId", msg.Header.RequestId, "(expected", userDelayedModified.Message.Header.RequestId, ")") | ||
} | ||
if msg.Header.Timestamp != userDelayedModified.Message.Header.Timestamp { | ||
Fail(t, "Unexpected delayed message timestamp", msg.Header.Timestamp, "(expected", userDelayedModified.Message.Header.Timestamp, ")") | ||
} | ||
if userDelayedModified.Message.Header.Timestamp == userDelayed.Message.Header.Timestamp { | ||
Fail(t, "Unexpected delayed message timestamp", userDelayedModified.Message.Header.Timestamp, "(expected", userDelayed.Message.Header.Timestamp, ")") | ||
} | ||
|
||
batchCount, err := tracker.GetBatchCount() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really think it would improve the readability of these tests if we made a little helper method that could return a DelayedInboxMessage built from just the important arguments from the test case. For example, I think the only thing that matters here is that the first message uses
delayedRequestId
and the second one usesdealyedRequestId2
, but I have to actually scan all of the lines between 38-51 and between 53-66 to be sure that something else doesn't differ between the two messages.Also, if it weren't for your comment on line 137, I wouldn't have noticed that the timestamp was different. But, that would have been really clear if we used a helper function to get a "normal" DelayedInboxMessage and then modified the fields on the struct we wanted to change for the test.