Skip to content

Commit c9559ca

Browse files
committed
Fix comments
1 parent 0e8ce83 commit c9559ca

File tree

5 files changed

+27
-50
lines changed

5 files changed

+27
-50
lines changed

contracts/SPVGateway.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ contract SPVGateway is ISPVGateway, Initializable {
4040
}
4141
}
4242

43-
function __SPVGateway_init() external initializer {
43+
function __SPVGateway_init_genesis() external initializer {
4444
BlockHeader.HeaderData memory genesisBlockHeader_ = BlockHeader.HeaderData({
4545
version: 1,
4646
prevBlockHash: bytes32(0),

hardhat.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ const config: HardhatUserConfig = {
4242
solidity: {
4343
version: "0.8.28",
4444
settings: {
45+
metadata: {
46+
bytecodeHash: "none",
47+
},
4548
optimizer: {
4649
enabled: true,
4750
runs: 1000000,
4851
},
49-
evmVersion: "paris",
52+
evmVersion: "london",
5053
},
5154
},
5255
etherscan: {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "spv-gateway",
2+
"name": "@distributedlab/spv-gateway",
33
"version": "0.1.0",
44
"license": "MIT",
55
"author": "Distributed Lab",
6-
"description": "",
6+
"description": "ERC-8002: SPV gateway reference implementation",
77
"keywords": [
88
"solidity",
99
"smart-contracts",

test/SPVContract.test.ts

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe("SPVGateway", () => {
4545
it("should correctly init SPV contract from genesis state", async () => {
4646
const genesisData = getBlockHeaderData(genesisBlockDataFilePath, 0);
4747

48-
const tx = await spvGateway["__SPVGateway_init()"]();
48+
const tx = await spvGateway.__SPVGateway_init_genesis();
4949

5050
await expect(tx).to.emit(spvGateway, "MainchainHeadUpdated").withArgs(genesisData.height, genesisData.blockHash);
5151
await expect(tx).to.emit(spvGateway, "BlockHeaderAdded").withArgs(genesisData.height, genesisData.blockHash);
@@ -54,7 +54,7 @@ describe("SPVGateway", () => {
5454
it("should correctly init SPV contract from genesis state passed outside", async () => {
5555
const initBlockData = getBlockHeaderData(genesisBlockDataFilePath, 0);
5656

57-
const tx = await spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](initBlockData.rawHeader, 0, 0);
57+
const tx = await spvGateway.__SPVGateway_init(initBlockData.rawHeader, 0, 0);
5858

5959
await expect(tx)
6060
.to.emit(spvGateway, "MainchainHeadUpdated")
@@ -69,7 +69,7 @@ describe("SPVGateway", () => {
6969
.parsedBlockHeader.chainwork;
7070
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
7171

72-
const tx = await spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
72+
const tx = await spvGateway.__SPVGateway_init(
7373
initBlockData.rawHeader,
7474
initBlockData.height,
7575
lastEpochCumulativeWork,
@@ -92,21 +92,15 @@ describe("SPVGateway", () => {
9292
.parsedBlockHeader.chainwork;
9393
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
9494

95-
await expect(
96-
spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
97-
initBlockData.rawHeader,
98-
initBlockData.height,
99-
lastEpochCumulativeWork,
100-
),
101-
)
95+
await expect(spvGateway.__SPVGateway_init(initBlockData.rawHeader, initBlockData.height, lastEpochCumulativeWork))
10296
.to.be.revertedWithCustomError(spvGateway, "InvalidInitialBlockHeight")
10397
.withArgs(initBlockHeight);
10498
});
10599

106100
it("should get exception if try to call init function twice", async () => {
107-
await spvGateway["__SPVGateway_init()"]();
101+
await spvGateway.__SPVGateway_init_genesis();
108102

109-
await expect(spvGateway["__SPVGateway_init()"]()).to.be.revertedWithCustomError(
103+
await expect(spvGateway.__SPVGateway_init_genesis()).to.be.revertedWithCustomError(
110104
spvGateway,
111105
"InvalidInitialization",
112106
);
@@ -117,11 +111,7 @@ describe("SPVGateway", () => {
117111
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
118112

119113
await expect(
120-
spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
121-
initBlockData.rawHeader,
122-
initBlockData.height,
123-
lastEpochCumulativeWork,
124-
),
114+
spvGateway.__SPVGateway_init(initBlockData.rawHeader, initBlockData.height, lastEpochCumulativeWork),
125115
).to.be.revertedWithCustomError(spvGateway, "InvalidInitialization");
126116
});
127117
});
@@ -134,11 +124,7 @@ describe("SPVGateway", () => {
134124
.parsedBlockHeader.chainwork;
135125
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
136126

137-
await spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
138-
initBlockData.rawHeader,
139-
initBlockData.height,
140-
lastEpochCumulativeWork,
141-
);
127+
await spvGateway.__SPVGateway_init(initBlockData.rawHeader, initBlockData.height, lastEpochCumulativeWork);
142128

143129
const batchSize = 100;
144130
const batchesCount = 22;
@@ -178,7 +164,7 @@ describe("SPVGateway", () => {
178164
});
179165

180166
it("should get exception if the first block does not exist", async () => {
181-
await spvGateway["__SPVGateway_init()"]();
167+
await spvGateway.__SPVGateway_init_genesis();
182168

183169
const blockHeadersData = [];
184170

@@ -194,7 +180,7 @@ describe("SPVGateway", () => {
194180
});
195181

196182
it("should get exception if pass block headers in the invalid order", async () => {
197-
await spvGateway["__SPVGateway_init()"]();
183+
await spvGateway.__SPVGateway_init_genesis();
198184

199185
await expect(
200186
spvGateway.addBlockHeaderBatch([
@@ -205,7 +191,7 @@ describe("SPVGateway", () => {
205191
});
206192

207193
it("should get exception if pass zero array", async () => {
208-
await spvGateway["__SPVGateway_init()"]();
194+
await spvGateway.__SPVGateway_init_genesis();
209195

210196
await expect(spvGateway.addBlockHeaderBatch([])).to.revertedWithCustomError(spvGateway, "EmptyBlockHeaderArray");
211197
});
@@ -214,7 +200,7 @@ describe("SPVGateway", () => {
214200
describe("#checkTxInclusion", () => {
215201
describe("#when there are from 1 to 6 transactions in a block", () => {
216202
beforeEach(async () => {
217-
await spvGateway["__SPVGateway_init()"]();
203+
await spvGateway.__SPVGateway_init_genesis();
218204

219205
const initBlockHeight = 1;
220206
const batchSize = 200;
@@ -534,11 +520,7 @@ describe("SPVGateway", () => {
534520
.parsedBlockHeader.chainwork;
535521
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
536522

537-
await spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
538-
initBlockData.rawHeader,
539-
initBlockData.height,
540-
lastEpochCumulativeWork,
541-
);
523+
await spvGateway.__SPVGateway_init(initBlockData.rawHeader, initBlockData.height, lastEpochCumulativeWork);
542524

543525
const neededBlockData = getBlockHeaderData(newestBlocksDataFilePath, 802368);
544526

@@ -690,7 +672,7 @@ describe("SPVGateway", () => {
690672

691673
describe("#addBlockHeader", () => {
692674
it("should correctly add new block header", async () => {
693-
await spvGateway["__SPVGateway_init()"]();
675+
await spvGateway.__SPVGateway_init_genesis();
694676

695677
const firstBlockData = getBlockHeaderData(firstBlocksDataFilePath, 1);
696678
const secondBlockData = getBlockHeaderData(firstBlocksDataFilePath, 2);
@@ -755,11 +737,7 @@ describe("SPVGateway", () => {
755737
.parsedBlockHeader.chainwork;
756738
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
757739

758-
await spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
759-
initBlockData.rawHeader,
760-
initBlockData.height,
761-
lastEpochCumulativeWork,
762-
);
740+
await spvGateway.__SPVGateway_init(initBlockData.rawHeader, initBlockData.height, lastEpochCumulativeWork);
763741

764742
const batchSize = 200;
765743
const batchesCount = 10;
@@ -847,7 +825,7 @@ describe("SPVGateway", () => {
847825
});
848826

849827
it("should get exception if pass block that already exists", async () => {
850-
await spvGateway["__SPVGateway_init()"]();
828+
await spvGateway.__SPVGateway_init_genesis();
851829

852830
const currentBlockData = getBlockHeaderData(firstBlocksDataFilePath, 1);
853831

@@ -859,7 +837,7 @@ describe("SPVGateway", () => {
859837
});
860838

861839
it("should get exception if prev block hash is not in the chain", async () => {
862-
await spvGateway["__SPVGateway_init()"]();
840+
await spvGateway.__SPVGateway_init_genesis();
863841

864842
const firstBlockData = getBlockHeaderData(firstBlocksDataFilePath, 1);
865843
const thirdBlockData = getBlockHeaderData(firstBlocksDataFilePath, 3);
@@ -874,7 +852,7 @@ describe("SPVGateway", () => {
874852

875853
describe("#getStorageMedianTime", () => {
876854
beforeEach("setup", async () => {
877-
await spvGateway["__SPVGateway_init()"]();
855+
await spvGateway.__SPVGateway_init_genesis();
878856
});
879857

880858
it("should return correct median time for the first block", async () => {
@@ -924,7 +902,7 @@ describe("SPVGateway", () => {
924902

925903
describe("#getMemoryMedianTime", async () => {
926904
beforeEach("setup", async () => {
927-
await spvGateway["__SPVGateway_init()"]();
905+
await spvGateway.__SPVGateway_init_genesis();
928906
});
929907

930908
it("should return correct median time", async () => {
@@ -958,11 +936,7 @@ describe("SPVGateway", () => {
958936
.parsedBlockHeader.chainwork;
959937
const initBlockData = getBlockHeaderData(newestBlocksDataFilePath, initBlockHeight);
960938

961-
await spvGateway["__SPVGateway_init(bytes,uint64,uint256)"](
962-
initBlockData.rawHeader,
963-
initBlockData.height,
964-
lastEpochCumulativeWork,
965-
);
939+
await spvGateway.__SPVGateway_init(initBlockData.rawHeader, initBlockData.height, lastEpochCumulativeWork);
966940
});
967941

968942
it("should get exception if pass invalid bits field", async () => {

0 commit comments

Comments
 (0)