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

WIP: pigeon feed upgrade #30

Closed

Conversation

webelf101
Copy link
Contributor

Related Github tickets

  • a list of github issues that are relevant for this PR

Background

A short paragraph on test what exactly this PR solves.

Testing completed

  • a list of actions that you've performed to ensure that this PR works as intended
  • 99% of the times you should have an item: "wrote tests"

@webelf101 webelf101 requested review from byte-bandit and wc117 March 21, 2024 15:37
@byte-bandit
Copy link
Contributor

Copying your statement from Discord:

Pigeon relayer should put paloma address in bytes32 type and gas estimate amount. They should be in consensus.
update treasury is similar to SLC. You need to put fee rates and wallets, and add consensus.
When users deposit their funds with their paloma address in bytes32 type, community fee and security fee are sent to community wallet and security wallet immediately. And relayer fee is sent on SLC. - This is to decrease gas in transactions.

contracts/Compass.vy Outdated Show resolved Hide resolved
@@ -219,3 +253,40 @@ def deploy_erc20(_paloma_denom: String[64], _name: String[64], _symbol: String[3
event_id: uint256 = unsafe_add(self.last_event_id, 1)
self.last_event_id = event_id
log ERC20DeployedEvent(_paloma_denom, erc20, _name, _symbol, _decimals, event_id)

@external
def update_treasury(consensus: Consensus, _feeset_id: uint256, _community_fee: uint256, _security_fee: uint256, _community_wallet: address, _security_wallet: address):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. At the moment, the wallet addresses are not part of the governance. We could add them, but would it not be easier to have them be part of compass directly? Or would that be too expensive?

  2. What do we do when deploying a new compass. Would it be enough to call update_treasury again to the new compass address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't need to update it, we can set them as constant and it will save so much gas. And we can set them on deployment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per Discord conversation here, this can stay in governance https://discord.com/channels/987730379182051408/1098323494636372129/1220751522032386149

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to add them to governance then. We'll also need to setup proper handover in case of a new compass (just like for ERC20 tokens)

Comment on lines 278 to 292
def deposit(paloma_address: bytes32, amount: uint256):
if msg.value > amount:
send(msg.sender, unsafe_sub(msg.value, amount))
else:
assert msg.value == amount, "Insufficient deposit"
_fee: uint256 = unsafe_div(amount * self.security_fee, DENOMINATOR)
send(self.security_wallet, _fee)
relayer_fee: uint256 = amount - _fee
_fee = unsafe_div(amount * self.community_fee, DENOMINATOR)
send(self.community_wallet, _fee)
relayer_fee -= _fee
_nonce: uint256 = self.deposit_nonce
self.fee_balance[paloma_address] = unsafe_add(self.fee_balance[paloma_address], relayer_fee)
log Deposited(paloma_address, msg.sender, _nonce, relayer_fee)
self.deposit_nonce = unsafe_add(_nonce, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea to just move funds to community and security wallet once during deposit is great. At the moment, those fees are defined as percentages of the relayer_fee, which is unique to each relayer, meaning a more expensive relayer would generate more community/security fee, whereas a cheaper relayer would generate less of it.

It also means that more expensive messages would generate more community and security fees, while cheap messages would generate less.

I honestly don't know the reasoning behind that decision, it was made before my time with Volume and I cannot find any background on this. @taariq @verabehr might know more. See https://www.notion.so/volumefi/EPIC-09-26-22-Paloma-Gas-Management-Pigeon-Feed-78319280833e4c7c8ffad368eddb1d91?pvs=4#659fbe58c4f84d56bce0f86afb35839e for background.

Moving the deduction of those fees to the deposit stage changes how they should be defined, and how we as a team should understand and communicate them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most cheap solution for gas. Paying fees in SLC will increase SLC gas cost more. SLC gas cost is already too expensive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@byte-bandit @webelf101 what is the decision that needs to be made here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taariq my understanding is that
EITHER, we compass becomes more gas expensive and we keep the community and security as percentage of the relayer fee
OR community and security are paid on deposit, but then they would be independent of the actual relayer fee and would need to be a percentage of the deposit amount

contracts/Compass.vy Outdated Show resolved Hide resolved
gas_fee: uint256 = gas_estimation * tx.gasprice
assert _fee_balance >= gas_fee, "Insufficient gas deposit"
self.fee_balance[paloma_address] = unsafe_sub(_fee_balance, gas_fee)
send(msg.sender, gas_fee)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current design calls for relayers to actively request a refund from compass, probably to reduce network fees and so they can time when to cash out?

So compass would have to store this funds as escrow for a while until relayers actively request a refund.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to save gas. Storing some data in a contract requires most gas. So I want to avoid storing the relayer fee amount for relayers but send it to the relayer directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so no claim system, the relayer is reimbursed directly.

How do we protect this against front running? If I see this tx in the mempool and I see that the sender is receiving a nice reward, wouldn't this be a prime candidate for exploiting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We simply send ETH but we don't use exchanges. So there can't be any exploit. @byte-bandit

Copy link
Contributor Author

@webelf101 webelf101 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your idea about the "front running"? I might miss something. @byte-bandit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taariq
Copy link
Contributor

taariq commented Jun 18, 2024

@byte-bandit @webelf101 why is this still open and what do we need to do to close and merge?

@byte-bandit
Copy link
Contributor

This needs changes. I'll be adding them once I get around to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants