From e38cdd40f9ac80eb569a8af3c7721d0624172e79 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 25 Nov 2022 13:22:31 +0800 Subject: [PATCH] feat(protocol): add `TaikoL1.getBlockProvers` --- packages/protocol/contracts/L1/TaikoL1.sol | 8 ++++++++ packages/protocol/test/L1/TaikoL1.test.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index fefbb69b2c2..3d3e90b6f18 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -229,6 +229,14 @@ contract TaikoL1 is EssentialContract, IHeaderSync, V1Events { return LibAnchorSignature.signTransaction(hash, k); } + function getBlockProvers(uint256 id, bytes32 parentHash) + public + view + returns (address[] memory) + { + return state.forkChoices[id][parentHash].provers; + } + function getConstants() public pure diff --git a/packages/protocol/test/L1/TaikoL1.test.ts b/packages/protocol/test/L1/TaikoL1.test.ts index 652618b3e7f..2a08f5e833d 100644 --- a/packages/protocol/test/L1/TaikoL1.test.ts +++ b/packages/protocol/test/L1/TaikoL1.test.ts @@ -94,6 +94,19 @@ describe("TaikoL1", function () { expect(hash).to.be.eq(genesisHash) }) }) + + describe("getBlockProvers()", async function () { + it("should return empty list when there is no proof for that block", async function () { + const { taikoL1 } = await deployTaikoL1Fixture() + + const provers = await taikoL1.getBlockProvers( + Math.ceil(Math.random() * 1024), + randomBytes32() + ) + + expect(provers).to.be.empty + }) + }) }) function randomBytes32() {