From 47743ddd5aee1f5090e2db27def056460d47401e Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 21 Nov 2024 09:26:00 -0600 Subject: [PATCH] Release preparation --- .gitmodules | 2 +- CHANGELOG.md | 1 + src/Zenith/CLI.hs | 14 +++++++------- src/Zenith/Core.hs | 20 ++++---------------- src/Zenith/DB.hs | 2 +- src/Zenith/GUI.hs | 13 +++++++------ src/Zenith/RPC.hs | 8 ++++---- src/Zenith/Scanner.hs | 4 ++-- src/Zenith/Tree.hs | 11 +++-------- zcash-haskell | 2 +- 10 files changed, 31 insertions(+), 46 deletions(-) diff --git a/.gitmodules b/.gitmodules index 8a74eac..601b93a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "zcash-haskell"] path = zcash-haskell url = https://git.vergara.tech/Vergara_Tech/zcash-haskell.git - branch = milestone2 + branch = master diff --git a/CHANGELOG.md b/CHANGELOG.md index 80d13ed..3f041b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `getoperationstatus` RPC method - `sendmany` RPC method - Function `prepareTxV2` implementing `PrivacyPolicy` +- Support for TEX addresses - Functionality to shield transparent balance - Functionality to de-shield shielded notes - Native commitment trees diff --git a/src/Zenith/CLI.hs b/src/Zenith/CLI.hs index 2a6a5d4..c2fa1a7 100644 --- a/src/Zenith/CLI.hs +++ b/src/Zenith/CLI.hs @@ -528,7 +528,7 @@ drawUI s = [splashDialog s, helpDialog s, displayDialog s, inputDialog s, ui s] (str " _____ _ _ _ \n|__ /___ _ __ (_) |_| |__\n / // _ \\ '_ \\| | __| '_ \\\n / /| __/ | | | | |_| | | |\n/____\\___|_| |_|_|\\__|_| |_|") <=> C.hCenter - (withAttr titleAttr (str "Zcash Wallet v0.6.0.0-beta")) <=> + (withAttr titleAttr (str "Zcash Wallet v0.7.0.0-beta")) <=> C.hCenter (withAttr blinkAttr $ str "Press any key...")) else emptyWidget capCommand3 :: String -> String -> String -> Widget Name @@ -827,7 +827,7 @@ scanZebra :: -> Int -> BC.BChan Tick -> ZcashNet - -> LoggingT IO () + -> NoLoggingT IO () scanZebra dbP zHost zPort b eChan znet = do bStatus <- liftIO $ checkBlockChain zHost zPort pool <- liftIO $ runNoLoggingT $ initPool dbP @@ -860,7 +860,7 @@ scanZebra dbP zHost zPort b eChan znet = do _ <- liftIO $ startSync pool mapM_ (liftIO . processBlock pool step) bList confUp <- - liftIO $ try $ updateConfs zHost zPort pool :: LoggingT + liftIO $ try $ updateConfs zHost zPort pool :: NoLoggingT IO (Either IOError ()) case confUp of @@ -940,7 +940,7 @@ appEvent (BT.AppEvent t) = do Just (_k, w) -> return w _ <- liftIO $ - runStderrLoggingT $ + runNoLoggingT $ syncWallet (Config (s ^. dbPath) @@ -1006,7 +1006,7 @@ appEvent (BT.AppEvent t) = do _ <- liftIO $ forkIO $ - runStderrLoggingT $ + runNoLoggingT $ scanZebra (s ^. dbPath) (s ^. zebraHost) @@ -2021,7 +2021,7 @@ sendTransaction pool chan zHost zPort znet accId bl amt ua memo policy = do Nothing -> BC.writeBChan chan $ TickMsg "Incorrect address" Just outUA -> do res <- - runStderrLoggingT $ + runNoLoggingT $ prepareTxV2 pool zHost @@ -2089,7 +2089,7 @@ deshieldTransaction :: -> IO () deshieldTransaction pool chan zHost zPort znet accId bl pnote = do BC.writeBChan chan $ TickMsg "Deshielding funds..." - res <- runStderrLoggingT $ deshieldNotes pool zHost zPort znet accId bl pnote + res <- runNoLoggingT $ deshieldNotes pool zHost zPort znet accId bl pnote case res of Left e -> BC.writeBChan chan $ TickMsg $ show e Right rawTx -> do diff --git a/src/Zenith/Core.hs b/src/Zenith/Core.hs index 6b0cdab..835a00d 100644 --- a/src/Zenith/Core.hs +++ b/src/Zenith/Core.hs @@ -8,21 +8,15 @@ import Control.Monad (forM, unless, when) import Control.Monad.IO.Class (liftIO) import Control.Monad.Logger ( LoggingT - , MonadLoggerIO , NoLoggingT , logDebugN , logErrorN , logInfoN - , logWarnN - , runFileLoggingT , runNoLoggingT - , runStdoutLoggingT ) import Crypto.Secp256k1 (SecKey(..)) import Data.Aeson -import Data.Binary.Get hiding (getBytes) import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as LBS import Data.HexString (HexString, hexBytes, hexString, toBytes, toText) import Data.Int (Int32, Int64) import Data.List @@ -34,14 +28,8 @@ import Data.Time import qualified Database.Esqueleto.Experimental as ESQ import Database.Persist import Database.Persist.Sqlite -import GHC.Float.RealFracMethods - ( ceilingFloatInteger - , floorFloatInt - , floorFloatInteger - ) import Haskoin.Crypto.Keys (XPrvKey(..)) import Lens.Micro ((&), (.~), (^.), set) -import Network.HTTP.Client import ZcashHaskell.Keys import ZcashHaskell.Orchard ( decryptOrchardActionSK @@ -759,7 +747,7 @@ deshieldNotes :: -> ZcashAccountId -> Int -> ProposedNote - -> LoggingT IO (Either TxError HexString) + -> NoLoggingT IO (Either TxError HexString) deshieldNotes pool zebraHost zebraPort znet za bh pnote = do bal <- liftIO $ getShieldedBalance pool za let zats = pn_amt pnote * scientific 1 8 @@ -886,7 +874,7 @@ prepareTxV2 :: -> Int -> [ProposedNote] -> PrivacyPolicy - -> LoggingT IO (Either TxError HexString) + -> NoLoggingT IO (Either TxError HexString) prepareTxV2 pool zebraHost zebraPort zn za bh pnotes policy = do accRead <- liftIO $ getAccountById pool za let recipients = map extractReceiver pnotes @@ -1297,7 +1285,7 @@ prepareTxV2 pool zebraHost zebraPort zn za bh pnotes policy = do syncWallet :: Config -- ^ configuration parameters -> Entity ZcashWallet - -> LoggingT IO () + -> NoLoggingT IO () syncWallet config w = do startTime <- liftIO getCurrentTime logDebugN $ T.pack $ show startTime @@ -1343,7 +1331,7 @@ syncWallet config w = do -- | Update commitment trees updateCommitmentTrees :: - ConnectionPool -> T.Text -> Int -> ZcashNetDB -> LoggingT IO () + ConnectionPool -> T.Text -> Int -> ZcashNetDB -> NoLoggingT IO () updateCommitmentTrees pool zHost zPort zNet = do sTdb <- liftIO $ getSaplingTree pool oTdb <- liftIO $ getOrchardTree pool diff --git a/src/Zenith/DB.hs b/src/Zenith/DB.hs index 4c9e7bf..dfbedf9 100644 --- a/src/Zenith/DB.hs +++ b/src/Zenith/DB.hs @@ -2680,7 +2680,7 @@ completeSync pool st = do return () -- | Rewind the data store to a given block height -rewindWalletData :: ConnectionPool -> Int -> ZcashNetDB -> LoggingT IO () +rewindWalletData :: ConnectionPool -> Int -> ZcashNetDB -> NoLoggingT IO () rewindWalletData pool b net = do logDebugN "Starting transaction rewind" liftIO $ rewindWalletTransactions pool b diff --git a/src/Zenith/GUI.hs b/src/Zenith/GUI.hs index ad5d5c7..304d960 100644 --- a/src/Zenith/GUI.hs +++ b/src/Zenith/GUI.hs @@ -15,6 +15,7 @@ import Control.Monad (forM_, unless, when) import Control.Monad.IO.Class (liftIO) import Control.Monad.Logger ( LoggingT + , NoLoggingT , logDebugN , runNoLoggingT , runStderrLoggingT @@ -1395,7 +1396,7 @@ handleEvent wenv node model evt = model & timer .~ 0 & barValue .~ 0.0 & modalMsg ?~ "Downloading blocks..." , Producer $ - runStderrLoggingT . + runNoLoggingT . scanZebra (c_dbPath $ model ^. configuration) (c_zebraHost $ model ^. configuration) @@ -1411,7 +1412,7 @@ handleEvent wenv node model evt = case currentWallet of Nothing -> return $ ShowError "No wallet available" Just cW -> do - runStderrLoggingT $ syncWallet (model ^. configuration) cW + runNoLoggingT $ syncWallet (model ^. configuration) cW pool <- runNoLoggingT $ initPool $ c_dbPath $ model ^. configuration wL <- getWallets pool (model ^. network) @@ -1668,7 +1669,7 @@ scanZebra :: -> Int -> ZcashNet -> (AppEvent -> IO ()) - -> LoggingT IO () + -> NoLoggingT IO () scanZebra dbPath zHost zPort net sendMsg = do bStatus <- liftIO $ checkBlockChain zHost zPort pool <- liftIO $ runNoLoggingT $ initPool dbPath @@ -1697,7 +1698,7 @@ scanZebra dbPath zHost zPort net sendMsg = do _ <- liftIO $ startSync pool mapM_ (liftIO . processBlock pool step) bList confUp <- - liftIO $ try $ updateConfs zHost zPort pool :: LoggingT + liftIO $ try $ updateConfs zHost zPort pool :: NoLoggingT IO (Either IOError ()) case confUp of @@ -1806,7 +1807,7 @@ deshieldTransaction config znet accId addR pnote sendMsg = do Nothing -> sendMsg $ ShowError "No transparent address available" Just tAddr -> do res <- - runStderrLoggingT $ + runNoLoggingT $ deshieldNotes pool zHost @@ -1850,7 +1851,7 @@ sendTransaction config znet accId bl amt ua memo policy sendMsg = do let zPort = c_zebraPort config pool <- runNoLoggingT $ initPool dbPath res <- - runStderrLoggingT $ + runNoLoggingT $ prepareTxV2 pool zHost diff --git a/src/Zenith/RPC.hs b/src/Zenith/RPC.hs index 286521e..a32fb8f 100644 --- a/src/Zenith/RPC.hs +++ b/src/Zenith/RPC.hs @@ -834,7 +834,7 @@ zenithServer state = getinfo :<|> handleRPC forkIO $ do res <- liftIO $ - runStderrLoggingT $ + runNoLoggingT $ prepareTxV2 pool zHost @@ -898,7 +898,7 @@ scanZebra dbPath zHost zPort net = do then max dbBlock b else max chkBlock b unless (chkBlock == dbBlock || chkBlock == 1) $ - runStderrLoggingT $ rewindWalletData pool sb $ ZcashNetDB net + runNoLoggingT $ rewindWalletData pool sb $ ZcashNetDB net unless (sb > zgb_blocks bStatus || sb < 1) $ do let bList = [(sb + 1) .. (zgb_blocks bStatus)] unless (null bList) $ do @@ -912,9 +912,9 @@ scanZebra dbPath zHost zPort net = do Right _ -> do wals <- getWallets pool net _ <- - runStderrLoggingT $ + runNoLoggingT $ updateCommitmentTrees pool zHost zPort $ ZcashNetDB net - runStderrLoggingT $ + runNoLoggingT $ mapM_ (syncWallet (Config dbPath zHost zPort "user" "pwd" 8080)) wals diff --git a/src/Zenith/Scanner.hs b/src/Zenith/Scanner.hs index 9344a35..50d6235 100644 --- a/src/Zenith/Scanner.hs +++ b/src/Zenith/Scanner.hs @@ -108,7 +108,7 @@ rescanZebra host port dbFilePath = do {-mapM_ (processBlock host port pool3 pg3 znet) bl3-} print "Please wait..." _ <- completeSync pool1 Successful - _ <- runStderrLoggingT $ updateCommitmentTrees pool1 host port znet + _ <- runNoLoggingT $ updateCommitmentTrees pool1 host port znet print "Rescan complete" -- | Function to process a raw block and extract the transaction information @@ -239,7 +239,7 @@ clearSync config = do w <- getWallets pool $ zgb_net chainInfo liftIO $ mapM_ (updateWalletSync pool 0 . entityKey) w w' <- liftIO $ getWallets pool $ zgb_net chainInfo - r <- runStderrLoggingT $ mapM (syncWallet config) w' + r <- runNoLoggingT $ mapM (syncWallet config) w' liftIO $ print r -- | Detect chain re-orgs diff --git a/src/Zenith/Tree.hs b/src/Zenith/Tree.hs index 1a52243..042421b 100644 --- a/src/Zenith/Tree.hs +++ b/src/Zenith/Tree.hs @@ -9,7 +9,7 @@ module Zenith.Tree where import Codec.Borsh -import Control.Monad.Logger (LoggingT, logDebugN) +import Control.Monad.Logger (NoLoggingT, logDebugN) import Data.HexString import Data.Int (Int32, Int64, Int8) import Data.Maybe (fromJust, isNothing) @@ -18,12 +18,7 @@ import qualified GHC.Generics as GHC import qualified Generics.SOP as SOP import ZcashHaskell.Orchard (combineOrchardNodes, getOrchardNodeValue) import ZcashHaskell.Sapling (combineSaplingNodes, getSaplingNodeValue) -import ZcashHaskell.Types - ( MerklePath(..) - , OrchardFrontier(..) - , OrchardTree(..) - , SaplingTree(..) - ) +import ZcashHaskell.Types (MerklePath(..), OrchardTree(..), SaplingTree(..)) type Level = Int8 @@ -181,7 +176,7 @@ getNotePosition (Branch _ x y) i | otherwise = Nothing getNotePosition _ _ = Nothing -truncateTree :: Monoid v => Node v => Tree v -> Int64 -> LoggingT IO (Tree v) +truncateTree :: Monoid v => Node v => Tree v -> Int64 -> NoLoggingT IO (Tree v) truncateTree (Branch s x y) i | getLevel s == 1 && getIndex (value x) == i = do logDebugN $ T.pack $ show (getLevel s) ++ " Trunc to left leaf" diff --git a/zcash-haskell b/zcash-haskell index dea960c..d45bd7d 160000 --- a/zcash-haskell +++ b/zcash-haskell @@ -1 +1 @@ -Subproject commit dea960c2acf7479eeb42845c07b482449d538aae +Subproject commit d45bd7dcf3c3cf4e893900a1774d24b14bf56591