Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions golem_base_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
UpdateEntityReturnType,
WatchLogsHandle,
)
from .utils import parse_legacy_btl_extended_log, rlp_encode_transaction
from .utils import rlp_encode_transaction

__all__: Sequence[str] = [
# Exports from .types
Expand Down Expand Up @@ -541,15 +541,6 @@ async def _process_golem_base_log_receipt(
),
)
)
# This is only here for backwards compatibility and can be removed
# once we undeploy kaolin.
case (
"GolemBaseStorageEntityBTLExptended"
| "GolemBaseStorageEntityTTLExptended"
):
extensions.append(parse_legacy_btl_extended_log(log_receipt))
case other:
raise ValueError(f"Unknown event type: {other}")

return GolemBaseTransactionReceipt(
creates=creates,
Expand Down Expand Up @@ -695,13 +686,7 @@ def create_subscription(topic: HexStr) -> LogsSubscription:
if delete_callback:
event_names.append("GolemBaseStorageEntityDeleted")
if extend_callback:
event_names.extend(
[
"GolemBaseStorageEntityBTLExtended",
"GolemBaseStorageEntityBTLExptended",
"GolemBaseStorageEntityTTLExptended",
]
)
event_names.append("GolemBaseStorageEntityBTLExtended")

events = list(
map(
Expand Down
22 changes: 0 additions & 22 deletions golem_base_sdk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,4 @@
"name": "GolemBaseStorageEntityBTLExtended",
"type": "event",
},
# Old ABI event that has a typo in the name and a missing non-indexed argument.
# This can be removed once we retire the kaolin network (the only one using
# this event hash).
{
"anonymous": False,
"inputs": [
{"indexed": True, "name": "entityKey", "type": "uint256"},
{"indexed": False, "name": "expirationBlock", "type": "uint256"},
],
"name": "GolemBaseStorageEntityBTLExptended",
"type": "event",
},
# Old ABI before rename of TTL -> BTL
{
"anonymous": False,
"inputs": [
{"indexed": True, "name": "entityKey", "type": "uint256"},
{"indexed": False, "name": "expirationBlock", "type": "uint256"},
],
"name": "GolemBaseStorageEntityTTLExptended",
"type": "event",
},
]
35 changes: 0 additions & 35 deletions golem_base_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
import logging

import rlp
from web3.types import LogReceipt

from .types import (
Annotation,
EntityKey,
ExtendEntityReturnType,
GenericBytes,
GolemBaseTransaction,
)

Expand Down Expand Up @@ -73,34 +69,3 @@ def format_annotation[T](annotation: Annotation[T]) -> tuple[str, T]:
encoded: bytes = rlp.encode(payload)
logger.debug("Encoded payload: %s", encoded)
return encoded


def parse_legacy_btl_extended_log(log_receipt: LogReceipt) -> ExtendEntityReturnType:
"""
Parse legacy BTL extended logs.

For legacy extend ABI types, the type signature in the ABI does
not correspond to the actual data returned, so we need
to parse the data ourselves.
"""
# pylint: disable=line-too-long
# Take the first 64 bytes by masking the rest
# (shift 1 to the left 256 positions, then negate the number)
# Example:
# 0x 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 012f
# 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0143
# mask this with:
# 0x 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
# 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111
# to obtain 0x143
# and then shift the original number to the right
# by 256 to obtain 0x12f
data_parsed = int.from_bytes(log_receipt["data"], byteorder="big", signed=False)
new_expiration_block = data_parsed & ((1 << 256) - 1)
old_expiration_block = data_parsed >> 256

return ExtendEntityReturnType(
old_expiration_block=old_expiration_block,
new_expiration_block=new_expiration_block,
entity_key=EntityKey(GenericBytes(log_receipt["topics"][1])),
)
Loading