Skip to content
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

Emit synthetic cross-chain events #875

Merged
merged 7 commits into from
Jun 4, 2021
Merged

Emit synthetic cross-chain events #875

merged 7 commits into from
Jun 4, 2021

Conversation

sirlensalot
Copy link
Contributor

@sirlensalot sirlensalot commented Jun 2, 2021

Emit synthetic events for cross-chain defpact executions. The signatures are

  • (pact.X_YIELD targetChain continuationName continuationArgs) for cross-chain yields
  • (pact.X_RESUME sourceChain continuationName continuationArgs) for cross-chain resumes

Thus a cross-chain transfer send from 0 to 1 would be (pact.X_YIELD "1" "coin.transfer-crosschain" ["Bob" "Alice" 10.0]) on 0 then (pact.X_RESUME "0" "coin.transfer-crosschain" ["Bob" "Alice" 10.0]) on 1.

@sirlensalot sirlensalot marked this pull request as draft June 2, 2021 04:45
@sirlensalot sirlensalot marked this pull request as ready for review June 2, 2021 15:24
emitEventUnsafe (QualifiedName "pact" name def) params mhash

emitEventUnsafe :: QualifiedName -> [PactValue] -> ModuleHash -> Eval e ()
emitEventUnsafe QualifiedName{..} params mh = do
Copy link
Contributor

@emmanueldenloye emmanueldenloye Jun 2, 2021

Choose a reason for hiding this comment

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

Why not append here? Also, what about using a dlist?

EDIT: I meant to say cons instead of append.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Events are rarely more than 1-2 long so not concerned about append performance as of yet ...

return result

applyPact _ _ t _ = evalError' t "applyPact: invalid defpact body, expected list of steps"


-- | Synthesize events for cross chain.
emitXChainEvents :: Maybe Yield -> PactExec -> Eval e ()
emitXChainEvents mResume PactExec {..} = do
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it acceptable that mResume is Nothing while _peYield yields (pardon the obvious pun) a Just value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in fact that's expected. I'll update comments

@sirlensalot sirlensalot merged commit 22900b9 into master Jun 4, 2021
@sirlensalot sirlensalot deleted the feat/xchain-events branch June 4, 2021 15:14
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.

None yet

3 participants