Open hats-bug-reporter[bot] opened 7 months ago
Sorry, the output didn't appear for some reason:
running 1 test
Balance of ALICE before claiming: 0
Balance of ALICE after claiming: 86400
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.88s
Thanks for the submission. Similarly to my comment on #45 - this is a duplicate finding of #44 .
Advise for the future - when you write a test, it should contain assertions that fail if the output is not what's expected. In your case, it ends with println
s. If you replace it with:
// ALICE claims the rewards
let rewards_claimed = claim_from_farm(
&mut session,
&farm,
[0].to_vec(),
ALICE).unwrap();
assert_eq!(vec![100000], rewards_claimed);
it will fail with a mismatch. If you move your test on top of https://github.com/Cardinal-Cryptography/common-amm/pull/84 it will pass.
EDIT: you'll need to fix your test first as in the one attached Alice is not a farmer:
Balance of ALICE before claiming: 0
thread 'hats::rewards_distribution_fail' panicked at 'called `Result::unwrap()` on an `Err` value: CallerNotFarmer', src/hats.rs:908:81
Thanks for the submission. This is a duplicate finding of #44 .
Advise for the future - when you write a test, it should contain assertions that fail if the output is not what's expected. In your case, it ends with
println
s. If you replace it with:// ALICE claims the rewards let rewards_claimed = claim_from_farm( &mut session, &farm, [0].to_vec(), ALICE).unwrap(); assert_eq!(vec![100000], rewards_claimed);
it will fail with a mismatch. If you move your test on top of Cardinal-Cryptography#84 it will pass.
EDIT: you'll need to fix your test first as in the one attached Alice is not a farmer:
Balance of ALICE before claiming: 0 thread 'hats::rewards_distribution_fail' panicked at 'called `Result::unwrap()` on an `Err` value: CallerNotFarmer', src/hats.rs:908:81
thanks for the advice, i've tried doing assertEq! with claimed rewards but it always returns 0 for me for some reason I don't know so i just use println! hope it's ok. Concerning ALICE being not a farmer: I don't know what the hell happened when I uploaded submission but it was a deposit from ALICE in my initial test, otherwise I wouldn't get this output and the test would fail
@deuszx lol we silently missed #44 yesterday when we discussed #43:
Bob should have accumulated rewards_amount of rewards, not 86400. rewards_amount = 10_000.
@deuszx lol we silently missed #44 yesterday when we discussed #43:
Bob should have accumulated rewards_amount of rewards, not 86400. rewards_amount = 10_000.
I think the two are unreleated. #43 states that a huge deposit after the farm ends affects the previous farms' rewards. That statement is untrue. Maybe you've observed something that in its core is really #44 but only #44 correctly pointed out the problem.
Thank you for the submission. After carefully reviewing it we've decided to mark it as INVALID.
PoC should refer to the actual point where the issue lies in and why. It's not enough to describe one of many scenarios where things break, without pointing out why.
We hope to see you in the future challenges of ink! codebase.
Github username: @rodiontr Twitter username: -- Submission hash (on-chain): 0x5d2df285a3916c2d5140a328b4d7e96bd0063997ed04c121a19fd8411b7f0f61 Severity: high
Description: Description\
The rewards for the farming are not fully distributed to the users as the reward amount will be equal to the duration and not to the actual rewards amount.
Attack Scenario\
Let's say the owner starts farm with 100000 rewards and makes the duration equal to 86_400 (one day). The problem is that the farmer (ALICE, see PoC below), will get only 86400 tokens after the end of the period instead of getting the whole 100000 amount as she should being the only farmer.
Attachments
PoC:
Add this to your
test.rs
The test gives the following output:
This means that ALICE had 0 tokens before the claim and only 86400 after that but the amount claimed should be equal to 100000.