Links:
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleRegistry.sol#L130
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleCoordinator.sol#L234
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleCoordinator.sol#L348
https://github.com/Cyfrin/2024-10-swan-dria/blob/c8686b199daadcef3161980022e12b66a5304f8e/contracts/llm/LLMOracleCoordinator.sol#L369
The finalizeValidation and unregister function correcly adjusts the allowance for each validator/generator, but there is no easy way for a validator/generator to retrieve the accumulated fees / stake amounts.
The docs state: "* Each oracle node can be thought of as an EOA that needs to register to the registry with some stake. The oracle can have two roles, generator or validator. They can register to both types if they would like to."
So, a validator/generator is an EOA and therfore it will be quite complicated to retrieve accumulated fees from the actual LLMOracleCoordinator/LLMOracleRegistry contract. A validator/generator would need to write a script using Ethers.js (or a similar library) that creates an instance of the fee token, connects with the corresponding validator/generator signer and calls the transferFrom method.
This, of course is unacceptable in terms of the user experience as most validators/generators would not be able to recover their fees.
The current contract behavior prevents validators/generators from accessing their accumulated fees / stake amounts, potentially resulting in a permanent loss of earned rewards / stake amounts
Manual Review
Remark: The following code sections only cover possible solutions to recover validator fees - the same code can be used to recover generator fees.
To ensure that validators/generators can access their fee tokens, a mechanism needs to be implemented that allows them to withdraw their fees. There are two approaches:
Direct Transfer to Validator: Transfer the fee immediately within the loop instead of modifying the allowance. This approach is straightforward but may be less flexible if you want to aggregate validator earnings over multiple validations:
Withdraw Pattern: Track each validator's accumulated fees in the contract and allow them to withdraw their balance on demand. Implement a mapping to track each validator’s balance and a withdraw function:
Add a withdraw function:
For the LLMOracleRegistry::unregister functions, the following modifications are required:
Direct Transfer to the oracle: Transfer the stake amount in the unregister function instead of modifying the allowance:
Withdraw Pattern: Track each oracle's accumulated stake amount in the contract and allow them to withdraw their balance on demand. Implement a mapping to track each oracle’s balance and a withdraw function:
Add a withdraw function:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.