[BUG]: A tiny stake takes almost the whole reward on a quiet feed
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- solidity
- Domain
- blockchain
Research direction
Read the reward payout path at src/Oracle.sol:130 and the activity/weight math at src/Oracle.sol:228-235, then run the reported reproduction with forge test --match-path test/QuietFeedReward.t.sol -vv to confirm the 1e6 wei staker draining the pool. The payload itself says the fix is a design choice (paying by share of deposits instead of decayed weight) and ties it to #30, so agree on the formula change with maintainers before editing. Done means the reproduction test passes, i.e. the tiny stake receives less than pool / 1000.
Written by the indexing model from the issue text.
Description
Bug Description
Each submit pays a reward of rewardPool * w * activity / newQ (src/Oracle.sol:130 and src/Oracle.sol:228-235) where newQ is the decayed total weight plus the submitter's weight. On a quiet feed the old weight has decayed to about zero so newQ is basically just the submitter's own weight. That means whoever submits next gets close to the full reward no matter how small their stake is.
In my test a staker with 1e6 wei (about 1e-12 of the stake) waited two hours and then took 99.9% of the reward pool in one submit. Resubmitting every 12 seconds keeps paying out too. In 100 submits it took about 1.1% of a 1 ETH balance. Each submit is capped at REWARD_BPS of the balance so this drains slowly but the rewards meant for real stakers go to someone who has almost nothing at stake.
It isn't caused by tof starting at 0 for a new address. A returning staker after a quiet period gets the same full activity factor and setting tof at deposit doesn't stop the repeated submits.
This has the same root as #30. Decayed weight goes to zero on a quiet feed while deposits don't. The reward formula follows Eq. 12 in the paper so changing it is a design choice. One option is to pay by share of deposits instead of share of decayed weight.
Steps to Reproduce
- Fund an oracle with 1 ETH. An honest user stakes 1e18 and submits.
- Another user stakes 1e6 wei.
- Nobody submits for two hours.
- The 1e6 wei user submits and gets almost the whole reward pool.
Logs and Screenshots
Test I used: test/QuietFeedReward.t.sol run with forge test --match-path test/QuietFeedReward.t.sol -vv
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Test, console2} from "lib/forge-std/src/Test.sol";
import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {Oracle} from "../src/Oracle.sol";
contract Tok is ERC20 {
constructor() ERC20("W", "W") {}
function mint(address to, uint256 a) external {
_mint(to, a);
}
}
contract QuietFeedRewardTest is Test {
function test_tinyStakeTakesTheRewardOnAQuietFeed() public {
Tok t = new Tok();
// halfLife 60s, q 50000, both locks 60s, rewardBps 100, gamma 0, sampleSize 5
Oracle o = new Oracle(address(this), "Feed", "d", address(t), 60, 50_000, 60, 60, 100, 0, 5);
vm.deal(address(o), 1 ether);
address honest = makeAddr("honest");
address tiny = makeAddr("tiny");
t.mint(honest, 1e18);
t.mint(tiny, 1e6);
vm.startPrank(honest);
t.approve(address(o), 1e18);
o.depositTokens(1e18);
vm.stopPrank();
vm.startPrank(tiny);
t.approve(address(o), 1e6);
o.depositTokens(1e6);
vm.stopPrank();
vm.warp(vm.getBlockTimestamp() + 61);
vm.prank(honest);
o.submitValue(3000e18);
// nobody submits for 2 hours
vm.warp(vm.getBlockTimestamp() + 2 hours);
uint256 pool = address(o).balance * 100 / 1e5;
vm.prank(tiny);
o.submitValue(3000e18);
console2.log("reward pool for this submit:", pool);
console2.log("paid to a 1e6 wei staker: ", tiny.balance);
// tiny holds 1e-12 of the stake so it should get about nothing
assertLt(tiny.balance, pool / 1000, "tiny stake took most of the reward");
}
}
Output on main 86df9c0:
Ran 1 test for test/QuietFeedReward.t.sol:QuietFeedRewardTest
[FAIL: tiny stake took most of the reward: 999489668518663 >= 999491667500] test_tinyStakeTakesTheRewardOnAQuietFeed() (gas: 2239899)
Logs:
reward pool for this submit: 999491667500000
paid to a 1e6 wei staker: 999489668518663
Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 7.02ms (3.81ms CPU time)
Environment Details
macOS with forge 1.8.7 (same as CI) and solc 0.8.33 with via_ir. Upstream main at 86df9c0. Local tests only.
Impact
Medium - Feature works but has issues
Code of Conduct
- I have joined the Discord server and will post updates there
- I have searched existing issues to avoid duplicates
- Dominant language
- Solidity
- Stars
- 3
- Forks
- 6
- Avg merge
- 14h 14m
- Merged PRs (30d)
- 5
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from StabilityNexus/OrbOracle-Solidity
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
[BUG]: Oracle with rewardBps above 1e5 can never accept a funded price submissionPossibly taken @kansalakshat claimed this 10 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
StabilityNexus/OrbOracle-Solidity#27 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
StabilityNexus/OrbOracle-Solidity#30 · 1 comment ·
-
[BUG]: Old prices stay in the feed after someone resubmits (decay is not multiplicative)Possibly taken @Deepak-negi11 claimed this 15 days ago. Openbug
Difficulty 5/5 Over a week Newbie friendliness 35/100
StabilityNexus/OrbOracle-Solidity#25 · 1 comment ·
All issues in StabilityNexus/OrbOracle-Solidity
Similar issues
-
eth_get_proof reports another account's fields for an absent accountPossibly taken @Indian-boult claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
eth_blobBaseFee should return the blob base fee of the next blockPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ethereum/go-ethereum#36196 ·
Maintainers usually reply within 3 days
-
bug Contract security
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
DogStark/PetChain-Contracts#1644 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
solana-foundation/solana-web3.js#4081 · 1 comment ·
Maintainers usually reply within 1 day