diff --git a/bridge_indexer/handlers/bridge_matcher.py b/bridge_indexer/handlers/bridge_matcher.py index b123e23..8b3cfc2 100644 --- a/bridge_indexer/handlers/bridge_matcher.py +++ b/bridge_indexer/handlers/bridge_matcher.py @@ -191,6 +191,7 @@ async def check_pending_outbox(cls): bridge_withdrawal: BridgeWithdrawOperation outbox_message = await RollupOutboxMessage.filter( parameters_hash=bridge_withdrawal.l2_transaction.parameters_hash, + bridge_withdrawals=None, ).order_by('level', 'index').first() if outbox_message: diff --git a/bridge_indexer/handlers/etherlink/on_withdraw.py b/bridge_indexer/handlers/etherlink/on_withdraw.py index 839c155..674f683 100644 --- a/bridge_indexer/handlers/etherlink/on_withdraw.py +++ b/bridge_indexer/handlers/etherlink/on_withdraw.py @@ -22,10 +22,7 @@ async def on_withdraw( if event.payload.sender == event.payload.ticket_owner: ctx.logger.warning('Uncommon Withdraw Routing Info: `ticket_owner == sender`. Mark Operation as `Deposit Revert`.') else: - ctx.logger.warning( - f'Incorrect Withdraw Routing Info: Specified `proxy` contract address not whitelisted: {token_contract}. Operation ignored.' - ) - return + ctx.logger.warning(f'Incorrect Withdraw Routing Info: Specified `proxy` contract address not whitelisted: {token_contract}.') withdrawal = await EtherlinkWithdrawOperation.create( timestamp=datetime.fromtimestamp(event.data.timestamp, tz=UTC), diff --git a/bridge_indexer/handlers/etherlink/on_xtz_withdraw.py b/bridge_indexer/handlers/etherlink/on_xtz_withdraw.py index b8bcd44..9ba146d 100644 --- a/bridge_indexer/handlers/etherlink/on_xtz_withdraw.py +++ b/bridge_indexer/handlers/etherlink/on_xtz_withdraw.py @@ -1,13 +1,14 @@ from datetime import UTC from datetime import datetime +from dipdup.context import HandlerContext +from dipdup.models.evm import EvmEvent + from bridge_indexer.handlers.bridge_matcher_locks import BridgeMatcherLocks from bridge_indexer.handlers.rollup_message import OutboxParametersHash from bridge_indexer.models import EtherlinkToken from bridge_indexer.models import EtherlinkWithdrawOperation from bridge_indexer.types.kernel_native.evm_events.withdrawal import WithdrawalPayload -from dipdup.context import HandlerContext -from dipdup.models.evm import EvmEvent async def on_xtz_withdraw( diff --git a/bridge_indexer/handlers/rollup_message.py b/bridge_indexer/handlers/rollup_message.py index 94f5e64..02e972e 100644 --- a/bridge_indexer/handlers/rollup_message.py +++ b/bridge_indexer/handlers/rollup_message.py @@ -6,7 +6,6 @@ from typing import AsyncGenerator from typing import TYPE_CHECKING from uuid import NAMESPACE_OID -from uuid import UUID from uuid import uuid5 import orjson @@ -252,10 +251,6 @@ async def _handle_transfer_inbox_message(self, message): ) async def _handle_external_inbox_message(self, message): - payload = base64.b64decode(message['payload']).hex() - if len(payload) <= 350: - return - self._outbox_level_queue.add(message['level']) async def _handle_outbox_level(self, outbox_level): @@ -275,14 +270,14 @@ async def _handle_outbox_level(self, outbox_level): recent_cement_operations = await self._tzkt.request( method='GET', - url=f'v1/operations/sr_cement?rollup={self._bridge.smart_rollup_address}&level.lt={outbox_level}&sort.desc=level&limit=1', + url=f'v1/operations/sr_cement?rollup={self._bridge.smart_rollup_address}&level.lt={outbox_level}&sort.desc=level&limit=1&status=applied', ) try: lcc_inbox_level = recent_cement_operations[0]['commitment']['inboxLevel'] except KeyError: if 'errors' in recent_cement_operations[0]: for error_data in recent_cement_operations[0]['errors']: - self._logger.warning(error_data['type']) + self._logger.error(error_data['type']) return created_at = datetime.fromisoformat(await self._tzkt.request('GET', f'v1/blocks/{outbox_level}/timestamp')) @@ -406,9 +401,7 @@ async def _from_native_event(self) -> str: payload: NativeWithdrawalPayload = self._value.payload try: - ticket = await TezosTicket.get( - token_id='xtz', - ).prefetch_related('token') + ticket = await TezosTicket.get(token_id='xtz') comparable_data = ComparableDTO( receiver=str(payload.receiver), @@ -426,9 +419,7 @@ async def _from_fa_event(self) -> str: payload: FAWithdrawalPayload = self._value.payload try: - ticket = await TezosTicket.get( - hash=payload.ticket_hash, - ).prefetch_related('token', 'etherlink_tokens') + ticket = await TezosTicket.get(hash=payload.ticket_hash) assert ticket.ticketer_address == payload.proxy comparable_data = ComparableDTO( diff --git a/bridge_indexer/hooks/on_synchronized.py b/bridge_indexer/hooks/on_synchronized.py index 05d21b1..ad60719 100644 --- a/bridge_indexer/hooks/on_synchronized.py +++ b/bridge_indexer/hooks/on_synchronized.py @@ -1,7 +1,17 @@ from dipdup.context import HookContext +from bridge_indexer.handlers.bridge_matcher_locks import BridgeMatcherLocks + async def on_synchronized( ctx: HookContext, ) -> None: await ctx.execute_sql('on_synchronized') + + BridgeMatcherLocks.set_pending_tezos_deposits() + BridgeMatcherLocks.set_pending_inbox() + BridgeMatcherLocks.set_pending_etherlink_deposits() + BridgeMatcherLocks.set_pending_etherlink_xtz_deposits() + BridgeMatcherLocks.set_pending_etherlink_withdrawals() + BridgeMatcherLocks.set_pending_outbox() + BridgeMatcherLocks.set_pending_tezos_withdrawals() diff --git a/bridge_indexer/types/output_proof/micheline_expression.py b/bridge_indexer/types/output_proof/micheline_expression.py index 9f896ee..7e24880 100644 --- a/bridge_indexer/types/output_proof/micheline_expression.py +++ b/bridge_indexer/types/output_proof/micheline_expression.py @@ -133,7 +133,7 @@ class Nat(BaseBinarySchema): def unpack(self): r, i = 0, 0 for i, e in enumerate(self._packed): - s = ((e & 0x7f) << (i * 7)) + s = (e & 0x7F) << (i * 7) if s == 0: break r += s