Skip to content

Scheduled callbacks #823

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

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

devbugging
Copy link
Contributor

@devbugging devbugging commented May 22, 2025

Description

This is scheduled callback implementation on emulator.

It's experimental feature and contains unsafe implementation of callback scheduler contract, which simplifies the scheduling logic (and doesn't match how it will be on the mainnet). This is intended for early access only. The APIs should stay the same and behaviour of the APIs should stay similar (but there's no guarantee).

Contract is also added directly into project as well as transactions which will be refactored once this becomes part of core-contracts.


For contributor use:

  • Targeted PR against master branch
  • Linked to GitHub issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the GitHub PR explorer
  • Added appropriate labels

@devbugging devbugging marked this pull request as ready for review May 23, 2025 17:55
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2025

Codecov Report

❌ Patch coverage is 20.10870% with 147 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/blockchain.go 0.00% 49 Missing and 1 partial ⚠️
emulator/callbacks.go 43.42% 40 Missing and 3 partials ⚠️
cmd/emulator/start/start.go 0.00% 34 Missing ⚠️
server/server.go 16.66% 18 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@devbugging devbugging requested a review from chasefleming June 6, 2025 14:46
@devbugging
Copy link
Contributor Author

@chasefleming added changes.

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Co-authored-by: Bastian Müller <[email protected]>
@devbugging devbugging requested review from turbolent and jribbink July 17, 2025 09:16
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

return 0, nil, fmt.Errorf("invalid event type, got: %s, expected: %s", event.Type, callbackScheduledEvent)
}

id, ok := event.Value.SearchFieldByName(IDField).(cadence.UInt64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Instead of searching linearly for two fields, maybe use FieldsMappedByName instead and look up the fields in the result

@chasefleming
Copy link
Member

From another chat, it sounds like we need to upgrade the contract to the latest version.

@joshuahannan
Copy link
Member

I just pushed changes to update to the latest version of the contract and updated the tests as well. There will be future versions of the contract with significant changes, but this at least contains the basic functionality.

@devbugging
Copy link
Contributor Author

@joshuahannan I'm not sure updating to real contract is a good idea here. This was supposed to be an early experimental verison of this feature not a production one. Since that contract is not yet done and tested we don't know how it will work with this integration, whereas this test contract I made I've tested it and it works. Unless you can do (for now manual) testing with the emulator to confirm it really works I wouldn't do this as part of this PR.
cc @chasefleming @nialexsan

@joshuahannan
Copy link
Member

@devbugging Can you elaborate more on why you think it might be an issue? The current version of the contract has all the most important functionality and the same API as the old one and has a decent number of unit tests already. I'm not sure why we'd want to use one that doesn't have full functionality. Maybe it isn't clear to me what the differences are that you're talking about

@devbugging
Copy link
Contributor Author

@joshuahannan the only reason is because I'm sure the current version works as it should to use it. If you can make sure this updated contract also works as it should, then go for it. But don't think that current tests in emulator are enough to validate it works. This is because I wasn't writing e2e tests for this as it was experimental feature and e2e tests are being done in flow-go for final version. I did quite a bit of manual tests to make sure it works. So if you did as well then I have no objections. If this is updated and not really validated it works as it should then we can't merge it in.

@joshuahannan
Copy link
Member

@devbugging Are the unit tests in flow-core-contracts enough to validate that the contract works as it should? So far, it seems to be working properly for the happy path for sure and definitely some edge cases too. afaik, this emulator release will just be used for internal testing, right? So I think it is okay to maybe take a small risk that something in the contract doesn't fully work if it means that we get full functionality of the contract and the correct events, API, etc for our internal testing

@devbugging
Copy link
Contributor Author

@joshuahannan the contract tests make sure the contract works but doesn't check this integration. I'm fine if we use the new contract, but then we need to update to also use correct templates from flow-core-contract as well as the contract imported from there. So we either get in what we have and it's tested and make another PR that updates everything, or we update the emulator to use flow-core-contracts as it should and we must at least once run happy-path manually. I don't feel confident merging something noone tested. Either way it's fine with me, but I don't have now time to update the emulator to use flow-core-contracts. Maybe next week or so. If you have then that's great. Otherwise that was my concern with delays.

@joshuahannan
Copy link
Member

Okay, I can spend some time this week updating it and testing it more

@jribbink
Copy link
Contributor

jribbink commented Aug 1, 2025

@joshuahannan @devbugging - can I merge this now? Hoping to release to the CLI asap :)

@joshuahannan
Copy link
Member

@jribbink Gregor told me that there were some issues when he was manually testing it so I don't know if it will work. I didn't understand the issues though. You might need to reach out to him to see what needs to be done because I don't think he gets notifications from github comments

@devbugging
Copy link
Contributor Author

devbugging commented Aug 4, 2025

@jribbink
I tested the emulator now and after the scheduled callback is executed the emulator hangs with block production. I'm pretty sure the issue is not big, but it needs focus to fix to all latest changes.

❌ Command Error: failed to submit transaction: client: rpc error: code = Internal desc = pending block with ID 88bd8ce5460741226dec41f2cc4021555635e1be68ff272b8f7cd642ffcdc537 is currently being executed

I don't think this PR is currently in working condition. So we either revert back to my last commit which was a working experiemntal version since 2 months ago, or we update the emulator to work with current version, but I don't know when I will be able to spend time on updating emulator since my time is now focused on making flow-go work.
That was my intention with this emulator version anyway, it wasn't to be latest version of WIP scheduled callbacks because that just adds on my plate to then maintain it.
I can hopefully spend some time second half of the week to udpate it, but I can only do that after I finish some localnet testing, which I can't predict how long it will take.

@jribbink
Copy link
Contributor

jribbink commented Aug 4, 2025

@devbugging

Gotcha, I can wait until we have something working. I would agree that it doesn't make sense to ship an old API in this case, especially if there are significant changes and an update is already in the pipeline, as we'll just be repeating the same effort twice for little added benefit.

Thank you!

@joshuahannan
Copy link
Member

joshuahannan commented Aug 4, 2025

I'll spend some time this week to try to get it working

@joshuahannan
Copy link
Member

@jribbink I got everything passing with the tests and the manual testing, so this is good to merge and make a release! Let me know if there is anything else you need for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants