Skip to content

Commit

Permalink
feat: updated lookahead buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshuJalan committed Oct 3, 2024
1 parent 6365096 commit 87d6aa4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions SmartContracts/src/avs/PreconfTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ contract PreconfTaskManager is IPreconfTaskManager, Initializable {

// A ring buffer of upcoming preconfers (who are also the L1 validators)
uint256 internal lookaheadTail;
uint256 internal constant LOOKAHEAD_BUFFER_SIZE = 64;
uint256 internal constant LOOKAHEAD_BUFFER_SIZE = 128;
LookaheadBufferEntry[LOOKAHEAD_BUFFER_SIZE] internal lookahead;

// A ring buffer that maps the block height to the associated proposer
// This is required since the stored block in Taiko has the address of this contract as the proposer
// Stores 2 epochs worth of L2 blocks = 256 (4 blocks / slot)
uint256 internal constant BLOCK_ID_TO_PROPOSER_BUFFER_SIZE = LOOKAHEAD_BUFFER_SIZE * 4;
uint256 internal constant BLOCK_ID_TO_PROPOSER_BUFFER_SIZE = PreconfConstants.TWO_EPOCHS * 4;
mapping(uint256 blockId_mod_BLOCK_ID_TO_PROPOSER_BUFFER_SIZE => ProposerInfo proposerInfo) internal
blockIdToProposer;

Expand Down
2 changes: 1 addition & 1 deletion SmartContracts/src/interfaces/IPreconfTaskManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ interface IPreconfTaskManager {
function getLookaheadTail() external view returns (uint256);

/// @dev Returns the entire lookahead buffer
function getLookaheadBuffer() external view returns (LookaheadBufferEntry[64] memory);
function getLookaheadBuffer() external view returns (LookaheadBufferEntry[128] memory);

/// @dev Returns the lookahead poster for an epoch
function getLookaheadPoster(uint256 epochTimestamp) external view returns (address);
Expand Down
2 changes: 1 addition & 1 deletion SmartContracts/test/blocks/BlockProposing.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract BlockProposing is BlocksFixtures {
preconfTaskManager.newBlockProposal("Block Params", "Txn List", 1, lookaheadSetParams);

// Verify that the lookahead for the next epoch has been updated
IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();

// Check the first entry
vm.assertEq(lookaheadBuffer[3].preconfer, addr_1);
Expand Down
4 changes: 2 additions & 2 deletions SmartContracts/test/lookahead/IncorrectLookahead.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ contract IncorrectLookahead is LookaheadFixtures {
nextEpochStart + PreconfConstants.SECONDS_IN_EPOCH - PreconfConstants.SECONDS_IN_SLOT;

// Verify that the lookahead has the fallback preconfer
IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[3].preconfer, addr_4);
vm.assertEq(lookaheadBuffer[3].timestamp, lastSlotTimestamp);
vm.assertEq(lookaheadBuffer[3].prevTimestamp, nextEpochStart - PreconfConstants.SECONDS_IN_SLOT);
Expand Down Expand Up @@ -343,7 +343,7 @@ contract IncorrectLookahead is LookaheadFixtures {
nextEpochStart + PreconfConstants.SECONDS_IN_EPOCH - PreconfConstants.SECONDS_IN_SLOT;

// Verify that the lookahead has the fallback preconfer
IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[3].preconfer, addr_4);
vm.assertEq(lookaheadBuffer[3].timestamp, lastSlotTimestamp);
vm.assertEq(lookaheadBuffer[3].prevTimestamp, nextEpochStart - PreconfConstants.SECONDS_IN_SLOT);
Expand Down
10 changes: 5 additions & 5 deletions SmartContracts/test/lookahead/LookaheadPosting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract LookaheadPosting is LookaheadFixtures {
uint256 lookaheadTail = preconfTaskManager.getLookaheadTail();
vm.assertEq(lookaheadTail, 1);

IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[1].preconfer, addr_1);
vm.assertEq(lookaheadBuffer[1].timestamp, nextEpochStart);
vm.assertEq(lookaheadBuffer[1].prevTimestamp, 0);
Expand Down Expand Up @@ -69,7 +69,7 @@ contract LookaheadPosting is LookaheadFixtures {
uint256 lookaheadTail = preconfTaskManager.getLookaheadTail();
vm.assertEq(lookaheadTail, 2);

IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[1].preconfer, addr_1);
vm.assertEq(lookaheadBuffer[1].timestamp, nextEpochStart);
vm.assertEq(lookaheadBuffer[1].prevTimestamp, 0);
Expand Down Expand Up @@ -112,7 +112,7 @@ contract LookaheadPosting is LookaheadFixtures {
uint256 lookaheadTail = preconfTaskManager.getLookaheadTail();
vm.assertEq(lookaheadTail, 3);

IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[1].preconfer, addr_1);
vm.assertEq(lookaheadBuffer[1].timestamp, nextEpochStart);
vm.assertEq(lookaheadBuffer[1].prevTimestamp, 0);
Expand Down Expand Up @@ -161,7 +161,7 @@ contract LookaheadPosting is LookaheadFixtures {
vm.assertEq(lookaheadTail, 1);

// Verify that addr_4 is inserted as fallback preconfer in lookahead buffer
IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[1].preconfer, addr_4);
vm.assertEq(lookaheadBuffer[1].timestamp, lastSlotTimestampInNextEpoch);
vm.assertEq(lookaheadBuffer[1].prevTimestamp, 0);
Expand Down Expand Up @@ -201,7 +201,7 @@ contract LookaheadPosting is LookaheadFixtures {
vm.assertEq(lookaheadTail, 1);

// Verify that addr_4 is inserted as fallback preconfer in lookahead buffer
IPreconfTaskManager.LookaheadBufferEntry[64] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
IPreconfTaskManager.LookaheadBufferEntry[128] memory lookaheadBuffer = preconfTaskManager.getLookaheadBuffer();
vm.assertEq(lookaheadBuffer[1].preconfer, addr_4);
vm.assertEq(lookaheadBuffer[1].timestamp, lastSlotTimestampInNextEpoch);
vm.assertEq(lookaheadBuffer[1].prevTimestamp, 0);
Expand Down

0 comments on commit 87d6aa4

Please sign in to comment.