-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add devnet and stress test #5
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a73b04b
Merge remote-tracking branch 'origin/main' into devnet-test
boray 8712c29
feat: add devnet and stress test
boray 744e8b3
test: fix name service test
boray d2e344c
test: update provable test
boray d7a70df
test: add integration test
boray cf9a3ec
fix: add explicit types
boray eee24a7
test: revert url type change
boray 59fef4c
test: add scripts
boray fbe1e75
chore: reorganize
boray 47cfa28
fix: settlement module
boray 7908f75
fix: integration and stress test
boray 3035bbe
fix: get_name.ts
boray 4be40f2
try to fix CI + lock o1js version
df6afed
try to fix CI
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
{ | ||
"version": 1, | ||
"deployAliases": { | ||
"devnet": { | ||
"networkId": "testnet", | ||
"url": "https://api.minascan.io/node/devnet/v1/graphql", | ||
"keyPath": "keys/devnet.json", | ||
"feepayerKeyPath": "/Users/boraysaygilier/.cache/zkapp-cli/keys/berkkey.json", | ||
"feepayerAlias": "berkkey", | ||
"fee": "0.1", | ||
"smartContract": "NameService" | ||
} | ||
} | ||
"deployAliases": {} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import fs from 'fs/promises'; | ||
import { | ||
AccountUpdate, | ||
Field, | ||
Mina, | ||
PrivateKey, | ||
UInt64, | ||
NetworkId, | ||
} from 'o1js'; | ||
import { | ||
NameService, | ||
NameRecord, | ||
offchainState, | ||
Name, | ||
} from '../../NameService.js'; | ||
|
||
// check command line arg | ||
let deployAlias = process.argv[2]; | ||
if (!deployAlias) throw Error(`Missing <deployAlias> argument`); | ||
Error.stackTraceLimit = 1000; | ||
const DEFAULT_NETWORK_ID = 'testnet'; | ||
|
||
// parse config and private key from file | ||
type Config = { | ||
deployAliases: Record< | ||
string, | ||
{ | ||
networkId?: string; | ||
url: string; | ||
keyPath: string; | ||
fee: string; | ||
feepayerKeyPath: string; | ||
feepayerAlias: string; | ||
} | ||
>; | ||
}; | ||
let configJson: Config = JSON.parse(await fs.readFile('config.json', 'utf8')); | ||
let config = configJson.deployAliases[deployAlias]; | ||
let feepayerKeysBase58: { privateKey: string; publicKey: string } = JSON.parse( | ||
await fs.readFile(config.feepayerKeyPath, 'utf8') | ||
); | ||
let zkAppKeysBase58: { privateKey: string; publicKey: string } = JSON.parse( | ||
await fs.readFile(config.keyPath, 'utf8') | ||
); | ||
|
||
let feepayerKey = PrivateKey.fromBase58(feepayerKeysBase58.privateKey); | ||
let zkAppKey = PrivateKey.fromBase58(zkAppKeysBase58.privateKey); | ||
|
||
const Network = Mina.Network({ | ||
archive: 'https://api.minascan.io/archive/devnet/v1/graphql', | ||
networkId: (config.networkId ?? DEFAULT_NETWORK_ID) as NetworkId, | ||
mina: config.url, | ||
}); | ||
|
||
const fee = Number(config.fee) * 1e9; // in nanomina (1 billion = 1.0 mina) | ||
Mina.setActiveInstance(Network); | ||
let tx; | ||
let feepayerAddress = feepayerKey.toPublicKey(); | ||
let zkAppAddress = zkAppKey.toPublicKey(); | ||
let name_service_contract = new NameService(zkAppAddress); | ||
|
||
console.time('compile program'); | ||
await offchainState.compile(); | ||
offchainState.setContractInstance(name_service_contract); | ||
console.timeEnd('compile program'); | ||
console.time('compile contract'); | ||
await NameService.compile(); | ||
console.timeEnd('compile contract'); | ||
|
||
console.time('deploy'); | ||
tx = await Mina.transaction({ sender: feepayerAddress, fee: fee }, async () => { | ||
AccountUpdate.fundNewAccount(feepayerAddress); | ||
await name_service_contract.deploy(); | ||
}) | ||
.prove() | ||
.sign([feepayerKey, zkAppKey]) | ||
.send() | ||
.wait(); | ||
console.log(tx.toPretty()); | ||
console.timeEnd('deploy'); | ||
|
||
console.time('set premimum rate'); | ||
tx = await Mina.transaction({ sender: feepayerAddress, fee: fee }, async () => { | ||
await name_service_contract.set_premium(UInt64.from(100)); | ||
}) | ||
.sign([feepayerKey]) | ||
.prove() | ||
.send() | ||
.wait(); | ||
console.log(tx.toPretty()); | ||
console.timeEnd('set premimum rate'); | ||
|
||
console.time('settlement proof'); | ||
let proof = await offchainState.createSettlementProof(); | ||
console.timeEnd('settlement proof'); | ||
|
||
console.time('settle'); | ||
tx = await Mina.transaction({ sender: feepayerAddress, fee: fee }, async () => | ||
name_service_contract.settle(proof) | ||
) | ||
.sign([feepayerKey]) | ||
.prove() | ||
.send() | ||
.wait(); | ||
console.log(tx.toPretty()); | ||
console.timeEnd('settle'); | ||
|
||
console.time('get premimum rate'); | ||
let res; | ||
tx = await Mina.transaction({ sender: feepayerAddress, fee: fee }, async () => { | ||
res = await name_service_contract.premium_rate(); | ||
}) | ||
.sign([feepayerKey]) | ||
.prove() | ||
.send() | ||
.wait(); | ||
console.log(tx.toPretty()); | ||
console.log(res!.toString()); | ||
console.timeEnd('get premimum rate'); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file does not reference o1js directly! We are getting o1js via o1js-pack....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After fixing this locally, my script continues running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it while debugging the wasm TypeError. After adding it back, it works fine on my end as well. I’ll add it in the next commit.