-
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
Conversation
contracts/src/integration-test.ts
Outdated
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.
@45930 what do you think about moving all test files to test folder and classification of interaction scripts and tests.
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.
There is already src/test/
, which you can use for this.
I prefer test/
at the top level, but for simplicity in the build, I moved it into src/
. I don't mind if you move it, as long as the tests keep passing!
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.
Did you test this case as part of the stress test?
- Deploy contract
- Emit 100 actions
- Exit terminal
- Reconnect and sync actions from the existing contract
const name = Name.fromString(stringName); | ||
const nr = new NameRecord({ | ||
mina_address: addresses.user1, | ||
avatar: Field(0), | ||
url: Name.fromString(stringUrl).packed, | ||
url: Field(0), |
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 is a regression because previously we tested an actual value was set, but now we are setting the same as the default value. We should at least use Field(1)
. Is there a reason not to leave it as it was?
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.
yes, that's a mistake. I changed the key type of the mapping to Name from Field. It seems I accidentally defaulted urls to Field(0)
while removing .packed
s from Names. I reverted this change in the latest commit.
Maybe we should also test this case, since there is someone asking about it: https://discord.com/channels/484437221055922177/1287933364007079967 Can we have 2 |
It may not be relevant to this project. It would be easier to test this in a simpler zkapp. |
no, but it tries to resolve a random name at the end of the cycles. |
I think we need to be absolutely sure this works at least. Handling multiple instances of the same contract is not a requirement, but we can't accidentally brick the contract if our js terminal disconnects. I believe it should work if we reconnect and re-sync the actions, but that should be tested as well. |
contracts/src/stress-test.ts
Outdated
console.timeEnd('compile contract'); | ||
|
||
console.time('deploy'); | ||
tx = await Mina.transaction({ sender: feepayerAddress, fee: fee }, async () => { |
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.
Since we always redeploy, this transaction gives an invalid fee excess after it's been run once. Can we skip this transaction if the contract is already deployed?
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.
Ideally, we should run the test with a fresh zkApp account. So, I don't think it should continue to run if the zkapp is already deployed. However, reading it from a file is unnecessary and actually cumbersome, so I changed that part to generate the zkApp key randomly
contracts/src/stress-test.ts
Outdated
console.timeEnd('set premimum rate'); | ||
|
||
console.time('settlement proof 1'); | ||
let proof = await offchainState.createSettlementProof(); |
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.
When I run this, my code hangs on this line. Here is my contract address:
https://minascan.io/devnet/account/B62qrxnym3P7ixgZPLeJixyX6fgruV9UhEGFF9ViPUHZbDErozZYBuW/txs?type=zk-acc
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.
Ah, I fixed this by updating my dependencies, see my other comment in package json.
@@ -26,6 +26,7 @@ | |||
"devDependencies": { | |||
"@babel/preset-env": "^7.16.4", | |||
"@babel/preset-typescript": "^7.16.0", | |||
"@types/node": "^22.5.5", |
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.
tx = await Mina.transaction( | ||
{ sender: feepayerAddress, fee: fee }, | ||
async () => { | ||
let res = await name_service_contract.resolve_name( |
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.
My script failed here since the name was not owned. I think the problem is wait(8); // wait for settlement
. This only waits for 8 seconds, which doesn't seem like long enough.
I think the wait function should be upgraded to watch the transaction we created, and only proceed when the transaction is applied. No matter how long we wait, the network may not yet have applied the transaction.
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.
yeah, wait function is incorrect. I probably missed that because the random case would have been in the set of settled ones.
Watching the settlement transaction would be the best but I don't think we can do that in o1js.
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.
Nice work getting this cleaned up Boray!
Summary
This PR adds interaction scripts that test the zkApp's behavior on Devnet.
contracts/src/devnet-interaction.ts
: Interacts with the zkApp on Devnet in the same way asinteract.ts
.contracts/src/stress-test.ts
: Tests whether a large number of actions can be settled on Devnet.contracts/src/integration-test.ts
: Interacts with the zkApp on Devnet but waits for the settlement module to settle.