Skip to content

Commit 898765a

Browse files
authored
Merge pull request #5 from distributed-lab/fix/some-stuff
Some repo fixes
2 parents dd4d734 + fd39906 commit 898765a

19 files changed

+197
-45
lines changed

.solcover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2-
skipFiles: ["mock/"],
2+
skipFiles: ["mock/", "interfaces/"],
33
configureYulOptimizer: true,
44
};

.solhint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"max-states-count": "warn",
1212
"not-rely-on-time": "off",
1313
"var-name-mixedcase": "off",
14-
"compiler-version": "off"
14+
"compiler-version": "off",
15+
"use-natspec": "off"
1516
}
1617
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Solarity
3+
Copyright (c) 2025 Distributed Lab
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

contracts/SPVContract.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ contract SPVContract is ISPVContract, Initializable {
6262
);
6363

6464
require(
65-
TargetsHelper.isTargetAdjustmentBlock(blockHeight_),
65+
blockHeight_ == 0 || TargetsHelper.isTargetAdjustmentBlock(blockHeight_),
6666
InvalidInitialBlockHeight(blockHeight_)
6767
);
6868

@@ -92,7 +92,7 @@ contract SPVContract is ISPVContract, Initializable {
9292
uint256 firstBlockHeight_ = getBlockHeight(blockHeaders_[0].prevBlockHash) + 1;
9393
bytes32 currentTarget_ = getBlockTarget(blockHeaders_[0].prevBlockHash);
9494

95-
for (uint256 i = 0; i < blockHeaderRawArray_.length; i++) {
95+
for (uint256 i = 0; i < blockHeaderRawArray_.length; ++i) {
9696
uint256 currentBlockHeight_ = firstBlockHeight_ + i;
9797

9898
currentTarget_ = _updateLastEpochCumulativeWork(currentTarget_, currentBlockHeight_);
@@ -260,7 +260,7 @@ contract SPVContract is ISPVContract, Initializable {
260260
$.blocksHeightToBlockHash[prevBlockHeight_] = prevBlockHash_;
261261

262262
prevBlockHash_ = _getBlockHeader(prevBlockHash_).prevBlockHash;
263-
prevBlockHeight_ -= 1;
263+
--prevBlockHeight_;
264264
} while (getBlockHash(prevBlockHeight_) != prevBlockHash_ && prevBlockHash_ != 0);
265265
}
266266
}
@@ -298,7 +298,7 @@ contract SPVContract is ISPVContract, Initializable {
298298
blockHeaders_ = new BlockHeaderData[](blockHeaderRawArray_.length);
299299
blockHashes_ = new bytes32[](blockHeaderRawArray_.length);
300300

301-
for (uint256 i = 0; i < blockHeaderRawArray_.length; i++) {
301+
for (uint256 i = 0; i < blockHeaderRawArray_.length; ++i) {
302302
(blockHeaders_[i], blockHashes_[i]) = _parseBlockHeaderRaw(blockHeaderRawArray_[i]);
303303

304304
if (i == 0) {

contracts/mock/SPVContractMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ contract SPVContractMock is SPVContract {
3232
) external pure returns (uint32) {
3333
BlockHeaderData[] memory blockHeaders_ = new BlockHeaderData[](blockHeaderRawArr_.length);
3434

35-
for (uint256 i = 0; i < blockHeaderRawArr_.length; i++) {
35+
for (uint256 i = 0; i < blockHeaderRawArr_.length; ++i) {
3636
(blockHeaders_[i], ) = blockHeaderRawArr_[i].parseBlockHeaderData();
3737
}
3838

deploy/1_SPVContract.migration.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export = async (deployer: Deployer) => {
99

1010
const spvContract = await deployer.deploy(SPVContract__factory);
1111

12-
await spvContract.__SPVContract_init(config.pendingBlockCount, config.pendingTargetHeightCount);
12+
await spvContract["__SPVContract_init(bytes,uint256,uint256)"](
13+
config.blockHeader,
14+
config.blockHeight,
15+
config.cumulativeWork,
16+
);
1317

1418
Reporter.reportContracts(["SPVContract", await spvContract.getAddress()]);
1519
};

deploy/config/localhost.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { DeployConfig } from "./types";
22

33
export const deployConfig: DeployConfig = {
4-
pendingBlockCount: 6,
5-
pendingTargetHeightCount: 6,
4+
blockHeader:
5+
"0x0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c",
6+
blockHeight: 0,
7+
cumulativeWork: 0,
68
};

deploy/config/sepolia.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { DeployConfig } from "./types";
22

33
export const deployConfig: DeployConfig = {
4-
pendingBlockCount: 6,
5-
pendingTargetHeightCount: 6,
4+
blockHeader:
5+
"0x0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c",
6+
blockHeight: 0,
7+
cumulativeWork: 0,
68
};

deploy/config/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BigNumberish } from "ethers";
22

33
export type DeployConfig = {
4-
pendingBlockCount: BigNumberish;
5-
pendingTargetHeightCount: BigNumberish;
4+
blockHeader: string;
5+
blockHeight: BigNumberish;
6+
cumulativeWork: BigNumberish;
67
};

hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const config: HardhatUserConfig = {
7777
gasReporter: {
7878
currency: "USD",
7979
gasPrice: 50,
80-
enabled: true,
80+
enabled: false,
8181
coinmarketcap: `${process.env.COINMARKETCAP_KEY}`,
8282
reportPureAndViewMethods: true,
8383
},

0 commit comments

Comments
 (0)