Skip to content

Commit

Permalink
Push current report fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Nov 1, 2023
1 parent 338c1a7 commit 87907b8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
9 changes: 6 additions & 3 deletions contracts/ethereum/scripts/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ICasimirRegistryAbi from '../build/abi/ICasimirRegistry.json'
import ICasimirUpkeepAbi from '../build/abi/ICasimirUpkeep.json'
import ICasimirViewsAbi from '../build/abi/ICasimirViews.json'
import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env'
import { run } from '@casimir/shell'

void async function() {
process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL['TESTNET']
Expand All @@ -18,10 +19,12 @@ void async function() {
const managerConfig = await factory.getManagerConfig(managerId)
// const manager = new ethers.Contract(managerConfig.managerAddress, ICasimirManagerAbi, provider) as CasimirManager
// const registry = new ethers.Contract(managerConfig.registryAddress, ICasimirRegistryAbi, provider) as CasimirRegistry
// const upkeep = new ethers.Contract(managerConfig.upkeepAddress, ICasimirUpkeepAbi, provider) as CasimirUpkeep
const upkeep = new ethers.Contract(managerConfig.upkeepAddress, ICasimirUpkeepAbi, provider) as CasimirUpkeep
const performUpkeep = await upkeep.connect(owner).performUpkeep('0x')
await performUpkeep.wait()
// const views = new ethers.Contract(managerConfig.viewsAddress, ICasimirViewsAbi, provider) as CasimirViews
// // const resetReport = await upkeep.connect(owner).resetReport(0, 0, 0, 0, 0)
// // await resetReport.wait()
// console.log(await views.getDepositedPoolStatuses(0, 2))
// const requestReport = await upkeep.connect(owner).requestReport()
// await requestReport.wait()
// run('npm run dev --workspace @casimir/functions')
}()
15 changes: 9 additions & 6 deletions services/functions/API-request-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ async function detailsHandler() {
}
const validators = await getValidators(depositedPoolPublicKeys)

const activatedDeposits = validators.reduce((accumulator, { validator }) => {
const { activation_epoch } = validator
const activatedDuringReportPeriod = activation_epoch > previousReportEpoch && activation_epoch <= reportEpoch
if (activatedDuringReportPeriod) {
const activatedDeposits = validators.reduce((accumulator, { status }, index) => {
const activationNeeded = depositedPoolStatuses[index] === 1 && status.includes('active')
if (activationNeeded) {
accumulator += 1
}
return accumulator
Expand Down Expand Up @@ -191,7 +190,10 @@ async function getDepositedPoolPublicKeys(startIndex, endIndex) {
let publicKey = '0x' + rawPublicKeys.slice(publicKeyStart, publicKeyEnd)
publicKeys.push(publicKey)
}
return publicKeys
return [
'0x853b4caf348bccddbf7e1c25e68676c3b3f857958c93b290a2bf84974ea33c4f793f1bbf7e9e9923f16e2237038e7b69',
'0x8889a628f263c414e256a1295c3f49ac1780e0b9cac8493dd1bd2f17b3b257660a12fb88f65333fa00c9a735c0f8d0e8'
]
}

async function getDepositedPoolStatuses(startIndex, endIndex) {
Expand All @@ -212,6 +214,7 @@ async function getDepositedPoolStatuses(startIndex, endIndex) {
}
})
if (request.error) throw new Error('Failed to get validator statuses')
console.log("Raw statuses", request.data.result)
const rawStatuses = request.data.result.slice(2)
const statuses = []
for (let i = 0; i < 5; i++) {
Expand All @@ -220,7 +223,7 @@ async function getDepositedPoolStatuses(startIndex, endIndex) {
let status = parseInt(rawStatuses.slice(start, end), 16)
statuses.push(status)
}
return statuses
return [1, 2]
}

async function getSweptBalance(startIndex, endIndex) {
Expand Down
28 changes: 14 additions & 14 deletions services/functions/src/providers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ export async function fulfillRequestHandler(input: HandlerInput): Promise<void>
if (success) {
const signer = config.wallet.connect(provider)
const dummySigners = Array(31).fill(signer.address)
const fulfillAndBill = await functionsBillingRegistry.connect(signer).fulfillAndBill(
requestId,
result,
'0x',
signer.address,
dummySigners,
4,
100_000,
500_000,
{
gasLimit: 500_000,
}
)
await fulfillAndBill.wait()
// const fulfillAndBill = await functionsBillingRegistry.connect(signer).fulfillAndBill(
// requestId,
// result,
// '0x',
// signer.address,
// dummySigners,
// 4,
// 100_000,
// 500_000,
// {
// gasLimit: 500_000,
// }
// )
// await fulfillAndBill.wait()
if (process.env.USE_LOGS === 'true') {
updateExecutionLog('execution.log', resultLog)
}
Expand Down

0 comments on commit 87907b8

Please sign in to comment.