foundry
foundry copied to clipboard
feat(`forge-script`): add `--confirmations` flag to wait for `n` confirmations
Component
Forge
Describe the feature you would like
Right now, the forge script verifier gets a little confused if it doesn't find any bytecode, and just exists. An easy solution I use with Brownie, Hardhat, Truffle, and Ape is to just wait X confirmations before attempting a verification.
Having a flag to wait x confirmations would be great.
forge script script/MyScript.sol --wait-confirmations 6
And this will result in:
##
Waiting for receipts.
⠉ [00:00:12] [######################################################################################################################################################################################] 6/6 receipts (0.0s)
Additional context
No response
@PatrickAlphaC I think you were planning to work on this so I assigned it to you, if that changes lmk and I can unassign
Seems it might take me a lot longer than I thought it would 😅
sorry... could we unassign?
Hey @zerosnacks, is this still relevant? if so I'd like to work on it.
Hi @caiquejjx, sorry for my rate reply. This ticket is still relevant and we would love to get it in. Assigned to you :)
thank you @zerosnacks, just to be sure I understood this task, what we want is that if the --verify flag is passed along the --confirmations one we should wait for x confirmations and the logic for what it concerns the wait part should be done somewhere inside this function https://github.com/foundry-rs/foundry/blob/15fdb2a19ee2a038f7e72523c6a0b0c3cdc6c3e4/crates/script/src/sequence.rs#L256
thank you @zerosnacks, just to be sure I understood this task, what we want is that if the
--verifyflag is passed along the--confirmationsone we should wait for x confirmations and the logic for what it concerns the wait part should be done somewhere inside this function https://github.com/foundry-rs/foundry/blob/15fdb2a19ee2a038f7e72523c6a0b0c3cdc6c3e4/crates/script/src/sequence.rs#L256
--confirmations should specify how many blocks we should wait before proceeding (with the verification step). In that sense it is more generalized.
This is useful if the chain experiences re-orgs or the transaction is not included in the next block.
Thanks @zerosnacks I can understand the concept but I don't completely get the implementation part, what I understand is:
- We can count the amount of blocks by counting the
receiptsinside the sequence object, as per what I understood each receipt is a block confirmation - If the script has more than one contract we should wait the confirmations for each contract
- If the
--confirmationsflag is specified it should be automatically infered thatargs.verifyis true
Can you confirm or correct me? Sorry for the noobie questions, I'm still starting to learn blockchain dev and the foundry project itself, thanks for your patience
We can count the amount of blocks by counting the receipts inside the sequence object, as per what I understood each receipt is a block confirmation
We should implement it here:
https://github.com/foundry-rs/foundry/blob/0ed43cefa9c9cb93fa9f9b18ff73d04c1a07cf56/crates/script/src/broadcast.rs#L196-L197
https://github.com/foundry-rs/foundry/blob/0ed43cefa9c9cb93fa9f9b18ff73d04c1a07cf56/crates/script/src/broadcast.rs#L163
https://github.com/foundry-rs/foundry/blob/0ed43cefa9c9cb93fa9f9b18ff73d04c1a07cf56/crates/script/src/progress.rs#L169
If the script has more than one contract we should wait the confirmations for each contract
This is correct, the --confirmations flag applies to each contract deployment. We should start the verification process once all deployed contracts have been included in blocks > confirmations count.
If the --confirmations flag is specified it should be automatically infered that args.verify is true
No, the --confirmations flag should not infer verification, it is also a useful flag in other contexts (like re-orgs)
It is needed
Hi @caiquejjx are you running into any blockers or do you have any questions?
Hey, sorry I just got back from vacation and wasn't able to get it working before going away. I was having a bit of a hard time with it but I still would like to push it a little more if that's ok, but also if someone more experienced wants to take this to speed things up it's fine for me, i'm mostly here for the learning and doing what's best for the project.
@caiquejjx not a problem! Let me know how you get on, hopping on another ticket is also fine - this one is more complex than it seems on the surface
thanks @zerosnacks, I'll take a bit more time then and if it's really a no go I'll let you know
@zerosnacks I have unassigned me, I still didn't had time to look into it again but I'm also not hopeful I'll be able to solve it, guess it's above my current knowledge 😅