-
Notifications
You must be signed in to change notification settings - Fork 164
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
DRAFT: Perform Apricot Phase 2 Validation on EVM ImportTxs #187
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Check cb58 values instead of hex * Subtracting fee from EVMImportTx
* Variable names
* Now that the AVAX AssetId is a constant we can remove these async calls * Formatting to use fooID instead of fooid or fooId
* * Formatting * Variable names * Now that the AVAX AssetId is a constant we can remove this async call. * Refactoring. * Formatting. * More formatting. * Cleanup.
Tests * Multi AVAX EVMOutput fail * Multi ANT EVMOutput fail * Single AVAX EVMOutput fail * Single ANT EVMOutput fail Miscellaneous * Fix jest warning * Select networkId * Use multiple hex addresses * Formatting and cleanup
Tests: Single ANT EVMOutput success Multiple ANT EVMOutput success Single underfunded AVAX EVMOutput fail Single AVAX EVMOutput success
cgcardona
approved these changes
May 7, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Let's merge to development
. 🎖️
Merged
dfenstermaker
pushed a commit
that referenced
this pull request
Feb 22, 2023
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
ImportTx
s for the EVM now have to obey two new rules:EVMOutput
s must not have any duplicate (assetID
,address
) pairs. That is, there cannot be multiple outputs sending the same asset to the same address. A given address may receive multiple assets, and a given asset may be sent to multiple addresses, but you can't (for example) send my address some AVAX in two separate Outputs.Input
amounts and AVAX-relatedEVMOutput
s must be equal to or greater than the transaction fee.At the end of
ImportTx
construction,validateOuts
is called to enforce these rules, throwing errors if they are broken. Because this function needs access toins
andouts
, but it is legal to call theconstructor
withoutins
andouts
,validateOuts
is only called if bothins
andouts
is provided to theconstructor
.TODOs/In Progress/Questions
Question: proper way to get amount from an input / proper way to get the amount burnedgetBurn
in thecommon/evmtx.ts:EVMStandardTx
class, but one doesn't seem to have access to that from theImportTx
constructor. Instead thegetBurn
code was used as a template for the existing calculation at time of writing.Question: proper way to get the AVAX AssetIDQuestion: proper way to get the fee requiredDefaults
.buildExportTx-cchain-avax.ts
successfully, there's some investigation and bugfixing to do there. EDIT: This ended up being a case of a wrong chainID, which makes me wonder:QUESTION: is a newDefaults.network
needed? TODO add it if soSee Also
I wonder if the
buildImportTx
implementation should change at all, or if that's outside the scope of this PR.Testing
evm-multi-avax-import-fail
Here’s a script to test a failure scenario. This script creates 2
EVMOutputs
w/ the same address and assetId.evm-multi-avax-import-success
Here’s a script to test a success scenario. This script creates 2
EVMOutputs
w/ the same assetId but different addresses which is valid.ts-node evm-multi-avax-import-success.ts Success! TXID: Wg4bmPRoes7nP48BKNnR5bmDfH7R8gTS2wQm7fHec4gFFYE99
evm-multi-asset-import-success
First mint an ANT with this script. Next use this script to test a success scenario. This script creates 2
EVMOutputs
for AVAX and 2EVMOutputs
for the newly minted ANT. For each pair ofEVMOutputs
they have the same assetId but different addresses which is validevm-ant-import-fail
First mint an ANT with this script. Next use this script to test a failure scenario. This creates 1
EVMOutput
with a non-AVAX assetId and no AVAX fee. This should fail.