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
SPV support with configurable backend #436
Conversation
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.
Looks good! Only a few small comments
spv :: MVar (LibState) -> Text -> Object Name -> IO (Either Text (Object Name)) | ||
spv mv ty _ = readMVar mv >>= \LibState{..} -> case M.lookup ty _rlsMockSPV of | ||
Nothing -> return $ Left $ "Unsupported SPV proof type: " <> ty | ||
Just o -> return $ Right o |
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.
Why pass Object Name
if it's never used? I'm assuming this is for future SPV work. If so, could we document what needs to be passed in there?
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 supports mock-spv
-- we're not going to have actual SPV proofs in Pact or pact -s
anytime soon, and I didn't want to build a cadillac mocker that is arg-dependent, so in repl scripts you just specify a response for a particular type and it will return that regardless of argument.
The larger question is whether the API itself is too lawless, ie string -> object -> object
. There's nothing SPV-y about it, it's almost a general computation backend on untyped objects. The intent is to read something from the message payload which will be desz'd into the SPV proof object, and get back the desz'd payload of that proof, with support for "types", ie "TXIN" ("did my transaction go in?") and "TXOUT" ("did my transaction run and have this exact output?"). So I can't really think of a better shape, but thought I'd ask.
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.
That's fair.
Unfortunately without "actually" calling out to SPV, i don't think you can do much besides mocking trivial SPV. That is, unless you want to come up with a way of storing merkle roots for a series of transactions and having the input object be verified as one of the inputs to a sort of "current merkle root" state in in the repl state, I don't how it could be lawful. For mocking, I guess this is fine, though, I do think it would be pretty cool to have SPV be tracked as part of the repl state.
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.
Mocking on both arguments now as discussed
toJSON . _erOutput <$> | ||
evalExec (setupEvalEnv dbEnv entity t (initMsgData (initialHashTx H.Blake2b_512)) | ||
refStore freeGasEnv permissiveNamespacePolicy noSPVSupport) | ||
pc | ||
|
||
benchKeySet :: KeySet | ||
benchKeySet = KeySet [PublicKey "benchadmin"] (Name ">" def) |
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.
These pc
's are a small legibility wibble. Maybe we should where
on the evalExec
so those <$>
's aren't line breaking on their arguments?
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.
done
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.
Very slick 👍
Adds builtin
verify-spv
which utilizes supplied backend to operate on an Object payload, and return an object with the proof payload upon success.