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 classes to handle W3_RPC #27

Merged
merged 7 commits into from
Jul 30, 2024
Merged

Add classes to handle W3_RPC #27

merged 7 commits into from
Jul 30, 2024

Conversation

Tritium-VLK
Copy link
Member

Use dRPC right now as it's super easy, but this creates an interface that is easy to change in 1 place.
See:
BalancerMaxis/bal_addresses#383

For a test of these classes, I don't think bal_addresses can actually use them due to the dependancy conflict, so maybe this belongs there?

@Tritium-VLK
Copy link
Member Author

Fraxtal is missing from dRPC. Challenging them to see how such a thing is dealt with.

@Tritium-VLK Tritium-VLK marked this pull request as draft July 26, 2024 17:14
@Tritium-VLK
Copy link
Member Author

Next step is to approve/release bal_tools. Then deal with questions about where the canonical list pools to check permissions lives on in the bal_addresses pr and merge/release that. Then release new releases, update the protocol_feel_allocator.

@Tritium-VLK Tritium-VLK marked this pull request as ready for review July 26, 2024 17:22

def __getitem__(self, chain):
if chain not in self.w3_by_chain:
Copy link
Collaborator

@jalbrekt85 jalbrekt85 Jul 27, 2024

Choose a reason for hiding this comment

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

i modified Web3RpcByChain to only init a chains respective w3 instance when referenced for the first time instead of initializing all chains at the start. still maintains the same interface/usage

@jalbrekt85
Copy link
Collaborator

jalbrekt85 commented Jul 27, 2024

nice, simple to use class for web3 instances across all chains. added some very basic tests. lgtm

def __getitem__(self, chain):
return self._get_or_create_w3(chain)

def __getattr__(self, chain):
Copy link
Collaborator

@jalbrekt85 jalbrekt85 Jul 27, 2024

Choose a reason for hiding this comment

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

i also added support for dot syntax, so a chain's web3 instance can be referenced like:

 Web3RpcByChain().mainnet
 # or
 Web3RpcByChain()["mainnet"]

since this class can basically be used across the board, i think making it more flexible is worth it

@gosuto-inzasheru
Copy link
Member

new test is not being run:

collected 94 items

tests/test_drpc.py ss                                                    [  2%]
tests/test_pools_gauges.py ..ss.s.s.ss.s.s.ss.s.s.ss.s.s.ss...s.ss.s.s.s [ 50%]
s.s.s.ss.s.s.ss.s.                                                       [ 69%]
tests/test_safe_tx_builder.py .                                          [ 70%]
tests/test_subgraph.py s.s.s.s.s.s.s.s.s......                           [ 94%]
tests/mock/test_mock_subgraph.py .....                                   [100%]

================== 49 passed, 45 skipped in 142.[59](https://github.com/BalancerMaxis/bal_tools/actions/runs/10119623674/job/27988323246?pr=27#step:6:60)s (0:02:22) ==================

@jalbrekt85
Copy link
Collaborator

new test is not being run:

collected 94 items

tests/test_drpc.py ss                                                    [  2%]
tests/test_pools_gauges.py ..ss.s.s.ss.s.s.ss.s.s.ss.s.s.ss...s.ss.s.s.s [ 50%]
s.s.s.ss.s.s.ss.s.                                                       [ 69%]
tests/test_safe_tx_builder.py .                                          [ 70%]
tests/test_subgraph.py s.s.s.s.s.s.s.s.s......                           [ 94%]
tests/mock/test_mock_subgraph.py .....                                   [100%]

================== 49 passed, 45 skipped in 142.[59](https://github.com/BalancerMaxis/bal_tools/actions/runs/10119623674/job/27988323246?pr=27#step:6:60)s (0:02:22) ==================

fixed in 0f40f08

@Tritium-VLK
Copy link
Member Author

@jalbrekt85 @gosuto-inzasheru thanks for the help. Will merge this and release a new version.

@Tritium-VLK Tritium-VLK merged commit 446bceb into main Jul 30, 2024
4 checks passed
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.

3 participants