Skip to content

Commit

Permalink
setConfigDefaultValues
Browse files Browse the repository at this point in the history
  • Loading branch information
defi-dev committed Sep 30, 2023
1 parent 8df88fe commit 3a8fa05
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 11 deletions.
6 changes: 4 additions & 2 deletions app/Cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ let app: App;

const netConfig: NetworkConfig = {
rpc: process.env.NETWORK_RPC,
max_block_delay: parseInt(process.env.NETWORK_MAX_BLOCK_DELAY || '60'),
resolve_min_success_count: parseInt(process.env.NETWORK_MIN_SUCCESS_RESOLVE || '3'),
max_block_delay: process.env.NETWORK_MAX_BLOCK_DELAY ? parseInt(process.env.NETWORK_MAX_BLOCK_DELAY) : undefined,
resolve_min_success_count: process.env.NETWORK_MIN_SUCCESS_RESOLVE
? parseInt(process.env.NETWORK_MIN_SUCCESS_RESOLVE)
: undefined,
agents: {
[agentAddress]: agentConfig,
},
Expand Down
15 changes: 15 additions & 0 deletions app/ConfigGetters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,18 @@ export function getDefaultExecutorConfig() {
gas_price_priority_add_gwei: 2,
};
}

export function getDefaultNetworkConfig() {
return {
max_block_delay: 60,
resolve_min_success_count: 3,
};
}

export function setConfigDefaultValues(config, defaultValues) {
Object.keys(defaultValues).forEach(name => {
if (typeof config[name] === 'undefined') {
config[name] = defaultValues[name];
}
});
}
9 changes: 8 additions & 1 deletion app/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import {
Resolver,
} from './Types.js';
import { ethers } from 'ethers';
import { getAverageBlockTime, getExternalLensAddress, getMulticall2Address } from './ConfigGetters.js';
import {
getAverageBlockTime,
getDefaultNetworkConfig,
getExternalLensAddress,
getMulticall2Address,
setConfigDefaultValues,
} from './ConfigGetters.js';
import { getExternalLensAbi, getMulticall2Abi } from './services/AbiService.js';
import { EthersContractWrapperFactory } from './clients/EthersContractWrapperFactory.js';
import EventEmitter from 'events';
Expand Down Expand Up @@ -71,6 +77,7 @@ export class Network {
this.initialized = false;
this.app = app;
this.name = name;
setConfigDefaultValues(networkConfig, getDefaultNetworkConfig());
this.rpc = networkConfig.rpc;
this.maxBlockDelay = networkConfig.max_block_delay;
this.networkConfig = networkConfig;
Expand Down
9 changes: 2 additions & 7 deletions app/agents/AbstractAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { BN_ZERO, DEFAULT_SYNC_FROM_CHAINS } from '../Constants.js';
import { toChecksummedAddress, weiValueToEth } from '../Utils.js';
import { FlashbotsExecutor } from '../executors/FlashbotsExecutor.js';
import { PGAExecutor } from '../executors/PGAExecutor.js';
import { getAgentDefaultSyncFromSafe, getDefaultExecutorConfig } from '../ConfigGetters.js';
import { getAgentDefaultSyncFromSafe, getDefaultExecutorConfig, setConfigDefaultValues } from '../ConfigGetters.js';
import { LightJob } from '../jobs/LightJob.js';
import { RandaoJob } from '../jobs/RandaoJob.js';
import { AbstractJob } from '../jobs/AbstractJob';
Expand Down Expand Up @@ -101,12 +101,7 @@ export abstract class AbstractAgent implements IAgent {
this.blacklistedJobs = new Set();

this.executorConfig = agentConfig.executor_config || {};
const defaultExecutorConfig = getDefaultExecutorConfig();
Object.keys(defaultExecutorConfig).forEach(name => {
if (typeof this.executorConfig[name] === 'undefined') {
this.executorConfig[name] = defaultExecutorConfig[name];
}
});
setConfigDefaultValues(this.executorConfig, getDefaultExecutorConfig());

// Check if all data for subgraph is provided
if (agentConfig.data_source) {
Expand Down
122 changes: 121 additions & 1 deletion app/artifacts/PPAgentV2.3.0.randao.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@
"name": "JobCheckResolverReturnedFalse",
"type": "error"
},
{
"inputs": [],
"name": "JobCompensationMultiplierBpsLT10000",
"type": "error"
},
{
"inputs": [
{
Expand Down Expand Up @@ -337,6 +342,11 @@
"name": "KeeperIsAssignedToJobs",
"type": "error"
},
{
"inputs": [],
"name": "KeeperShouldBeDisabledForStakeLTMinKeeperCvp",
"type": "error"
},
{
"inputs": [],
"name": "KeeperWorkerNotAuthorized",
Expand Down Expand Up @@ -1338,6 +1348,11 @@
"internalType": "uint8",
"name": "keeperActivationTimeoutHours",
"type": "uint8"
},
{
"internalType": "uint16",
"name": "jobFixedRewardFinney",
"type": "uint16"
}
],
"indexed": false,
Expand Down Expand Up @@ -1594,6 +1609,45 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bool",
"name": "ok_",
"type": "bool"
},
{
"internalType": "uint256",
"name": "job_",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "keeperId_",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "baseFee_",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "gasUsed_",
"type": "uint256"
}
],
"name": "calculateCompensation",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -1672,6 +1726,24 @@
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "for_",
"type": "address"
},
{
"internalType": "bytes32[]",
"name": "jobKeys_",
"type": "bytes32[]"
}
],
"name": "depositJobOwnerCreditsAndAssignKeepers",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -1965,7 +2037,7 @@
"outputs": [
{
"internalType": "bytes32[]",
"name": "jobKeys",
"name": "actualJobKeys",
"type": "bytes32[]"
}
],
Expand Down Expand Up @@ -2129,6 +2201,11 @@
"internalType": "uint8",
"name": "keeperActivationTimeoutHours",
"type": "uint8"
},
{
"internalType": "uint16",
"name": "jobFixedRewardFinney",
"type": "uint16"
}
],
"internalType": "struct IPPAgentV2RandaoViewer.RandaoConfig",
Expand Down Expand Up @@ -2267,6 +2344,11 @@
"internalType": "uint8",
"name": "keeperActivationTimeoutHours",
"type": "uint8"
},
{
"internalType": "uint16",
"name": "jobFixedRewardFinney",
"type": "uint16"
}
],
"internalType": "struct IPPAgentV2RandaoViewer.RandaoConfig",
Expand Down Expand Up @@ -2541,6 +2623,39 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "keeperId_",
"type": "uint256"
},
{
"internalType": "address",
"name": "to_",
"type": "address"
},
{
"internalType": "uint256",
"name": "currentAmount_",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "pendingAmount_",
"type": "uint256"
},
{
"internalType": "bool",
"name": "disable_",
"type": "bool"
}
],
"name": "ownerSlashDisable",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -2835,6 +2950,11 @@
"internalType": "uint8",
"name": "keeperActivationTimeoutHours",
"type": "uint8"
},
{
"internalType": "uint16",
"name": "jobFixedRewardFinney",
"type": "uint16"
}
],
"internalType": "struct IPPAgentV2RandaoViewer.RandaoConfig",
Expand Down

0 comments on commit 3a8fa05

Please sign in to comment.