Skip to content

Commit

Permalink
Merge branch 'fix/outbox-indexer'
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsereda committed Oct 12, 2024
2 parents f2b361b + 026f141 commit 3650da8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
1 change: 1 addition & 0 deletions bridge_indexer/handlers/bridge_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions bridge_indexer/handlers/etherlink/on_withdraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 3 additions & 2 deletions bridge_indexer/handlers/etherlink/on_xtz_withdraw.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
17 changes: 4 additions & 13 deletions bridge_indexer/handlers/rollup_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -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'))
Expand Down Expand Up @@ -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),
Expand All @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions bridge_indexer/hooks/on_synchronized.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion bridge_indexer/types/output_proof/micheline_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3650da8

Please sign in to comment.