Skip to content

Conversation

@tweag-ev-ak
Copy link
Collaborator

@tweag-ev-ak tweag-ev-ak commented Jan 8, 2026

closes #86

After this PR we can re-organize the events flow.

@tweag-ev-ak tweag-ev-ak force-pushed the add_execute_endpoint branch from db644b3 to ed1b378 Compare January 8, 2026 05:52
@tweag-ev-ak tweag-ev-ak marked this pull request as ready for review January 8, 2026 05:58
Copy link
Contributor

@axman6 axman6 left a comment

Choose a reason for hiding this comment

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

LGTM!

case evalPwcExUnitsWithLogs pwc exMaxBudget of
Right (pwc', logs, exUnits) -> pure (pwc', exUnits, logs, Nothing)
Left (ValidationFailure exUnits evalErr logs pwc') -> pure (pwc', exUnits, logs, Just evalErr)
_err -> fail "The script evaluation has failed"
Copy link
Contributor

Choose a reason for hiding this comment

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

Which case is this matching? We aren't using MonadFail much, and I think that we should at least tell the user why it failed if we have more info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, the simple show err doesn't work here because of the era constraints, I postponed it until the next PRs.

Comment on lines 199 to 235
case C.toScriptInEra (C.convert ctxAlonzoEraOnwards) rsScriptFileContent of
Nothing -> Nothing
Just scriptInEra -> Just (C.toShelleyScript scriptInEra)
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this just C.toShelleyScript <$> C.toScriptInEra (C.convert ctxAlonzoEraOnwards) rsScriptFileContent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, a leftover after copy-paste editing.

Comment on lines +101 to +102
, rsScriptEvaluationParameters :: ScriptEvaluationParameters
, rsScriptForEvaluation :: ScriptForEvaluation
Copy link
Contributor

Choose a reason for hiding this comment

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

These can be removed now (removed in my prometheus PR)

@tweag-ev-ak tweag-ev-ak force-pushed the add_execute_endpoint branch from ed1b378 to 8231f60 Compare January 8, 2026 11:34
@tweag-ev-ak tweag-ev-ak force-pushed the add_execute_endpoint branch from 8231f60 to b855f76 Compare January 8, 2026 11:36
Copy link
Member

@adithyaov adithyaov left a comment

Choose a reason for hiding this comment

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

Few question but overall LGTM.
We might want to take a look at error handling again later.

, evalError :: Maybe EvalError
, exUnits :: ExUnits
, context :: ExecutionContext
, context :: Either ExecutionContext ExecutionContextId
Copy link
Member

Choose a reason for hiding this comment

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

Is my understanding correct: The reason for this change is to provide an ExecutionContextId instead of the whole ExecutionContext while returning the result for /execute.

Is there any other use case in mind?

Can't we just return the entire ExecutionContext? We can just leave this as ExecutionContext?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, looks like this also serves another purpose. It differentiates manual execution from automatic execution.
A followup question: Do we want the event stream to contain manual executions?

Just rs -> do
(_, exUnits, logs, evalError') <- tryRunScriptInContext rs context
liftIO $
events.addExecutionEvent blockHeader $
Copy link
Member

Choose a reason for hiding this comment

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

/execute is not a read + execute.
It's read + execute + write.
This modifies the database and adds and event to the event stream.

Is this what is intended?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good question and yeah, I thought about making an option so it's possible to execute without writing.

This PR and #103 are iterations to this point.

deriving (Show, Eq)

-- resolveScript :: ScriptInAnyLang -> _
resolveScript :: C.ScriptInAnyLang -> ExceptT String IO (ScriptEvaluationParameters, ScriptForEvaluation)
Copy link
Member

Choose a reason for hiding this comment

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

This was removed earlier in another PR IIRC.

Comment on lines +154 to +155
, rsScriptEvaluationParameters
, rsScriptForEvaluation
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove this.

May have been added unintentionally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use to run the scripts in the /execute endpoint

, -- TODO: Should this be incorporated into rsScourse?
-- Can't be Just when rsSource is Nothing
rsScriptFileContent :: Maybe C.ScriptInAnyLang
, rsScriptFileContent :: C.ScriptInAnyLang
Copy link
Member

Choose a reason for hiding this comment

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

Why was this a Maybe earlier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was not required but should be.

@tweag-ev-ak tweag-ev-ak merged commit 22ffc3a into main Jan 9, 2026
2 checks passed
@tweag-ev-ak tweag-ev-ak deleted the add_execute_endpoint branch January 9, 2026 18:40
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.

Add /execute endpoint

4 participants