Skip to content

Commit

Permalink
Merge pull request #377 from trifle-labs/just-reduce-times
Browse files Browse the repository at this point in the history
Just reduce times
  • Loading branch information
okwme authored Nov 25, 2024
2 parents 659edcf + d9729ae commit 3446b45
Show file tree
Hide file tree
Showing 24 changed files with 3,742 additions and 26 deletions.
1,024 changes: 1,024 additions & 0 deletions contracts/AnybodyProblemV3.sol

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions contracts/AnybodyProblemV3Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import './AnybodyProblemV3.sol';

contract AnybodyProblemV3Mock is AnybodyProblemV3 {
bool public foo = true;

constructor(
address payable proceedRecipient_,
address payable speedruns_,
address externalMetadata_,
address payable tournament_,
address[] memory verifiers_,
uint256[] memory verifiersTicks,
uint256[] memory verifiersBodies,
address payable previousAB_
)
AnybodyProblemV3(
proceedRecipient_,
speedruns_,
externalMetadata_,
tournament_,
verifiers_,
verifiersTicks,
verifiersBodies,
previousAB_
)
{}

Body[6][5] public mockedBodyDataByLevel;

function setRunData(
uint256 runId,
uint256 day,
uint256 accumulativeTime,
address owner
) public {
if (runs_[runId].day == 0) {
counterForOrdering++;
}
runs_[runId].day = day;
runs_[runId].accumulativeTime = accumulativeTime;
runs_[runId].owner = owner;
}

function setMockedBodyDataByLevel(
uint256 level,
Body[6] memory bodyData
) public {
mockedBodyDataByLevel[level - 1] = bodyData;
}

function generateLevelData(
uint256 day,
uint256 level
)
public
view
override(AnybodyProblemV3)
returns (AnybodyProblemV3.Body[6] memory bodyData, uint256 bodyCount)
{
if (mockedBodyDataByLevel[level - 1][0].seed == bytes32(0)) {
return super.generateLevelData(day, level);
}
return (mockedBodyDataByLevel[level - 1], level + 1);
}
}
4 changes: 2 additions & 2 deletions dist/index.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions scripts/deployAnybodyProblemV3.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
async function main() {
const { deployAnybodyProblemV3, saveAndVerifyContracts } = await import(
'./utils.js'
)
const deployedContracts = await deployAnybodyProblemV3({
ignoreTesting: true
})
await saveAndVerifyContracts(deployedContracts)
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})
167 changes: 165 additions & 2 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,166 @@ const deployAnybodyProblemV2 = async (options) => {
}
]
returnObject['verificationData'] = verificationData
if (returnObject['AnybodyProblemV2']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV2']
} else if (returnObject['AnybodyProblemV1']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV1']
} else if (returnObject['AnybodyProblemV0']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV0']
}
return returnObject
}

const deployAnybodyProblemV3 = async (options) => {
const defaultOptions = {
mock: false,
ignoreTesting: false,
skipVerifiers: false,
verbose: false,
AnybodyProblemV1: null,
AnybodyProblemV2: null,
Speedruns: null,
ExternalMetadata: null
}
let {
mock,
ignoreTesting,
skipVerifiers,
verbose,
AnybodyProblemV0,
AnybodyProblemV1,
AnybodyProblemV2,
Speedruns,
ExternalMetadata
} = Object.assign(defaultOptions, options)
global.ignoreTesting = ignoreTesting
global.networkinfo = await hre.ethers.provider.getNetwork()
global.verbose = verbose
log('Deploying v3 contracts')

const [deployer] = await hre.ethers.getSigners()

// use the already deployed speedruns contract and external metadata contract
const deployedContracts = await initContracts([
'AnybodyProblemV0',
'AnybodyProblemV1',
'AnybodyProblemV2',
'Speedruns',
'ExternalMetadata'
])

const { verifiers, verifiersTicks, verifiersBodies, returnObject } =
await deployVerifiers({
skipVerifiers,
deployedContracts,
ignoreTesting,
verbose
})

if (!AnybodyProblemV0) AnybodyProblemV0 = deployedContracts.AnybodyProblemV0
returnObject['AnybodyProblemV0'] = AnybodyProblemV0

if (!Speedruns) Speedruns = deployedContracts.Speedruns
returnObject['Speedruns'] = Speedruns

if (!ExternalMetadata) ExternalMetadata = deployedContracts.ExternalMetadata
returnObject['ExternalMetadata'] = ExternalMetadata

if (!AnybodyProblemV1) AnybodyProblemV1 = deployedContracts.AnybodyProblemV1
returnObject['AnybodyProblemV1'] = AnybodyProblemV1

if (!AnybodyProblemV2) AnybodyProblemV2 = deployedContracts.AnybodyProblemV2
returnObject['AnybodyProblemV2'] = AnybodyProblemV2

const HitchensOrderStatisticsTreeLib = await hre.ethers.getContractFactory(
'HitchensOrderStatisticsTreeLib'
)
const hitchensOrderStatisticsTreeLib =
await HitchensOrderStatisticsTreeLib.deploy()
returnObject['HitchensOrderStatisticsTreeLib'] =
hitchensOrderStatisticsTreeLib

const Tournament = await hre.ethers.getContractFactory('Tournament', {
// TODO: why did i need to do this at one point and not now?
// libraries: {
// HitchensOrderStatisticsTreeLib: hitchensOrderStatisticsTreeLib.address
// }
})
const tournament = await Tournament.deploy()
log('Tournament Deployed at ' + String(tournament.address))
returnObject['Tournament'] = tournament

log(mock ? 'Deploying AnybodyProblemV3Mock' : 'Deploying AnybodyProblemV3')
// deploy AnybodyProblem
const AnybodyProblemV3 = await hre.ethers.getContractFactory(
mock ? 'AnybodyProblemV3Mock' : 'AnybodyProblemV3'
)

const constructorArguments = [
deployer.address,
Speedruns.address,
ExternalMetadata.address,
tournament.address,
verifiers,
verifiersTicks,
verifiersBodies,
AnybodyProblemV2.address
]

const anybodyProblemV3 = await AnybodyProblemV3.deploy(
...constructorArguments
)
await anybodyProblemV3.deployed()

returnObject['AnybodyProblemV3'] = anybodyProblemV3

log(
'AnybodyProblemV3 Deployed at ' +
String(anybodyProblemV3.address) +
` with speedrunsAddress ${Speedruns.address} and externalMetdataAddress ${ExternalMetadata.address} and tournamentAddress ${tournament.address} and verifiers ${verifiers} and verifiersTicks ${verifiersTicks} and verifiersBodies ${verifiersBodies} and anybodyProblemV2Address ${AnybodyProblemV2.address}`
)

// update AnybodyProblemV2 with proceedRecipient
await anybodyProblemV3.updateProceedRecipient(proceedRecipient)
log(`AnybodyProblemV3 ProceedRecipient updated to ${proceedRecipient}`)

// update Speedruns
await Speedruns.updateAnybodyProblemAddress(anybodyProblemV3.address)
log(
`AnybodyProblemV3 address updated in Speedruns to ${anybodyProblemV3.address}`
)

// update ExternalMetadata
await ExternalMetadata.updateAnybodyProblemAddress(anybodyProblemV3.address)
log(
`AnybodyProblemV3 address updated in ExternalMetadata to ${anybodyProblemV3.address}`
)

// update Tournament
await tournament.updateAnybodyProblemAddress(anybodyProblemV3.address)
log(
`AnybodyProblemV3 address updated in Tournament to ${anybodyProblemV3.address}`
)

const verificationData = [
{
name: 'AnybodyProblemV3',
constructorArguments
},
{
name: 'Tournament',
constructorArguments: []
}
]
returnObject['verificationData'] = verificationData
if (returnObject['AnybodyProblemV3']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV3']
} else if (returnObject['AnybodyProblemV2']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV2']
} else if (returnObject['AnybodyProblemV1']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV1']
} else if (returnObject['AnybodyProblemV0']) {
returnObject['AnybodyProblem'] = returnObject['AnybodyProblemV0']
}
return returnObject
}
Expand Down Expand Up @@ -606,12 +760,20 @@ const deployContracts = async (options) => {
if (options?.saveAndVerify) {
await saveAndVerifyContracts(deployedContracts2)
}
const deployedContracts3 = await deployAnybodyProblemV3({
...options,
...deployedContracts2
})
if (options?.saveAndVerify) {
await saveAndVerifyContracts(deployedContracts3)
}
const returnValue = {
...deployedContracts0,
...deployedContracts1,
...deployedContracts2
...deployedContracts2,
...deployedContracts3
}
returnValue.AnybodyProblem = returnValue.AnybodyProblemV2
returnValue.AnybodyProblem = returnValue.AnybodyProblemV3
return returnValue
}

Expand Down Expand Up @@ -1292,6 +1454,7 @@ export {
getThemeName,
deployAnybodyProblemV1,
deployAnybodyProblemV2,
deployAnybodyProblemV3,
saveAndVerifyContracts,
proceedRecipient,
deployVerifiers
Expand Down
4 changes: 4 additions & 0 deletions server/contractData/8453-AnybodyProblemV3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"address": "0x0b62e06a8da04A42393960E240025319544BB168",
"chain": { "chainId": 8453, "name": "unknown" }
}
2 changes: 1 addition & 1 deletion server/contractData/8453-Game_4_250Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0xEbbB276C1006f23B1A5878a5c76ad3d72B8A002A",
"address": "0x7099E994d3Bf7fdc612EEDc1d1e3926084e7671d",
"chain": { "chainId": 8453, "name": "unknown" }
}
2 changes: 1 addition & 1 deletion server/contractData/8453-Game_6_250Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x6cc4950960b040FcDd22126E39554b5fA4F703ec",
"address": "0xA1D33c2Ab764AB4eCcD7a3988be8dD009fdE06a7",
"chain": { "chainId": 8453, "name": "unknown" }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0xF65797567fF1Fef98b46eF09FdF9eCA1d3B8a17b",
"address": "0xbaD98B68D31Dc45Df1C3C3Bcd7b29aCe2B1d80cA",
"chain": { "chainId": 8453, "name": "unknown" }
}
2 changes: 1 addition & 1 deletion server/contractData/8453-Tournament.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x00a12198B91A7405503529DDD62ad1B34CE6b5d3",
"address": "0x067fa869c9f10B895a2dC038E80970F5030c8017",
"chain": { "chainId": 8453, "name": "unknown" }
}
4 changes: 4 additions & 0 deletions server/contractData/84532-AnybodyProblemV3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"address": "0x75C39Ff24DCFEd0FEEbafd434a40Ec9dc615ebEf",
"chain": { "chainId": 84532, "name": "unknown" }
}
2 changes: 1 addition & 1 deletion server/contractData/84532-Game_4_250Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x7592abb3D48F083C1a2F4922DECF3Ec9D760c599",
"address": "0x936134737c30187AbA50a2B2893Be55B2EEBbF45",
"chain": { "chainId": 84532, "name": "unknown" }
}
2 changes: 1 addition & 1 deletion server/contractData/84532-Game_6_250Verifier.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x2f17a2Dd686c843A1B298E853aaD0220A2ea7Fe6",
"address": "0x375b74Eef30255689B56C213De1C70484c8261B9",
"chain": { "chainId": 84532, "name": "unknown" }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0xf45a48f0B99D66723b5C5e12306218110a313140",
"address": "0x50b9a3ba35C51D25BaBe6f2739aC5df2b41C6994",
"chain": { "chainId": 84532, "name": "unknown" }
}
2 changes: 1 addition & 1 deletion server/contractData/84532-Tournament.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"address": "0x7F6A32C0EC2C3BC02144a184349AFBed88189CFE",
"address": "0xa035D398d4Cfac0a53e3A8A8E8d1d387efeED28E",
"chain": { "chainId": 84532, "name": "unknown" }
}
Loading

0 comments on commit 3446b45

Please sign in to comment.