Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
90a4e56
#291 extract transaction sender class
otselnik Nov 14, 2021
143913b
#291 move perm accs to transaction sender
otselnik Nov 16, 2021
16c9bff
#291 fix state
otselnik Nov 22, 2021
f2c0303
#291 fix errors
otselnik Nov 23, 2021
57f3b53
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 23, 2021
3369f67
#291 merge fixes
otselnik Nov 23, 2021
af721bb
#291 refactoring
otselnik Nov 23, 2021
e512bb8
#291 move EXTRA_GAS to environment
otselnik Nov 23, 2021
8dc5e29
#291 capitalize CONFIRMATION_CHECK_DELAY
otselnik Nov 23, 2021
8dce2a5
#291 sort imports
otselnik Nov 23, 2021
cef8f21
#291 relative paths
otselnik Nov 24, 2021
1bf8383
#291 Should be fixed in #326
otselnik Nov 24, 2021
9672438
#291 testing chnages
otselnik Nov 24, 2021
2d42b73
fix storage account check
sinev-valentine Nov 24, 2021
ac2755c
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 24, 2021
3519c61
Merge branch '371_add_FinalizedStorage_to_check' into 291_proxy_refac…
otselnik Nov 24, 2021
bf313a2
#291 rename `trx_with_create_and_airdrop` -> `make_trx_with_create_an…
otselnik Nov 24, 2021
3093fcc
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 24, 2021
e3c4e33
#295 fix state
otselnik Nov 24, 2021
9b57e53
#291 iterative combined
otselnik Nov 25, 2021
ccffcf4
#295 do not get measurments
otselnik Nov 25, 2021
4d685db
#291 pull request fixes
otselnik Nov 25, 2021
6f63338
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Nov 25, 2021
4546926
Merge branch '291_proxy_refactoring' into 295_iterative_execution
otselnik Nov 25, 2021
7befc6b
#295 turn combined instructions ON
otselnik Nov 29, 2021
b5010f8
#295 make neon_instructions return transasactions
otselnik Nov 29, 2021
5ebf76a
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
otselnik Dec 2, 2021
b464b1e
#291 merge fix
otselnik Dec 2, 2021
79088c6
#295 get rid of `USE_COMBINED_START_CONTINUE`
otselnik Dec 2, 2021
52173a0
Merge branch '291_proxy_refactoring' into 295_iterative_execution
otselnik Dec 2, 2021
4fe15e9
#295 requested fixes
otselnik Dec 2, 2021
607e74e
Merge remote-tracking branch 'origin/develop' into 295_iterative_exec…
otselnik Dec 2, 2021
d9f762a
#295 call_continue_bucked refactoring
otselnik Dec 2, 2021
842ec7d
#295 fix
otselnik Dec 3, 2021
78de121
#295 leave only combined iterative transactions
otselnik Dec 3, 2021
47cf219
#295 move constants into class
otselnik Dec 3, 2021
0eebc1f
#295 refactoring
otselnik Dec 3, 2021
cec7a38
Merge remote-tracking branch 'origin/develop' into 295_iterative_exec…
otselnik Dec 6, 2021
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/develop' into 291_proxy_refactoring
  • Loading branch information
otselnik committed Dec 2, 2021
commit 5ebf76aaac7715a8fb335c889ac237139e1dd1d7
117 changes: 18 additions & 99 deletions proxy/indexer/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
import os
import rlp
import time

import logging
from multiprocessing.dummy import Pool as ThreadPool
from solana.rpc.api import Client
from typing import Dict, Union

from ..environment import SOLANA_URL, EVM_LOADER_ID


try:
Expand Down Expand Up @@ -51,9 +47,13 @@ def __init__(self, eth_trx, eth_signature, from_address, got_result, signatures,
self.slot = slot


class Indexer:
def __init__(self):
self.client = Client(SOLANA_URL)
class Indexer(IndexerBase):
def __init__(self,
solana_url,
evm_loader_id,
log_level = 'INFO'):
IndexerBase.__init__(self, solana_url, evm_loader_id, log_level)

self.canceller = Canceller()
self.logs_db = LogDB()
self.blocks_by_hash = SQLDict(tablename="solana_blocks_by_hash")
Expand All @@ -66,96 +66,15 @@ def __init__(self):
self.blocked_storages = {}


def gather_unknown_transactions(self):
poll_txs = set()
ordered_txs = []

minimal_tx = None
continue_flag = True
current_slot = self.client.get_slot(commitment="confirmed")["result"]
maximum_slot = self.last_slot
minimal_slot = current_slot

percent = 0

counter = 0
while (continue_flag):
opts: Dict[str, Union[int, str]] = {}
if minimal_tx:
opts["before"] = minimal_tx
opts["commitment"] = "confirmed"
result = self.client._provider.make_request("getSignaturesForAddress", EVM_LOADER_ID, opts)
logger.debug("{:>3} get_signatures_for_address {}".format(counter, len(result["result"])))
counter += 1

if len(result["result"]) == 0:
logger.debug("len(result['result']) == 0")
break

for tx in result["result"]:
solana_signature = tx["signature"]
slot = tx["slot"]

if solana_signature in HISTORY_START:
logger.debug(solana_signature)
continue_flag = False
break

ordered_txs.append(solana_signature)

if solana_signature not in self.transaction_receipts:
poll_txs.add(solana_signature)

if slot < minimal_slot:
minimal_slot = slot
minimal_tx = solana_signature

if slot > maximum_slot:
maximum_slot = slot

if slot < self.last_slot:
continue_flag = False
break

logger.debug("start getting receipts")
pool = ThreadPool(PARALLEL_REQUESTS)
pool.map(self.get_tx_receipts, poll_txs)

if len(self.transaction_order):
index = 0
try:
index = ordered_txs.index(self.transaction_order[0])
except ValueError:
self.transaction_order = ordered_txs + self.transaction_order
else:
self.transaction_order = ordered_txs[:index] + self.transaction_order
else:
self.transaction_order = ordered_txs

self.last_slot = maximum_slot
self.current_slot = current_slot

self.counter_ = 0


def get_tx_receipts(self, solana_signature):
# trx = None
retry = True

while retry:
try:
trx = self.client.get_confirmed_transaction(solana_signature)['result']
self.transaction_receipts[solana_signature] = trx
retry = False
except Exception as err:
logger.debug(err)
time.sleep(1)

self.counter_ += 1
if self.counter_ % 100 == 0:
logger.debug(self.counter_)

# return (solana_signature, trx)
def process_functions(self):
IndexerBase.process_functions(self)
logger.debug("Process receipts")
self.process_receipts()
logger.debug("Start getting blocks")
self.gather_blocks()
logger.debug("Unlock accounts")
self.canceller.unlock_accounts(self.blocked_storages)
self.blocked_storages = {}


def process_receipts(self):
Expand Down Expand Up @@ -183,7 +102,7 @@ def process_receipts(self):
if trx['transaction']['message']['instructions'] is not None:
for instruction in trx['transaction']['message']['instructions']:

if trx["transaction"]["message"]["accountKeys"][instruction["programIdIndex"]] != EVM_LOADER_ID:
if trx["transaction"]["message"]["accountKeys"][instruction["programIdIndex"]] != self.evm_loader_id:
continue

if check_error(trx):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.