Skip to content

Commit

Permalink
1.1.0 Release commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedonnan committed Sep 12, 2023
1 parent e34d19c commit 0b36c37
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,28 @@ Features include:
- Websocket pooling for high performance calls
- Support for RPC batching, allowing multiple calls to the same function at once
- Currency conversion for wei, so you don't have to rely on external libs like Web3.py
- Private transaction and Bundle support for communication directly with block builders

### Implemented RPC methods

All methods listed in the [Ethereum JSON RPC API specification](https://ethereum.org/en/developers/docs/apis/json-rpc/) are completed as of version `1.0.5`,
alongside methods for subscriptions, and support for calling custom function names with custom parameters.

(Methods eth_signTransaction and eth_sendTransaction are currently under construction for reformatting)
### Supported Builders

With the `BuilderRPC` class, pythereum supports submitting bundles and private transactions directly to block builders.
Each builder class that can be passed into BuilderRPC instances automatically manages communication with the given builder.

The following builder classes are currently implemented:

- Titan Builder
- Rsync Builder
- Beaver Builder (Using same parameters as rsync, may need adjustment)
- Builder0x69
- Flashbots Builder (additional robustness testing needed)

With support for creating custom builder classes by inheriting from the `Builder` class.
An implementation of the Beaver Builder and support for [mevboost](mevboost.pics) coming in future versions.

### Example usage

Expand Down Expand Up @@ -48,20 +62,19 @@ import asyncio
from pythereum import EthRPC, SubscriptionType

TEST_URL = "ws://127.0.0.1:8545"
erpc = EthRPC(TEST_URL, pool_size=2)


async def test_subscription(subscription_type: SubscriptionType):
"""
Creates a subscription to receive data about all new heads
Prints each new subscription result as it is received
"""
async with erpc.subscribe(subscription_type) as sc:
# The following will iterate as each item is gotten by sc.recv()
async for item in sc.recv():
# 'item' is formatted into the appropriate form for its subscription type
# this is done by the sc.recv() automatically
print(item)
async with EthRPC(TEST_URL, pool_size=1) as erpc:
async with erpc.subscribe(subscription_type) as sc:
# The following will iterate as each item is gotten by sc.recv()
async for item in sc.recv():
# 'item' is formatted into the appropriate form for its subscription type
# this is done by the sc.recv() automatically
print(item)


if __name__ == "__main__":
Expand Down Expand Up @@ -169,7 +182,7 @@ pythereum = {git = "https://github.com/gabedonnan/pythereum.git"}
or

```toml
pythereum = "^1.0.5"
pythereum = "^1.1.0"
```

If you would like to install the library via pypi instead of via this git repository.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pythereum"
version = "1.0.5"
version = "1.1.0"
description = "A lightweight Ethereum JSON RPC library written in python"
authors = ["gabedonnan <[email protected]>"]
readme = "README.md"
Expand Down
1 change: 1 addition & 0 deletions pythereum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
BuilderRPC,
Builder,
Builder0x69,
BeaverBuilder,
TitanBuilder,
RsyncBuilder,
FlashbotsBuilder,
Expand Down
26 changes: 23 additions & 3 deletions pythereum/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,30 @@ def format_private_transaction(
class BeaverBuilder(Builder):
def __init__(self):
super().__init__(
"https://rpc.beaverbuild.org/",
"eth_sendPrivateTransaction"
"https://rsync-builder.xyz/",
"eth_sendPrivateRawTransaction",
"eth_sendBundle",
"eth_cancelBundle",
{
"txs",
"blockNumber",
"minTimestamp",
"maxTimestamp",
"revertingTxHashes",
"replacementUuid",
"refundPercent",
"refundRecipient",
"refundTxHashes"
}
)

def format_private_transaction(
self,
tx: str | HexStr | list[str] | list[HexStr],
max_block_number: str | HexStr | list[str] | list[HexStr] | None = None
) -> list[Any]:
return [tx]


class RsyncBuilder(Builder):
def __init__(self):
Expand Down Expand Up @@ -297,4 +317,4 @@ async def __aexit__(self, *args):


# A list containing all the current supported builders. Can be passed in to a BuilderRPC to send to all
ALL_BUILDERS = [TitanBuilder(), Builder0x69(), RsyncBuilder()]
ALL_BUILDERS = [TitanBuilder(), Builder0x69(), RsyncBuilder(), BeaverBuilder()]

0 comments on commit 0b36c37

Please sign in to comment.