Skip to content

Commit

Permalink
Merge pull request #15 from firstbatchxyz/caglacelik/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
erhant authored Dec 17, 2024
2 parents 61e4e85 + b52ec11 commit fb13c3a
Show file tree
Hide file tree
Showing 25 changed files with 282 additions and 385 deletions.
31 changes: 16 additions & 15 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
LLMOracleCoordinatorTest:test_RegisterOracles() (gas: 85220279)
LLMOracleCoordinatorTest:test_RevertWhen_ValidateWithoutWhitelist() (gas: 85762465)
LLMOracleCoordinatorTest:test_ValidatorIsGenerator() (gas: 85901959)
LLMOracleCoordinatorTest:test_WitValidation_NotEveryGeneratorGetFee() (gas: 86487077)
LLMOracleCoordinatorTest:test_WithValidation() (gas: 86320336)
LLMOracleCoordinatorTest:test_WithoutValidation() (gas: 85890818)
LLMOracleRegistryTest:test_RegisterGeneratorOracle() (gas: 19012935)
LLMOracleRegistryTest:test_RegisterValidatorOracle() (gas: 19118692)
LLMOracleRegistryTest:test_RemoveFromWhitelist() (gas: 19129212)
LLMOracleRegistryTest:test_RevertWhen_RegisterSameGeneratorTwice() (gas: 19016443)
LLMOracleRegistryTest:test_RevertWhen_RegistryHasNotApprovedByOracle() (gas: 18792693)
LLMOracleRegistryTest:test_RevertWhen_UnregisterBeforeEnoughTimeHasPassed() (gas: 19022419)
LLMOracleRegistryTest:test_RevertWhen_UnregisterSameGeneratorTwice() (gas: 19013957)
LLMOracleRegistryTest:test_UnregisterOracle() (gas: 19011031)
LLMOracleRegistryTest:test_WithdrawStakesAfterUnregistering() (gas: 19216115)
DeployTest:test_Deploy() (gas: 18806)
LLMOracleCoordinatorTest:test_RegisterOracles() (gas: 85451094)
LLMOracleCoordinatorTest:test_RevertWhen_ValidateWithoutWhitelist() (gas: 85992710)
LLMOracleCoordinatorTest:test_ValidatorIsGenerator() (gas: 86132116)
LLMOracleCoordinatorTest:test_WitValidation_NotEveryGeneratorGetFee() (gas: 86717264)
LLMOracleCoordinatorTest:test_WithValidation() (gas: 86550482)
LLMOracleCoordinatorTest:test_WithoutValidation() (gas: 86121119)
LLMOracleRegistryTest:test_RegisterGeneratorOracle() (gas: 19039588)
LLMOracleRegistryTest:test_RegisterValidatorOracle() (gas: 19145257)
LLMOracleRegistryTest:test_RemoveFromWhitelist() (gas: 19155867)
LLMOracleRegistryTest:test_RevertWhen_RegisterSameGeneratorTwice() (gas: 19043118)
LLMOracleRegistryTest:test_RevertWhen_RegistryHasNotApprovedByOracle() (gas: 18819346)
LLMOracleRegistryTest:test_RevertWhen_UnregisterBeforeEnoughTimeHasPassed() (gas: 19049072)
LLMOracleRegistryTest:test_RevertWhen_UnregisterSameGeneratorTwice() (gas: 19040632)
LLMOracleRegistryTest:test_UnregisterOracle() (gas: 19037706)
LLMOracleRegistryTest:test_WithdrawStakesAfterUnregistering() (gas: 19242862)
StatisticsTest:testFuzz_Average(uint8,uint8,uint8,uint8) (runs: 256, μ: 9729, ~: 9729)
StatisticsTest:testFuzz_StandardDeviation(uint8,uint8,uint8,uint8,uint8,uint8,uint8,uint8,uint8,uint8) (runs: 256, μ: 21841, ~: 21835)
StatisticsTest:testFuzz_Variance(uint8,uint8,uint8,uint8,uint8) (runs: 256, μ: 13876, ~: 13876)
Expand Down
35 changes: 13 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LLM Oracle is a **Decentralized Protocol** for **executing AI tasks on-chain**.
Compile the contracts with:

```sh
forge build
forge clean && forge build
```

> [!NOTE]
Expand All @@ -19,13 +19,13 @@ forge build
Run tests on local:

```sh
forge test --force
forge clean && forge test
```

or on any other evm chain:

```sh
forge test --rpc-url <RPC_URL>
forge clean && forge test --rpc-url <RPC_URL>
```

## Deployment
Expand All @@ -43,7 +43,6 @@ Create keystores for deployment. [See more for keystores](https://eips.ethereum.
```sh
cast wallet import <FILE_NAME_OF_YOUR_KEYSTORE> --interactive
```

You can see your wallets with:

```sh
Expand All @@ -56,37 +55,30 @@ cast wallet list
> You HAVE to type your password on the terminal to be able to use your keys. (e.g when deploying a contract)
**Step 3.**
Enter your private key (associated with the public key you added to env file) and password on terminal. You'll see your public key on terminal.
Enter your private key (associated with your address) and password on terminal. You'll see your address on terminal.

> [!NOTE]
>
> If you want to deploy contracts on localhost please provide local public key for the command above.
**Step 4.** Required only for local deployment.

Start a local node with:

```sh
anvil
```
> If you want to deploy contracts on localhost please provide local address for the command above.
**Step 5.**
Deploy the contracts with:
**Step 4.**
Deploy the contract with:

```sh
forge script ./script/Deploy.s.sol:Deploy --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_PUBLIC_KEY> --broadcast
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast
```

or for instant verification use:

```sh
forge script ./script/Deploy.s.sol:Deploy --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_PUBLIC_KEY> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
```

> [!NOTE] > `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`.
> [!NOTE]
> `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`.
>
> e.g.
> e.g.
> `https://base-sepolia.blockscout.com/api/` for `Base Sepolia Network`
>
You can see deployed contract addresses under the `deployment/<chainid>.json`

Expand All @@ -105,7 +97,6 @@ Check coverages with:
```sh
forge clean && bash coverage.sh
```

or to see summarized coverages on terminal:

```sh
Expand Down
7 changes: 6 additions & 1 deletion deployment/31337.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
"{ \"LLMOracleRegistry\": { \"proxyAddr\": \"0x9fe46736679d2d9a65f0992f2272de9f3c7fa6e0\", \"implAddr\": \"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512\" }, \"LLMOracleCoordinator\": { \"proxyAddr\": \"0xdc64a140aa3e981100a9beca4e685f962f0cf6c9\", \"implAddr\": \"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9\" }"
{
"LLMOracleRegistry": {
"proxyAddr": "0x34a1d3fff3958843c43ad80f30b94c510645c316",
"implAddr": "0x7fa9385be102ac3eac297483dd6233d62b3e1496"
}
}
27 changes: 9 additions & 18 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LLM Oracle is a **Decentralized Protocol** for **executing AI tasks on-chain**.
Compile the contracts with:

```sh
forge build
forge clean && forge build
```

> [!NOTE]
Expand All @@ -19,13 +19,13 @@ forge build
Run tests on local:

```sh
forge test --force
forge clean && forge test
```

or on any other evm chain:

```sh
forge test --rpc-url <RPC_URL> --force
forge clean && forge test --rpc-url <RPC_URL>
```

## Deployment
Expand Down Expand Up @@ -55,30 +55,22 @@ cast wallet list
> You HAVE to type your password on the terminal to be able to use your keys. (e.g when deploying a contract)
**Step 3.**
Enter your private key (associated with the public key you added to env file) and password on terminal. You'll see your public key on terminal.
Enter your private key (associated with your address) and password on terminal. You'll see your address on terminal.

> [!NOTE]
>
> If you want to deploy contracts on localhost please provide local public key for the command above.
> If you want to deploy contracts on localhost please provide local address for the command above.
**Step 4.** Required only for local deployment.

Start a local node with:

```sh
anvil
```

**Step 5.**
Deploy the contracts with:
**Step 4.**
Deploy the contract with:

```sh
forge clean && forge script ./script/Deploy.s.sol:Deploy --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_PUBLIC_KEY> --broadcast
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast
```
or for instant verification use:

```sh
forge clean && forge script ./script/Deploy.s.sol:Deploy --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_PUBLIC_KEY> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
```

> [!NOTE]
Expand Down Expand Up @@ -158,4 +150,3 @@ forge update
```

You can see the documentation under the `docs/` directory.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# LLMOracleCoordinator
[Git Source](https://github.com/firstbatchxyz/dria-oracle-contracts/blob/cdb7cd04715c2a34800fff701d86f15ce85acfe1/src/LLMOracleCoordinator.sol)
[Git Source](https://github.com/firstbatchxyz/dria-oracle-contracts/blob/609653a954d5da8f6a2fba22755e9328ec77967f/src/LLMOracleCoordinator.sol)

**Inherits:**
[LLMOracleTask](/src/LLMOracleTask.sol/interface.LLMOracleTask.md), [LLMOracleManager](/src/LLMOracleManager.sol/abstract.LLMOracleManager.md), UUPSUpgradeable
Expand Down Expand Up @@ -94,11 +94,11 @@ Reverts if the task status is not `status`.
modifier onlyAtStatus(uint256 taskId, TaskStatus status);
```

### isWhiteListed
### onlyWhitelisted


```solidity
modifier isWhiteListed(address account);
modifier onlyWhitelisted(address account);
```

### constructor
Expand Down Expand Up @@ -237,7 +237,7 @@ function validate(uint256 taskId, uint256 nonce, uint256[] calldata scores, byte
public
onlyRegistered(LLMOracleKind.Validator)
onlyAtStatus(taskId, TaskStatus.PendingValidation)
isWhiteListed(msg.sender);
onlyWhitelisted(msg.sender);
```
**Parameters**

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# LLMOracleManager
[Git Source](https://github.com/firstbatchxyz/dria-oracle-contracts/blob/cdb7cd04715c2a34800fff701d86f15ce85acfe1/src/LLMOracleManager.sol)
[Git Source](https://github.com/firstbatchxyz/dria-oracle-contracts/blob/609653a954d5da8f6a2fba22755e9328ec77967f/src/LLMOracleManager.sol)

**Inherits:**
OwnableUpgradeable
Expand Down Expand Up @@ -54,7 +54,7 @@ Minimums for oracle parameters.


```solidity
LLMOracleTaskParameters minimumParameters;
LLMOracleTaskParameters public minimumParameters;
```


Expand All @@ -63,7 +63,7 @@ Maximums for oracle parameters.


```solidity
LLMOracleTaskParameters maximumParameters;
LLMOracleTaskParameters public maximumParameters;
```


Expand Down
Loading

0 comments on commit fb13c3a

Please sign in to comment.