-
Notifications
You must be signed in to change notification settings - Fork 979
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
slither-read-storage native POA support #1843
slither-read-storage native POA support #1843
Conversation
In SlitherReadStorage, self.rpc_info: Optional[RpcInfo] replaces self.rpc, self._block, self._web3
I'm running into an error in
I'm thinking it might be better to use the pre-existing |
test_read_storage is passing on my machine, but for some reason the
|
The more I look at it, the more it seems like introducing the def parse_block_identifier(
w3: "Web3", block_identifier: BlockIdentifier
) -> BlockIdentifier:
if block_identifier is None:
return w3.eth.default_block
if isinstance(block_identifier, int):
return parse_block_identifier_int(w3, block_identifier)
elif block_identifier in ["latest", "earliest", "pending", "safe", "finalized"]:
return block_identifier
elif isinstance(block_identifier, bytes) or is_hex_encoded_block_hash(
block_identifier
):
return w3.eth.get_block(block_identifier)["number"]
else:
raise BlockNumberOutofRange I am leaning toward going back to this and removing class RpcInfo:
def __init__(self, rpc_url: str, block: BlockIdentifier = "latest") -> None:
assert isinstance(block, int) or block in ["latest", "earliest", "pending", "safe", "finalized"]
... |
@0xalpharush I went ahead and changed it back |
Better, cleaner python Co-authored-by: alpharush <[email protected]>
allow ValueError if user provides invalid block arg
I think we can squash and merge this |
Adds a new
RpcInfo
class that holdsself.rpc
,self.web3
andself.block
, which are removed fromSlitherReadStorage
.SlitherReadStorage
gets newself._rpc_info: Optional[RpcInfo]
which is required for using Web3.In
RpcInfo
, automatically detect if the network is POA when settingself._block
.web3.eth.get_block
raises an ExtraDataLengthError when using an RPC for a POA network, so if we catch one of those after trying to setself._block
, we know it is a POA network and therefore inject the appropriate middleware.