-
Notifications
You must be signed in to change notification settings - Fork 65
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
[Bridge] [Solidity] Remove BridgeTransfer Struct #846
Comments
@0xPrimata
Where is the analysis? Maybe we should profile the contracts first and then we identify the culprit section as @0xmovses suggested. |
Responded to issue 842 with gas report |
@0xPrimata Thanks for that. The issue with not storing the bridge transfer details (in both direction) is that we don't have the data (details) for the How do you retrieve the details of a transfer in the |
@franck44 same way, confirm by hashing with the original data. That will create a keccak256 that confirms that the user is inputting legitimate arguments. Then, bridgeTransfers[bridgeTransferId] will be at state 1 and you check that timelock has passed. |
@0xPrimata Read the question again please:
|
Sorry, so we have an API that stores events, we would store the initaite bridge event and that data would serve to call refund.
|
@0xPrimata could you clarify which of this options is the one where the relevant information is extracted from on-chain data. Want to make sure i understand how our service gets the necessary information from onchain data and after it crashed, thereby loosing all data locally. |
@apenzk We can reliably take the transaction input arguments from etherscan.io and their API. |
Implementation available at https://github.com/movementlabsxyz/movement/tree/remove-bridge-struct Gas Report
|
That does not work. You have to store on Ethereum mainnet, not in your own DB.
Not sure you understand what global storage is.
Etherscan is not a trusted API. That's not an option.
That's a very complicated answer unsecured process. It is not practical.
It is too complicated and not secure because either involves untrusted components.
The safe approach is to ensure security first and optimise second. |
@franck44 I meant local computer memory and storage, the app being ran on browser or localStorage.set() That is very debatable and I think that off-loading user's cost is very promising. I dispute that. It's very simple, the Relayer gets the data from events. Oh ya there is one more method, eth_getLogs. That should be enough, you just have to parse the logs and input it directly as arguments. We can even store on Movement but not on Ethereum and we will have a completely onchain storage of all required data for all bridge attempts. This is just as secure as the current method, even more secure because we are currently not hash checking between the initiator and counterparty. Ethereum txs are exhorbitant and can get even more prohibitive expensive. In my life experience, if anything bad happens, a lot of people end up getting locked out because of how expensive it gets, especially retail, I have seen that happen and their losses become massive because they cannot exit. Anything we can do to improve that, and still have it secure, I think is good. btw, we are saving: |
@0xPrimata For Mainnet we don't need that, so we'll hold off on this proposal. |
@0xPrimata tbh a saving of only approximately 60% of cost at this point does not justify a short term fix of something where there seems to be a fundamental debate. Just wanting to express my support for holding off on a quick fix. In particular the following MUST be our standard
|
This is totally fine, I understand it would be unsafe to implement this, but I definitely think it's at least as safe as the current implementation. This is mostly just a V2 proposed change. Totally fine with holding off on the proposal @franck44 .appreciate the response @apenzk . |
Is your feature request related to a problem? Please describe.
Our bridge is currently extremely expensive as shown in our gas analysis: #842
We also need to assert that the bridge values are being passed correctly and keccak256 of all params can handle it. keccak256 is a cheap process, especially for Ethereum Mainnet, keeping all of it's logic in memory.
#830
Describe the solution you'd like
One solution is to drop the struct completely and only store a mapping of the bridgeTransferId to it's state:
mapping(bytes32 bridgeTransferId => uint8 state) bridgeTransfers;
then, on the initiator contract
initiateBridgeTransfer(recipient, amount, hashLock)
the bridgeTransferId is created using params and stored:subsequent calls will use emitted values by
BridgeTransferInitiated();
on the counterparty contract
lockBridgeTransfer(bridgeTransferId, recipient, amount, initialTimestamp, hashLock, nonce)
user calls
lockBridgeTransfer(bridgeTransferId, recipient, amount, initialTimestamp, hashLock, nonce, preImage)
Then we are finally able to call on initiator
completeBridgeTransfer(bridgeTransferId, recipient, amount, initialTimestamp, hashLock, nonce, preImage)
Describe alternatives you've considered
Completely rebuilding the bridge or keeping it as it is.
Additional context
The text was updated successfully, but these errors were encountered: