fix(contract-verifier): Fix verifier data migration #3608
Merged
+73
−30
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.
Recent data migration for contract verifier turned out to be broken. This PR consists of two parts:
Fixing the migration
Turns out, when using CSV format in
COPY FROM STDIN
, you don't need to escape backslashes (e.g. you should use\x
instead of\\x
). When backslash is escaped, the value is being treated as a string, not bytea. This resulted in values like\xd8792c840591d437dac9bbdc6c8d2096b41800c0
being inserted as\x5c7864383739326338343035393164343337646163396262646336633864323039366234313830306330
.The fix is simple: remove the backslash.
Another problem was that in the sanity check I didn't make sure that count of matching rows is actually not zero 🤦 . I've made the check significantly more strict.
Fixing the data
The logic is explained in the migration file. Thanks to the fact that migration is done on SQL side without transferring any data, it completes almost immediately.
Testing
To test it, I've done the following:
contracts_verification_info
from testnet, made sure that now table is being ported correctly.