MarketplaceFacet.fillPodListingThe plotIndexes array is designed to contain unique plot indexes, ensuring that no index appears more than once. However, due to an oversight in the fillPodListing function in the MarketplaceFacet, it is possible for multiple entries to have the same index.
During the fillPodListing function call, the user filling the pod listing receives the newly purchased pods from the lister based on the following logic:
Let's assume Alice currently owns a plot starting at index 10, ranging from 10-110 (100 pods), and wishes to sell pods 50-110.
When Bob buys pods 50-60, the transfer process is as follows:
Delete the original plot from Alice.
Create a new plot for Alice from the starting index (10) to the start of the purchased pods (50).
Create a new plot for Bob from the start of the purchased pods (50) to the end (60).
Create a new plot for Alice from the end of the purchased pods (60) to the end (110).
However, if Bob buys zero pods while Alice holds the listing from 10-110, the process will look like this:
Delete the original plot from Alice.
Create a new plot for Alice from the starting index (10) to the end (110) (no change for Alice).
Create a new plot for Bob from the starting index (10) to the starting index (10) (the plot size will be zero, but the index will still be pushed to plotIndexes).
There is currently no check in the _fillListing function to prevent buying zero pods.
Functions utilizing the plotIndexes array will return incorrect values.
For example, getPlotsFromAccount will return the same plot multiple times.
Additionally, removePlotIndexFromAccount will only remove a single instance of the index, failing to perform correctly.
Include a requirement in the _fillPodListing function to ensure that beanPayAmount > 0:
To reproduce the issue, add the following test to protocol/test/Marketplace.test.js in the describe("Fill") section and execute it using yarn test --grep "Test Bug":
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.