Skip to content

Commit

Permalink
backfill transaction history
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandpo committed Aug 31, 2023
1 parent f687ac2 commit 0519f26
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions eagleproject/core/blockchain/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@
START_OF_OUSD_V2 = 11596940
START_OF_OUSD_V2_TIME = datetime.strptime("29-12-2020", "%d-%m-%Y")
START_OF_OUSD_TOTAL_SUPPLY_UPDATED_HIGHRES=13534392
START_OF_WOUSD = 14566204
OUSD_TOTAL_SUPPLY_UPDATED_TOPIC="0x99e56f783b536ffacf422d59183ea321dd80dcd6d23daa13023e8afea38c3df1"
OUSD_TOTAL_SUPPLY_UPDATED_HIGHRES_TOPIC="0x41645eb819d3011b13f97696a8109d14bfcddfaca7d063ec0564d62a3e257235"

START_OF_OETH = 17067000
START_OF_WOETH = 16950116

VAULT_FEE_UPGRADE_BLOCK = 17187589

Expand Down
28 changes: 26 additions & 2 deletions eagleproject/core/blockchain/harvest/transaction_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

from django.db.models import Q
from core.blockchain.harvest.transactions import (
explode_log_data
explode_log_data,
backfill_transaction_history,
)
from core.blockchain.harvest.snapshots import (
build_asset_block
Expand All @@ -39,7 +40,8 @@
totalSupply,
dripper_available,
OUSDMetaStrategy,
OETHCurveAMOStrategy
OETHCurveAMOStrategy,
latest_block,
)
from core.blockchain.apy import (
get_trailing_apy,
Expand All @@ -56,6 +58,8 @@
START_OF_CURVE_CAMPAIGN_TIME,
START_OF_OUSD_V2,
START_OF_OETH,
START_OF_WOUSD,
START_OF_WOETH,
BLOCKS_PER_DAY,
OUSD_TOTAL_SUPPLY_UPDATED_TOPIC,
OUSD_TOTAL_SUPPLY_UPDATED_HIGHRES_TOPIC,
Expand Down Expand Up @@ -744,6 +748,26 @@ def backfill_subscribers():
sub.save()


def backfill_transactions(project=OriginTokens.OUSD):
if project == OriginTokens.OUSD:
start_block = START_OF_OUSD_V2
contract = OUSD
elif project == OriginTokens.OETH:
start_block = START_OF_OETH
contract = OETH
elif project == OriginTokens.WOUSD:
start_block = START_OF_WOUSD
contract = WOUSD
elif project == OriginTokens.WOETH:
start_block = START_OF_WOETH
contract = WOETH
else:
raise Exception('Unexpected project id', project)

end_block = latest_block()
backfill_transaction_history(contract, start_block, end_block)


# get all accounts that at some point held OUSD
def fetch_all_holders(project=OriginTokens.OUSD):
to_addresses = list(map(lambda log: log['to_address'], TokenTransfer.objects.filter(project=project).values('to_address').distinct()))
Expand Down
4 changes: 4 additions & 0 deletions eagleproject/core/blockchain/harvest/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ def download_logs_from_contract(contract, start_block, end_block):
ensure_transaction_and_downsteam_hashes(list(tx_hashes))


def backfill_transaction_history(contract, start_block, end_block):
download_logs_from_contract(contract, start_block, end_block)


def ensure_latest_logs(upto):
pointers = {x.contract: x for x in LogPointer.objects.all()}
# Keep in mind that GAE isn't best suited for parallelism. And if we were to go for it
Expand Down
2 changes: 1 addition & 1 deletion eagleproject/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
calculate_report_change,
send_report_email,
get_history_for_address,
_daily_rows
_daily_rows,
)

from core.blockchain.rpc import (
Expand Down
5 changes: 5 additions & 0 deletions eagleproject/scripts/backfill_transactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from core.blockchain.harvest.transaction_history import backfill_transactions

def run(*script_args):
project = script_args[0] if len(script_args) > 0 else None
backfill_transactions(project)

0 comments on commit 0519f26

Please sign in to comment.