Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-foundry
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoKass committed Aug 1, 2024
2 parents c57ac68 + 0586ed5 commit 7e45237
Show file tree
Hide file tree
Showing 7 changed files with 33,334 additions and 23 deletions.
16,452 changes: 16,452 additions & 0 deletions deployments/account_patches_devnet.json

Large diffs are not rendered by default.

16,457 changes: 16,457 additions & 0 deletions deployments/blockscout_genesis_devnet.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion deployments/state-dump-10-none.json

This file was deleted.

334 changes: 321 additions & 13 deletions generated-types/bindings/contracts/l1/lightlinkportal/LightLinkPortal.go

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions scripts/hardhat/deploy/deployBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ import { ethers } from "hardhat";
import { log } from "../lib/log";
import { proxyDeployAndInitialize } from "../lib/deploy";

// npx hardhat verify --contract contracts/L1/L1CrossDomainMessenger.sol:L1CrossDomainMessenger --network sepolia 0x719E6614628552CFE0CE83B61778b2eA8A5c2147
// npx hardhat verify --contract contracts/L1/L1StandardBridge.sol:L1StandardBridge --network sepolia 0xFe1F82B89E458F3236098cCa992209306FE45b47
// npx hardhat verify --contract contracts/L1/LightLinkPortal.sol:LightLinkPortal --network sepolia 0xc537029Daf5489d9D4B377324027a7677fEC0515

// npx hardhat verify --contract contracts/L2/L2ToL1MessagePasser.sol:L2ToL1MessagePasser --network pegasus 0x5FbDB2315678afecb367f032d93F642f64180aa3
// npx hardhat verify --contract contracts/L2/L2StandardBridge.sol:L2StandardBridge --network pegasus 0x5FbDB2315678afecb367f032d93F642f64180aa3
// npx hardhat verify --contract contracts/L2/L2CrossDomainMessenger.sol:L2CrossDomainMessenger --network pegasus 0x719E6614628552CFE0CE83B61778b2eA8A5c2147
// npx hardhat verify --contract contracts/L2/L1Block.sol:L1Block --network pegasus 0x719E6614628552CFE0CE83B61778b2eA8A5c2147

const CanonicalStateChain =
process.env.CANONICAL_STATE_CHAIN_ADDR ?? ethers.ZeroAddress;
const Challenge = process.env.CHALLENGE_ADDR ?? ethers.ZeroAddress;
Expand Down
34 changes: 34 additions & 0 deletions test/tests/L1/CanonicalStateChainTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ describe("CanonicalStateChain", function () {
).to.emit(canonicalStateChain, "RolledBack");
});
});

describe("setMaxPointers", function () {
it("setMaxPointers should update maxPointers var", async function () {
expect(
Expand All @@ -401,4 +402,37 @@ describe("CanonicalStateChain", function () {
);
});
});

describe("getL2Output", function () {
it("Should return the expect L2Output", async function () {
const header: CanonicalStateChain.HeaderStruct = {
epoch: 1,
l2Height: 1,
prevHash: _chain.genesisHash,
outputRoot: ethers.keccak256(ethers.toUtf8Bytes("0")),
celestiaPointers: [{ height: 1, shareStart: 1, shareLen: 1 }],
};

await expect(
canonicalStateChain
.connect(publisher)
.getFunction("pushBlock")
.send(header),
)
.to.emit(canonicalStateChain, "BlockAdded")
.withArgs(1);

const res = await canonicalStateChain.getL2Output(1);
expect(res[0]).to.equal(ethers.keccak256(ethers.toUtf8Bytes("0")));
});
});

describe("startingTimestamp", function () {
it("Should return timestamp of genesis block", async function () {
const genesisBlockHash = await canonicalStateChain.chain(0);
const header = await canonicalStateChain.headerMetadata(genesisBlockHash);
const timestamp = await canonicalStateChain.startingTimestamp();
expect(timestamp).to.be.equal(header[0]);
});
});
});
70 changes: 70 additions & 0 deletions test/tests/L1/L1CrossDomainMessengerTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { ethers } from "hardhat";
import { expect } from "chai";
import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
import { pushRandomHeader, setupCanonicalStateChain } from "../../lib/chain";
import {
LightLinkPortal,
L1CrossDomainMessenger,
} from "../../../typechain-types";
import { proxyDeployAndInitialize } from "../../../scripts/hardhat/lib/deploy";
import { l1 } from "../../../typechain-types/contracts";

describe("L1CrossDomainMessenger", function () {
let lightLinkPortal: LightLinkPortal;
let l1CrossDomainMessenger: L1CrossDomainMessenger;
let owner: HardhatEthersSigner, _chain: any;

beforeEach(async function () {
[owner] = await ethers.getSigners();

// - LightLinkPortal
const lightLinkPortalDeployment = await proxyDeployAndInitialize(
owner,
await ethers.getContractFactory("LightLinkPortal"),
[ethers.ZeroAddress, ethers.ZeroAddress],
);
lightLinkPortal = lightLinkPortalDeployment.contract as LightLinkPortal;

// - L1CrossDomainMessenger
const l1CrossDomainMessengerDeployment = await proxyDeployAndInitialize(
owner,
await ethers.getContractFactory("L1CrossDomainMessenger"),
[lightLinkPortalDeployment.address],
);

l1CrossDomainMessenger =
l1CrossDomainMessengerDeployment.contract as L1CrossDomainMessenger;
});

describe("Deployment", function () {
it("Should set the right LightLinkPortal", async function () {
expect(await l1CrossDomainMessenger.PORTAL()).to.equal(
await lightLinkPortal.getAddress(),
);
});

it("Should not be allowed to initialize twice", async function () {
await expect(
l1CrossDomainMessenger
.connect(owner)
.getFunction("initialize")
.send(await lightLinkPortal.getAddress()),
).to.be.revertedWithCustomError(
l1CrossDomainMessenger,
"InvalidInitialization",
);
});
});

// Internal
// describe("gasPayingToken", function () {
// it("Should return ETHER address and decimals 18", async function () {
// expect( await l1CrossDomainMessenger.
// l1CrossDomainMessenger.
// .connect(owner)
// .getFunction("gasPayingToken")
// .send(),
// ).to.be.equal("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE");
// });
// });
});

0 comments on commit 7e45237

Please sign in to comment.