Skip to content
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

feat: medusa tests #51

Draft
wants to merge 29 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5d5fd14
chore: properties md update
simon-something Oct 29, 2024
3b77715
test(medusa): handlers and working setup
simon-something Nov 10, 2024
1b53763
test(medusa): add lib to crytic compile
simon-something Nov 10, 2024
98de161
test(medusa): prop 0 sanity check ok
simon-something Nov 10, 2024
92a50e3
test(medusa): git ignore corpus
simon-something Nov 10, 2024
1e78bdb
test(medusa): git ignore corpus
simon-something Nov 10, 2024
efc8876
test(medusa): typo medusa json
simon-something Nov 10, 2024
e4cf1e5
test(medusa): rm corpus
simon-something Nov 10, 2024
c0ffee6
test(medusa): natspec
simon-something Nov 11, 2024
c0ffee7
test(medusa): rm non-sensical handlers onlyoracle etc
simon-something Nov 11, 2024
c0ffeed
test(medusa): ghosts refactor
simon-something Nov 13, 2024
c0ffee6
test(medusa): more handler fixes
simon-something Nov 13, 2024
c0ffeee
test(medusa): properties md update
simon-something Nov 20, 2024
9c8dce2
test(medusa): requester properties (#57)
0xJabberwock Nov 28, 2024
c0ffee9
test(medusa): dispute window in prop6
simon-something Nov 28, 2024
c0ffeef
test(medusa): fix approveModule
simon-something Nov 28, 2024
c0ffeeb
test(medusa): fix approveModule
simon-something Nov 28, 2024
97fff3c
test(medusa): rename PropertyDispute to PropertyDisputer
0xJabberwock Nov 29, 2024
80d145f
test(medusa): correct prop-6
0xJabberwock Nov 29, 2024
1d45342
test(medusa): assert prop-7
0xJabberwock Nov 29, 2024
c0ffee6
test(medusa): properties 13
simon-something Nov 30, 2024
c0ffee9
test(medusa): fix prop1 for empty finalized req
simon-something Dec 7, 2024
c0ffee7
test(medusa): fix fp
simon-something Dec 11, 2024
7218056
test(medusa): proposer properties
0xJabberwock Dec 13, 2024
2b8bc63
test(medusa): fix prop8b
simon-something Dec 11, 2024
c0ffee2
test(medusa): false pos fix
simon-something Dec 16, 2024
c0ffeea
test(medusa): false pos fix
simon-something Dec 16, 2024
a3b8f1c
Merge branch 'dev' into test/handler-cov
simon-something Dec 18, 2024
c0ffee8
Revert "Merge branch 'dev' into test/handler-cov"
simon-something Dec 18, 2024
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
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ out-via-ir
# Keep the latest deployment only
broadcast/*/*/*

# Out dir
# Medusa files
out
crytic-export

# Echidna corpus
test/invariants/fuzz/echidna_coverage
test/invariants/corpus
test/invariants/fuzz/corpus
2 changes: 1 addition & 1 deletion .solhint.tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"var-name-mixedcase": "off",
"const-name-snakecase": "off",
"no-inline-assembly": "off",
"no-empty-blocks": "error",
"no-empty-blocks": "off",
"definition-name-capwords": "off",
"named-parameters-function": "off",
"no-global-import": "off",
Expand Down
Empty file added 1
Empty file.
185 changes: 5 additions & 180 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ The deployments are stored in ./broadcast
See the [Foundry Book for available options](https://book.getfoundry.sh/reference/forge/forge-create.html).

## Licensing
The primary license for EBO contracts is GPL-3.0, see [`LICENSE`](./LICENSE).
TODO

## Contributors

Expand Down
Empty file added log/log-1733753739.log
Empty file.
241 changes: 241 additions & 0 deletions log/log-1733753780.log

Large diffs are not rendered by default.

Empty file added log/log-1733753814.log
Empty file.
87 changes: 87 additions & 0 deletions medusa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"fuzzing": {
"workers": 10,
"workerResetLimit": 50,
"timeout": 0,
"testLimit": 0,
"shrinkLimit": 100000,
"callSequenceLength": 100,
"corpusDirectory": "test/invariants/corpus",
"coverageEnabled": true,
"targetContracts": ["FuzzTest"],
"predeployedContracts": { "ValidatorLib": "0xc0ffee" },
"targetContractsBalances": [],
"constructorArgs": {},
"deployerAddress": "0x30000",
"senderAddresses": [
"0x10000",
"0x20000",
"0x30000",
"0x40000",
"0x50000",
"0x60000",
"0x70000",
"0x80000",
"0x90000",
"0xa0000"
],
"blockNumberDelayMax": 60480,
"blockTimestampDelayMax": 604800,
"blockGasLimit": 125000000,
"transactionGasLimit": 12500000,
"testing": {
"stopOnFailedTest": true,
"stopOnFailedContractMatching": false,
"stopOnNoTests": true,
"testAllContracts": false,
"traceAll": false,
"assertionTesting": {
"enabled": true,
"testViewMethods": true,
"panicCodeConfig": {
"failOnCompilerInsertedPanic": false,
"failOnAssertion": true,
"failOnArithmeticUnderflow": false,
"failOnDivideByZero": false,
"failOnEnumTypeConversionOutOfBounds": false,
"failOnIncorrectStorageAccess": false,
"failOnPopEmptyArray": false,
"failOnOutOfBoundsArrayAccess": false,
"failOnAllocateTooMuchMemory": false,
"failOnCallUninitializedVariable": false
}
},
"propertyTesting": {
"enabled": true,
"testPrefixes": ["property_"]
},
"optimizationTesting": {
"enabled": true,
"testPrefixes": ["optimize_"]
},
"targetFunctionSignatures": [],
"excludeFunctionSignatures": [""]
},
"chainConfig": {
"codeSizeCheckDisabled": true,
"cheatCodes": {
"cheatCodesEnabled": true,
"enableFFI": false
}
}
},
"compilation": {
"platform": "crytic-compile",
"platformConfig": {
"target": "test/invariants/FuzzTest.t.sol",
simon-something marked this conversation as resolved.
Show resolved Hide resolved
"solcVersion": "",
"exportDirectory": "",
"args": ["--compile-libraries=(ValidatorLib,0xc0ffee)"]
}
},
"logging": {
"level": "info",
"logDirectory": "",
"noColor": false
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"build": "forge build",
"build:optimized": "FOUNDRY_PROFILE=optimized forge build",
"coverage": "forge coverage --ir-minimum --report summary --report lcov --match-path 'test/unit/*'",
"coverage": "forge coverage --report summary --report lcov --match-path 'test/unit/*'",
"deploy:arbitrum": "bash -c 'source .env && forge script Deploy --rpc-url arbitrum --account $ARBITRUM_DEPLOYER_NAME --broadcast --verify --chain arbitrum -vvvvv'",
"lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix",
Expand All @@ -34,8 +34,8 @@
"package.json": "sort-package-json"
},
"dependencies": {
"@defi-wonderland/prophet-core": "0.0.0-819e5fe9",
"@defi-wonderland/prophet-modules": "0.0.0-022dfec8"
"@defi-wonderland/prophet-core": "0.0.0-96d1084b",
"@defi-wonderland/prophet-modules": "0.0.0-b72dcda6"
},
"devDependencies": {
"@commitlint/cli": "19.3.0",
Expand Down
1 change: 1 addition & 0 deletions script/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ address constant _ARBITRUM_MAINNET_COUNCIL = address(0x101);
address constant _ARBITRUM_SEPOLIA_GRAPH_TOKEN = 0x1A1af8B44fD59dd2bbEb456D1b7604c7bd340702;
address constant _ARBITRUM_SEPOLIA_HORIZON_STAKING = 0x3F53F9f9a5d7F36dCC869f8D2F227499c411c0cf;
address constant _ARBITRUM_SEPOLIA_EPOCH_MANAGER = 0x7975475801BEf845f10Ce7784DC69aB1e0344f11;
address constant _ARBITRUM_SEPOLIA_GOVERNOR = 0xadE6B8EB69a49B56929C1d4F4b428d791861dB6f;
address constant _ARBITRUM_SEPOLIA_ARBITRATOR = address(0x100);
address constant _ARBITRUM_SEPOLIA_COUNCIL = address(0x101);

Expand Down
15 changes: 3 additions & 12 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ import {
IBondEscalationAccounting
} from '@defi-wonderland/prophet-modules/solidity/interfaces/extensions/IBondEscalationAccounting.sol';
import {IERC20} from '@openzeppelin/contracts/interfaces/IERC20.sol';

import {Arbitrable, IArbitrable} from 'contracts/Arbitrable.sol';
import {CouncilArbitrator, ICouncilArbitrator} from 'contracts/CouncilArbitrator.sol';
import {IEpochManager} from 'interfaces/external/IEpochManager.sol';
import {IHorizonStaking} from 'interfaces/external/IHorizonStaking.sol';

import {EBOAccessModule, IEBOAccessModule} from 'contracts/EBOAccessModule.sol';
import {Arbitrable, IArbitrable} from 'contracts/Arbitrable.sol';
import {CouncilArbitrator, ICouncilArbitrator} from 'contracts/CouncilArbitrator.sol';
import {EBOFinalityModule, IEBOFinalityModule} from 'contracts/EBOFinalityModule.sol';
import {EBORequestCreator, IEBORequestCreator} from 'contracts/EBORequestCreator.sol';
import {EBORequestModule, IEBORequestModule} from 'contracts/EBORequestModule.sol';
Expand All @@ -44,7 +42,7 @@ import {
import 'forge-std/Script.sol';

contract Deploy is Script {
uint256 public constant DEPLOYMENT_COUNT = 11;
uint256 public constant DEPLOYMENT_COUNT = 10;
uint256 public constant OFFSET_EBO_REQUEST_CREATOR = DEPLOYMENT_COUNT - 1;

// Oracle
Expand All @@ -56,7 +54,6 @@ contract Deploy is Script {
IBondEscalationModule public bondEscalationModule;
IArbitratorModule public arbitratorModule;
IEBOFinalityModule public eboFinalityModule;
IEBOAccessModule public eboAccessModule;

// Extensions
IHorizonAccountingExtension public horizonAccountingExtension;
Expand Down Expand Up @@ -158,10 +155,6 @@ contract Deploy is Script {
councilArbitrator = new CouncilArbitrator(arbitratorModule, arbitrable);
console.log('`CouncilArbitrator` deployed at:', address(councilArbitrator));

// Deploy `EBOAccessModule`
eboAccessModule = new EBOAccessModule(oracle, arbitrable, horizonAccountingExtension);
console.log('`EBOAccessModule` deployed at:', address(eboAccessModule));

// Deploy `EBORequestCreator`
IOracle.Request memory _requestData = _instantiateRequestData();
eboRequestCreator = new EBORequestCreator(oracle, epochManager, arbitrable, _requestData);
Expand All @@ -178,9 +171,7 @@ contract Deploy is Script {
_requestData.nonce = 0;

// Set requester and modules

_requestData.requester = address(eboRequestCreator);
_requestData.accessModule = address(eboAccessModule);
_requestData.requestModule = address(eboRequestModule);
_requestData.responseModule = address(bondedResponseModule);
_requestData.disputeModule = address(bondEscalationModule);
Expand Down
9 changes: 2 additions & 7 deletions src/contracts/CouncilArbitrator.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.26;

import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol';
import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol';
import {IArbitrator} from '@defi-wonderland/prophet-modules/solidity/interfaces/IArbitrator.sol';

Expand Down Expand Up @@ -69,20 +68,16 @@ contract CouncilArbitrator is ICouncilArbitrator {
if (getAnswer[_disputeId] != IOracle.DisputeStatus.None) revert CouncilArbitrator_DisputeAlreadyArbitrated();

getAnswer[_disputeId] = _award;
IAccessController.AccessControl memory _accessControl =
IAccessController.AccessControl({user: address(this), data: bytes('')});

ORACLE.resolveDispute(
_resolutionParams.request, _resolutionParams.response, _resolutionParams.dispute, _accessControl
);
ORACLE.resolveDispute(_resolutionParams.request, _resolutionParams.response, _resolutionParams.dispute);

// If the request was not finalized, finalize it
if (ORACLE.finalizedAt(_resolutionParams.dispute.requestId) == 0) {
// If the dispute was lost, finalize with response
if (_award != IOracle.DisputeStatus.Lost) {
_resolutionParams.response.requestId = 0;
}
ORACLE.finalize(_resolutionParams.request, _resolutionParams.response, _accessControl);
ORACLE.finalize(_resolutionParams.request, _resolutionParams.response);
}

emit DisputeArbitrated(_disputeId, _award);
Expand Down
79 changes: 0 additions & 79 deletions src/contracts/EBOAccessModule.sol

This file was deleted.

6 changes: 2 additions & 4 deletions src/contracts/EBORequestCreator.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.26;

import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/access/IAccessController.sol';
import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

import {
Expand Down Expand Up @@ -82,11 +81,10 @@ contract EBORequestCreator is IEBORequestCreator {
) revert EBORequestCreator_RequestAlreadyCreated();

_requestModuleData.chainId = _chainId;

_requestData.requestModuleData = abi.encode(_requestModuleData);

IAccessController.AccessControl memory _accessControl =
IAccessController.AccessControl({user: address(this), data: bytes('')});
_requestId = ORACLE.createRequest(_requestData, bytes32(0), _accessControl);
_requestId = ORACLE.createRequest(_requestData, bytes32(0));

requestIdPerChainAndEpoch[_chainId][_epoch] = _requestId;

Expand Down
1 change: 1 addition & 0 deletions src/contracts/EBORequestModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.8.26;

import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol';

import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';

import {IArbitrable, IEBORequestCreator, IEBORequestModule, IOracle} from 'interfaces/IEBORequestModule.sol';
Expand Down
3 changes: 3 additions & 0 deletions src/contracts/HorizonAccountingExtension.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ contract HorizonAccountingExtension is Validator, IHorizonAccountingExtension {

// Check the balance in the contract
// If not enough balance, slash some users to get enough balance
// TODO: How many iterations should we do?
while (disputeBalance[_disputeId] < _rewardAmount) {
_slash(_disputeId, MAX_USERS_TO_SLASH, maxUsersToCheck, _result, _status);
}
Expand Down Expand Up @@ -406,6 +407,8 @@ contract HorizonAccountingExtension is Validator, IHorizonAccountingExtension {
if (_slashAmount > 0) {
// Slash the user
HORIZON_STAKING.slash(_user, _slashAmount, _slashAmount, address(this));
// TODO: What if `MIN_THAWING_PERIOD` has passed, all provision tokens have been thawed
// and slashing is skipped or reverts (bricking `claimEscalationReward()`)?

_unbond(_user, _slashAmount);

Expand Down
Loading
Loading