Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions with blacklisted eth receivers are included in a batch profitability comparison #40

Closed
stana-miric opened this issue Jan 19, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@stana-miric
Copy link
Contributor

When building a batch, transactions are first collected from the outgoing transaction pool in order to calculate the total bridge fee and check if a more profitable batch of the same token type already exists in the pool. When doing this, there is no check if the translation’s destination address is included in the blacklist or not. Later, when transactions are collected to be included in the batch, additional blacklist filtering is applied. This can cause potential creation of the less profitable batch than the one of the same token type with the biggest nonce already in the pool. Also, the double retrieval of the calculations seems unnecessary.

@jkilpatr jkilpatr added the bug Something isn't working label Jan 24, 2022
@jkilpatr
Copy link
Collaborator

This is an excellent catch! Thank you for taking the time to investigate the issue.

I'll look into it myself today and follow up with more comments.

@jkilpatr
Copy link
Collaborator

So I've dug into this and it seems very straightforward to add the same check from here to here

This seems like a 20 minute patch, maybe an hour or two if you want to make the blacklist check more generic and avoid code duplciation.

From your comments I assume you're digging into reducing the repeated fee computation that's currently a big part of batch creation? Batch creation is pretty complex, and optimizing it will quickly baloon into a lot of work, not that I don't think it's important just wondering on priorities.

Thanks for finding and reporting this bug!

@stana-miric
Copy link
Contributor Author

stana-miric commented Jan 28, 2022

Agree that refactoring should be avoided at this point and with the proposed solution.
We fixed this and adapted tests and 2 other minor issues are resolved which are related to the building batches.

One is related to the GetFees function(the sum will always be 0),
and the other one with the GetLastOutgoingBatchByTokenType (the lastBatch will always point to the last batch in the array)
Also, here should check be greater or equal(.GTE)?

@jkilpatr
Copy link
Collaborator

GT or GTE either should work there. Good catch on get fees as well.

If you have the fixes locally could you get them up as PRs? I'd love to review/merge so that we can have them ready for the next upgrade.

stana-miric added a commit to stana-miric/Gravity-Bridge that referenced this issue Feb 1, 2022
jkilpatr pushed a commit to stana-miric/Gravity-Bridge that referenced this issue Feb 1, 2022
jkilpatr pushed a commit that referenced this issue Feb 1, 2022
@jkilpatr
Copy link
Collaborator

jkilpatr commented Feb 1, 2022

resolved in #57

@jkilpatr jkilpatr closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants