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

Add binary search for creator tx hash #1809

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

kuzdogan
Copy link
Member

Adds a new function findContractCreationTxByBinarySearch to do a lower bound binary search for the transaction that created the contract.

Calls eth_getCode on the middle blocks to see if the contract has code. If yes, the contract should be created before this block. If no code, the contract should be created after this block.
Once the block is found, searches through all the tx's of the block to see if any of them created this contract.
Only supports EOA contract creations (tx.to === null). Tracing every single tx would've been quite expensive.

Adds unit tests and an integration test for the Mainnet Tether contract to test the function.

@manuelwedler
Copy link
Collaborator

Tests are failing

Since now server started to find creation Tx hashes with the binary search, tests were failing.

We add the creation related info to some tests and block fetching the creation tx when testing for updating creation info in the db.
@kuzdogan
Copy link
Member Author

@manuelwedler Fixed the failing tests after we enabled binary search for finding creation transactions. The test suite was breaking because the server now uses binary search to locate transaction hashes for contract creation.

I made two main changes to resolve this:

  1. Added the necessary creation data to the test cases that needed it
  2. Blocked the creation transaction fetching specifically for tests that verify database updates of creation info

Please have a look at the updated tests too. The tests are now passing again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Sprint - Needs Review
Development

Successfully merging this pull request may close these issues.

2 participants