Skip to content

Some repo fixes #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .solcover.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
skipFiles: ["mock/"],
skipFiles: ["mock/", "interfaces/"],
configureYulOptimizer: true,
};
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"max-states-count": "warn",
"not-rely-on-time": "off",
"var-name-mixedcase": "off",
"compiler-version": "off"
"compiler-version": "off",
"use-natspec": "off"
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Solarity
Copyright (c) 2025 Distributed Lab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions contracts/SPVContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ contract SPVContract is ISPVContract, Initializable {
);

require(
TargetsHelper.isTargetAdjustmentBlock(blockHeight_),
blockHeight_ == 0 || TargetsHelper.isTargetAdjustmentBlock(blockHeight_),
InvalidInitialBlockHeight(blockHeight_)
);

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

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

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

prevBlockHash_ = _getBlockHeader(prevBlockHash_).prevBlockHash;
prevBlockHeight_ -= 1;
--prevBlockHeight_;
} while (getBlockHash(prevBlockHeight_) != prevBlockHash_ && prevBlockHash_ != 0);
}
}
Expand Down Expand Up @@ -298,7 +298,7 @@ contract SPVContract is ISPVContract, Initializable {
blockHeaders_ = new BlockHeaderData[](blockHeaderRawArray_.length);
blockHashes_ = new bytes32[](blockHeaderRawArray_.length);

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

if (i == 0) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/mock/SPVContractMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract SPVContractMock is SPVContract {
) external pure returns (uint32) {
BlockHeaderData[] memory blockHeaders_ = new BlockHeaderData[](blockHeaderRawArr_.length);

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

Expand Down
6 changes: 5 additions & 1 deletion deploy/1_SPVContract.migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export = async (deployer: Deployer) => {

const spvContract = await deployer.deploy(SPVContract__factory);

await spvContract.__SPVContract_init(config.pendingBlockCount, config.pendingTargetHeightCount);
await spvContract["__SPVContract_init(bytes,uint256,uint256)"](
config.blockHeader,
config.blockHeight,
config.cumulativeWork,
);

Reporter.reportContracts(["SPVContract", await spvContract.getAddress()]);
};
6 changes: 4 additions & 2 deletions deploy/config/localhost.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { DeployConfig } from "./types";

export const deployConfig: DeployConfig = {
pendingBlockCount: 6,
pendingTargetHeightCount: 6,
blockHeader:
"0x0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c",
blockHeight: 0,
cumulativeWork: 0,
};
6 changes: 4 additions & 2 deletions deploy/config/sepolia.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { DeployConfig } from "./types";

export const deployConfig: DeployConfig = {
pendingBlockCount: 6,
pendingTargetHeightCount: 6,
blockHeader:
"0x0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c",
blockHeight: 0,
cumulativeWork: 0,
};
5 changes: 3 additions & 2 deletions deploy/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BigNumberish } from "ethers";

export type DeployConfig = {
pendingBlockCount: BigNumberish;
pendingTargetHeightCount: BigNumberish;
blockHeader: string;
blockHeight: BigNumberish;
cumulativeWork: BigNumberish;
};
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const config: HardhatUserConfig = {
gasReporter: {
currency: "USD",
gasPrice: 50,
enabled: true,
enabled: false,
coinmarketcap: `${process.env.COINMARKETCAP_KEY}`,
reportPureAndViewMethods: true,
},
Expand Down
179 changes: 155 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading