-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contracts): read configs from files
- Loading branch information
Showing
9 changed files
with
126 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"epochDuration": 86400, | ||
"slashingWindow": 604800, | ||
"maxChallengeDuration": 604800, | ||
"challengeBond": 1000000000000000000, | ||
"blockhashEvmLookback": 256, | ||
"justificationDelay": 32, | ||
"eth2GenesisTimestamp": 1694786400, | ||
"slotTime": 12, | ||
"allowUnsafeRegistration": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"epochDuration": 86400, | ||
"slashingWindow": 604800, | ||
"maxChallengeDuration": 604800, | ||
"challengeBond": 1000000000000000000, | ||
"blockhashEvmLookback": 256, | ||
"justificationDelay": 32, | ||
"eth2GenesisTimestamp": 1606824023, | ||
"slotTime": 12, | ||
"allowUnsafeRegistration": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
library BoltConfig { | ||
struct ParametersConfig { | ||
uint48 epochDuration; | ||
uint48 slashingWindow; | ||
uint48 maxChallengeDuration; | ||
uint256 challengeBond; | ||
uint256 blockhashEvmLookback; | ||
uint256 justificationDelay; | ||
uint256 eth2GenesisTimestamp; | ||
uint256 slotTime; | ||
bool allowUnsafeRegistration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Test, console} from "forge-std/Test.sol"; | ||
|
||
import {BoltConfig} from "../src/lib/Config.sol"; | ||
|
||
contract Utils is Test { | ||
function readParameters() public view returns (BoltConfig.ParametersConfig memory) { | ||
string memory root = vm.projectRoot(); | ||
string memory path = string.concat(root, "/config/config.test.json"); | ||
string memory json = vm.readFile(path); | ||
|
||
uint48 epochDuration = uint48(vm.parseJsonUint(json, ".epochDuration")); | ||
uint48 slashingWindow = uint48(vm.parseJsonUint(json, ".slashingWindow")); | ||
uint48 maxChallengeDuration = uint48(vm.parseJsonUint(json, ".maxChallengeDuration")); | ||
bool allowUnsafeRegistration = vm.parseJsonBool(json, ".allowUnsafeRegistration"); | ||
uint256 challengeBond = vm.parseJsonUint(json, ".challengeBond"); | ||
uint256 blockhashEvmLookback = vm.parseJsonUint(json, ".blockhashEvmLookback"); | ||
uint256 justificationDelay = vm.parseJsonUint(json, ".justificationDelay"); | ||
uint256 eth2GenesisTimestamp = vm.parseJsonUint(json, ".eth2GenesisTimestamp"); | ||
uint256 slotTime = vm.parseJsonUint(json, ".slotTime"); | ||
|
||
return BoltConfig.ParametersConfig({ | ||
epochDuration: epochDuration, | ||
slashingWindow: slashingWindow, | ||
maxChallengeDuration: maxChallengeDuration, | ||
challengeBond: challengeBond, | ||
blockhashEvmLookback: blockhashEvmLookback, | ||
justificationDelay: justificationDelay, | ||
eth2GenesisTimestamp: eth2GenesisTimestamp, | ||
slotTime: slotTime, | ||
allowUnsafeRegistration: allowUnsafeRegistration | ||
}); | ||
} | ||
} |