Skip to content

Commit

Permalink
fix for erigon nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
F4ever committed Sep 20, 2024
1 parent acacbb9 commit c095709
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion src/providers/execution/contracts/lido.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,54 @@ def handle_oracle_report(
while passing empty `_withdrawalFinalizationBatches` and `_simulatedShareRate` == 0, plugging the returned values
to the following formula: `_simulatedShareRate = (postTotalPooledEther * 1e27) / postTotalShares`
"""
try:
return self._handle_oracle_report(
timestamp,
time_elapsed,
validators_count,
cl_balance,
withdrawal_vault_balance,
el_rewards,
shares_to_burn,
accounting_oracle_address,
HexStr('0x' + ref_slot.to_bytes(32).hex()),
block_identifier,
)
except ValueError as error:
# {'code': -32602, 'message': 'invalid argument 2: hex number with leading zero digits'}
logger.info({
'msg': 'Expected behaviour for Erigon nodes. Try another request format.',
'error': repr(error),
})
return self._handle_oracle_report(
timestamp,
time_elapsed,
validators_count,
cl_balance,
withdrawal_vault_balance,
el_rewards,
shares_to_burn,
accounting_oracle_address,
HexStr(hex(ref_slot)),
block_identifier,
)

def _handle_oracle_report(
self,
timestamp: int,
time_elapsed: int,
validators_count: int,
cl_balance: Wei,
withdrawal_vault_balance: Wei,
el_rewards: Wei,
shares_to_burn: int,
accounting_oracle_address: ChecksumAddress,
ref_slot: HexStr,
block_identifier: BlockIdentifier = 'latest',
) -> LidoReportRebase:
"""
Erigon should recieve ref_slot
"""
state_override: dict[ChecksumAddress, CallOverrideParams] = {
accounting_oracle_address: {
# Fix: insufficient funds for gas * price + value
Expand All @@ -45,7 +93,7 @@ def handle_oracle_report(
# properly process negative rebase sanity checks. Since current simulation skips call to AO,
# setting up `lastProcessingRefSlot` directly.
'stateDiff': {
HexStr(self.w3.keccak(text="lido.BaseOracle.lastProcessingRefSlot").hex()): HexStr('0x' + ref_slot.to_bytes(32).hex()),
HexStr(self.w3.keccak(text="lido.BaseOracle.lastProcessingRefSlot").hex()): ref_slot,
},
},
}
Expand Down

0 comments on commit c095709

Please sign in to comment.