-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathconfig.ts
More file actions
77 lines (71 loc) · 2.98 KB
/
config.ts
File metadata and controls
77 lines (71 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { ZeroAddress } from "ethers";
import { ZerogContractConfigs } from "./networks/zerog_contract_config";
import { ZerogMainnetContractConfigsStandard } from "./networks/zerog_mainnet_contract_config_standard";
import { ZerogMainnetContractConfigsTurbo } from "./networks/zerog_mainnet_contract_config_turbo";
import { ZerogTestnetContractConfigsStandard } from "./networks/zerog_testnet_contract_config_standard";
import { ZerogTestnetContractConfigsTurbo } from "./networks/zerog_testnet_contract_config_turbo";
export interface MineConfigs {
settings: number;
// The initial difficulty for PoRA mining.
initDifficulty: number;
// Mining window duration for each subtask in blocks
targetMineBlocks: number;
// Target number of submissions per epoch
targetSubmissions: number;
// Maximum shards per mining submission
maxShards: number;
// Number of subtasks per epoch
nSubtasks: number;
// Interval between subtask start times in blocks
subtaskInterval: number;
}
export interface ChunkRewardConfigs {
// Foundation admin address for chunk reward management
foundationAdmin: string;
}
export interface NetworkConfigs {
mineConfigs: MineConfigs;
chunkRewardConfigs: ChunkRewardConfigs;
// This variable determines how often the `makeContext` function needs to be called within each mining cycle, known as an Epoch. If this function is not called over several epochs, it may cause issues. By default, this value is set very high, meaning that the contract will not generate mining tasks. For mining tests, adjust it to a suitable size (recommended block count per hour).
blocksPerEpoch: number;
firstBlock: number;
rootHistory: string;
// Upon enabling the economic model, this controls the data storage validity period and the reward release cycle. The annual storage cost per GB is a constant in the contract named `ANNUAL_ZGS_TOKENS_PER_GB`.
lifetimeMonth: number;
flowDeployDelay: number;
unitPrice: number;
}
export const DefaultConfig: NetworkConfigs = {
mineConfigs: {
settings: 0,
initDifficulty: 30000,
targetMineBlocks: 100,
targetSubmissions: 10,
maxShards: 32,
nSubtasks: 1,
subtaskInterval: 100,
},
chunkRewardConfigs: {
foundationAdmin: ZeroAddress,
},
blocksPerEpoch: 1000000000,
firstBlock: 0,
rootHistory: ZeroAddress,
lifetimeMonth: 3,
flowDeployDelay: 0,
unitPrice: 1,
};
export const GlobalConfig: { [key: string]: NetworkConfigs } = {
zg: ZerogContractConfigs,
zgTestnetStandard: ZerogTestnetContractConfigsStandard,
zgTestnetTurbo: ZerogTestnetContractConfigsTurbo,
zgTurbo: ZerogMainnetContractConfigsTurbo,
zgStandard: ZerogMainnetContractConfigsStandard,
};
export function getConfig(network: string) {
if (network in GlobalConfig) return GlobalConfig[network];
if (network === "hardhat") {
return DefaultConfig;
}
throw new Error(`network ${network} non-exist`);
}