Skip to content

Commit

Permalink
Merge branch '4844-only' into 4844-with-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Jan 17, 2024
2 parents 7bbfa8d + 229eb59 commit 071e4fe
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 48 deletions.
12 changes: 10 additions & 2 deletions src/bridge/ISequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,16 @@ interface ISequencerInbox is IDelayedMessageProvider {
uint64 creationBlock;
}

/// @notice Returns the max time variation settings for this sequencer inbox
function maxTimeVariation() external view returns (ISequencerInbox.MaxTimeVariation memory);
/// @dev returns 4 uint256 to be compatible with older version
function maxTimeVariation()
external
view
returns (
uint256 delayBlocks,
uint256 futureBlocks,
uint256 delaySeconds,
uint256 futureSeconds
);

function dasKeySetInfo(bytes32) external view returns (bool, uint64);

Expand Down
24 changes: 16 additions & 8 deletions src/bridge/SequencerInbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,29 @@ contract SequencerInbox is GasRefundEnabled, ISequencerInbox {
return bounds;
}

function maxTimeVariation() public view returns (ISequencerInbox.MaxTimeVariation memory) {
function maxTimeVariation()
external
view
returns (
uint256,
uint256,
uint256,
uint256
)
{
(
uint64 delayBlocks_,
uint64 futureBlocks_,
uint64 delaySeconds_,
uint64 futureSeconds_
) = maxTimeVariationInternal();

return
ISequencerInbox.MaxTimeVariation({
delayBlocks: delayBlocks_,
futureBlocks: futureBlocks_,
delaySeconds: delaySeconds_,
futureSeconds: futureSeconds_
});
return (
uint256(delayBlocks_),
uint256(futureBlocks_),
uint256(delaySeconds_),
uint256(futureSeconds_)
);
}

function maxTimeVariationInternal()
Expand Down
62 changes: 34 additions & 28 deletions test/contract/sequencerInbox.spec.4844.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ describe('SequencerInbox', async () => {
await rollupOwner.getAddress()
)

const dataHashReader = await Toolkit4844.deployDataHashReader(fundingWallet)
const blobBasefeeReader = await Toolkit4844.deployBlobBasefeeReader(fundingWallet)
const sequencerInboxFac = (await ethers.getContractFactory(
'SequencerInbox'
)) as SequencerInbox__factory
const seqInboxTemplate = await sequencerInboxFac.deploy(
117964,
dataHashReader.address,
blobBasefeeReader.address
)
const inboxFac = new Inbox__factory(deployer)
const inboxTemplate = await inboxFac.deploy(117964)

Expand All @@ -289,40 +299,34 @@ describe('SequencerInbox', async () => {
adminAddr,
'0x'
)

const sequencerInboxProxy = await transparentUpgradeableProxyFac.deploy(
seqInboxTemplate.address,
adminAddr,
'0x'
)
const inboxProxy = await transparentUpgradeableProxyFac.deploy(
inboxTemplate.address,
adminAddr,
'0x'
)
await bridgeProxy.deployed()
await inboxProxy.deployed()
const dataHashReader = await Toolkit4844.deployDataHashReader(fundingWallet)
const blobBasefeeReader = await Toolkit4844.deployBlobBasefeeReader(
fundingWallet
)
await sequencerInboxProxy.deployed()

const bridge = await bridgeFac.attach(bridgeProxy.address).connect(user)
const bridgeAdmin = await bridgeFac
.attach(bridgeProxy.address)
.connect(rollupOwner)
const sequencerInbox = await sequencerInboxFac
.attach(sequencerInboxProxy.address)
.connect(user)
await (await bridgeAdmin.initialize(rollupMock.address)).wait()

const sequencerInboxFac = new SequencerInbox__factory(deployer)
const sequencerInbox = await sequencerInboxFac.deploy(
bridge.address,
{
delayBlocks: maxDelayBlocks,
futureBlocks: 10,
delaySeconds: maxDelayTime,
futureSeconds: 3000,
},
117964,
dataHashReader.address,
blobBasefeeReader.address,
{ gasLimit: 15000000 }
)
await sequencerInbox.deployed()
await sequencerInbox.initialize(bridgeProxy.address, {
delayBlocks: maxDelayBlocks,
delaySeconds: maxDelayTime,
futureBlocks: 10,
futureSeconds: 3000,
})

const inbox = await inboxFac.attach(inboxProxy.address).connect(user)

Expand Down Expand Up @@ -381,7 +385,9 @@ describe('SequencerInbox', async () => {
const subMessageCount = await bridge.sequencerReportedSubMessageCount()
const batchSendTx = await sequencerInbox
.connect(batchPoster)
.functions.addSequencerL2BatchFromOrigin(
.functions[
'addSequencerL2BatchFromOrigin(uint256,bytes,uint256,address,uint256,uint256)'
](
await bridge.sequencerMessageCount(),
'0x0042',
await bridge.delayedMessageCount(),
Expand Down Expand Up @@ -542,15 +548,15 @@ describe('SequencerInbox', async () => {
const maxTimeVariation = await sequencerInbox.maxTimeVariation()
return {
minBlocks:
blockNumber > maxTimeVariation.delayBlocks.toNumber()
? blockNumber - maxTimeVariation.delayBlocks.toNumber()
blockNumber > maxTimeVariation[0].toNumber()
? blockNumber - maxTimeVariation[0].toNumber()
: 0,
maxBlock: blockNumber + maxTimeVariation.futureBlocks.toNumber(),
maxBlock: blockNumber + maxTimeVariation[1].toNumber(),
minTimestamp:
blockTimestamp > maxTimeVariation.delaySeconds.toNumber()
? blockTimestamp - maxTimeVariation.delaySeconds.toNumber()
blockTimestamp > maxTimeVariation[2].toNumber()
? blockTimestamp - maxTimeVariation[2].toNumber()
: 0,
maxTimestamp: blockTimestamp + maxTimeVariation.futureSeconds.toNumber(),
maxTimestamp: blockTimestamp + maxTimeVariation[3].toNumber(),
}
}

Expand Down
20 changes: 10 additions & 10 deletions test/foundry/BridgeCreator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ contract BridgeCreatorTest is Test {
// seqInbox
assertEq(address(seqInbox.bridge()), address(bridge), "Invalid bridge ref");
assertEq(address(seqInbox.rollup()), rollup, "Invalid seq rollup ref");
ISequencerInbox.MaxTimeVariation memory maxTimeVariation = seqInbox.maxTimeVariation();
assertEq(maxTimeVariation.delayBlocks, timeVars.delayBlocks, "Invalid delayBlocks");
assertEq(maxTimeVariation.futureBlocks, timeVars.futureBlocks, "Invalid futureBlocks");
assertEq(maxTimeVariation.delaySeconds, timeVars.delaySeconds, "Invalid delaySeconds");
assertEq(maxTimeVariation.futureSeconds, timeVars.futureSeconds, "Invalid futureSeconds");
(uint256 delayBlocks, uint256 futureBlocks, uint256 delaySeconds, uint256 futureSeconds) = seqInbox.maxTimeVariation();
assertEq(delayBlocks, timeVars.delayBlocks, "Invalid delayBlocks");
assertEq(futureBlocks, timeVars.futureBlocks, "Invalid futureBlocks");
assertEq(delaySeconds, timeVars.delaySeconds, "Invalid delaySeconds");
assertEq(futureSeconds, timeVars.futureSeconds, "Invalid futureSeconds");

// inbox
assertEq(address(inbox.bridge()), address(bridge), "Invalid bridge ref");
Expand Down Expand Up @@ -225,11 +225,11 @@ contract BridgeCreatorTest is Test {
// seqInbox
assertEq(address(seqInbox.bridge()), address(bridge), "Invalid bridge ref");
assertEq(address(seqInbox.rollup()), rollup, "Invalid seq inbox rollup ref");
ISequencerInbox.MaxTimeVariation memory maxTimeVariation = seqInbox.maxTimeVariation();
assertEq(maxTimeVariation.delayBlocks, timeVars.delayBlocks, "Invalid delayBlocks");
assertEq(maxTimeVariation.futureBlocks, timeVars.futureBlocks, "Invalid futureBlocks");
assertEq(maxTimeVariation.delaySeconds, timeVars.delaySeconds, "Invalid delaySeconds");
assertEq(maxTimeVariation.futureSeconds, timeVars.futureSeconds, "Invalid futureSeconds");
(uint256 delayBlocks, uint256 futureBlocks, uint256 delaySeconds, uint256 futureSeconds) = seqInbox.maxTimeVariation();
assertEq(delayBlocks, timeVars.delayBlocks, "Invalid delayBlocks");
assertEq(futureBlocks, timeVars.futureBlocks, "Invalid futureBlocks");
assertEq(delaySeconds, timeVars.delaySeconds, "Invalid delaySeconds");
assertEq(futureSeconds, timeVars.futureSeconds, "Invalid futureSeconds");

// inbox
assertEq(address(inbox.bridge()), address(bridge), "Invalid bridge ref");
Expand Down

0 comments on commit 071e4fe

Please sign in to comment.