Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/edmund/l2-spv-poc' into edmund/l…
Browse files Browse the repository at this point in the history
…2-spv-poc
  • Loading branch information
edmundnoble committed Apr 19, 2023
2 parents 4303d4f + b8952a4 commit f05e411
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ package yet-another-logger
source-repository-package
type: git
location: https://github.com/kadena-io/pact.git
tag: 842fbc4256b3cbbde337dbeaa393b649a26f1574
tag: 1484c15af7f3514524e5986f061f950c030d34b6

source-repository-package
type: git
Expand Down
4 changes: 2 additions & 2 deletions src/Chainweb/SPV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ data ProofTarget = ProofTargetChain !ChainId | ProofTargetCrossNetwork !Text
deriving anyclass NFData

instance ToJSON ProofTarget where
toJSON (ProofTargetChain cid) = toJSON cid
toJSON (ProofTargetChain cid) = toJSON (toText cid)
toJSON (ProofTargetCrossNetwork subtgt) = toJSON ("crossnet:" <> subtgt)
toEncoding (ProofTargetChain cid) = toEncoding cid
toEncoding (ProofTargetChain cid) = toEncoding (toText cid)
toEncoding (ProofTargetCrossNetwork subtgt) = toEncoding ("crossnet:" <> subtgt)

instance FromJSON ProofTarget where
Expand Down
9 changes: 6 additions & 3 deletions src/Chainweb/SPV/VerifyProof.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ verifyTransactionOutputProofAt_
-> TransactionOutputProof SHA512t_256
-> BlockHash
-> IO TransactionOutput
verifyTransactionOutputProofAt_ bdb proof@(TransactionOutputProof _cid p) ctx = do
unlessM (ancestorOf bdb h ctx) $ throwM
$ SpvExceptionVerificationFailed "target header is not in the chain"
verifyTransactionOutputProofAt_ bdb proof@(TransactionOutputProof tgt p) ctx = do
case tgt of
ProofTargetChain _cid ->
unlessM (ancestorOf bdb h ctx) $ throwM
$ SpvExceptionVerificationFailed "target header is not in the chain"
ProofTargetCrossNetwork _net -> return ()
proofSubject p
where
h = runTransactionOutputProof proof

0 comments on commit f05e411

Please sign in to comment.