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

feat(#383, #384): add more certificates and node update to v10.1.3 #382

Merged
merged 22 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9927495
feat(#381): add drep registeration certificate
sourabhxyz Dec 27, 2024
b81a05c
feat(#381): add drep registeration test
sourabhxyz Dec 27, 2024
8221491
test(#381): also add signature from drep
sourabhxyz Dec 27, 2024
f31adba
feat(#381): also log balance lost, increase drep deposit protocol param
sourabhxyz Dec 27, 2024
fd9471d
style(#381): fourmolu
sourabhxyz Dec 27, 2024
f1e9786
feat(#381): refactor drep module
sourabhxyz Dec 28, 2024
0290754
feat(#383): update to node v10.1.3
sourabhxyz Dec 28, 2024
9f49388
feat(#383): clean cabal.project file
sourabhxyz Dec 28, 2024
3b92127
feat(#383): clean cabal.project file
sourabhxyz Dec 28, 2024
2b61385
chore(#383): update changelog
sourabhxyz Dec 28, 2024
0d52956
feat(#384): delegate to drep before trying withdrawal in privnet test
sourabhxyz Dec 29, 2024
c1b455d
fix(#384): don't delegate to drep in case of script credential
sourabhxyz Dec 29, 2024
4619398
feat(#384): updates to epoch module
sourabhxyz Dec 29, 2024
a1842ac
feat(#384): updates to anchor module
sourabhxyz Dec 29, 2024
44e836f
feat(#384): updates to drep module
sourabhxyz Dec 29, 2024
fe7c718
style(#384): fourmolu
sourabhxyz Dec 29, 2024
5e505ad
feat(#384): add drep update certificate
sourabhxyz Dec 29, 2024
24b89f7
feat(#384): add drep unregistration certificate
sourabhxyz Dec 29, 2024
4141da7
feat(#384): handle drep unregistration refund in coin balancing
sourabhxyz Dec 29, 2024
8f2693c
feat(#384): use custom fork of cardano-api to fix a bug in their code
sourabhxyz Dec 30, 2024
e74bdb5
style(#384): hlint...
sourabhxyz Dec 30, 2024
00865c1
feat(#384): update default value of `GYAwaitTxParameters`
sourabhxyz Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* Likewise types `GYSigningKey kr`, `GYVerificationKey kr`, `GYExtendedSigningKey kr` are newly introduced and previous relevant key types like `GYPaymentSigningKey` are simply type synonyms.
* Constructor of `GYPubKeyHash` is no longer exported.
* `readSomeSigningKey` is removed.
* Adds additional certificates such as those related to governance, drep participation, etc.
* Tracks node version 10.1.3 and corresponding updated CLB version.
* Update default value of `GYAwaitTxParameters` to now have 100 max attempts.

## 0.7.0

Expand Down
4 changes: 3 additions & 1 deletion atlas-cardano.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ library
GeniusYield.Types
GeniusYield.Types.Ada
GeniusYield.Types.Address
GeniusYield.Types.Anchor
GeniusYield.Types.Blueprint
GeniusYield.Types.Blueprint.Argument
GeniusYield.Types.Blueprint.Contract
Expand Down Expand Up @@ -189,7 +190,7 @@ library
auto-update ^>=0.2.1,
base ^>=4.18.2,
base16-bytestring ^>=1.0.2,
blockfrost-client ^>=0.8.0,
blockfrost-client ^>=0.9.1,
bytestring ^>=0.11.5,
cache ^>=0.1.3,
cassava ^>=0.5.3,
Expand Down Expand Up @@ -365,6 +366,7 @@ test-suite atlas-privnet-tests
main-is: atlas-privnet-tests.hs
other-modules:
GeniusYield.Test.Privnet.Blueprint
GeniusYield.Test.Privnet.DRep
GeniusYield.Test.Privnet.SimpleScripts
GeniusYield.Test.Privnet.Stake
GeniusYield.Test.Privnet.Stake.Key
Expand Down
90 changes: 43 additions & 47 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ packages: .
tests: true

-- repeating the index-state for hackage to work around hackage.nix parsing limitation
index-state: 2024-08-27T16:28:01Z
index-state: 2024-10-10T00:52:24Z

-- NOTE: Do not bump chap index beyond that used by target cardano-node version.
index-state:
, hackage.haskell.org 2024-08-27T16:28:01Z
, cardano-haskell-packages 2024-07-24T14:16:32Z
, hackage.haskell.org 2024-10-10T00:52:24Z
, cardano-haskell-packages 2024-11-26T16:00:26Z

-- NOTE: Do not bump chap index beyond that used by target cardano-node version.

-- TODO: Default value should be @direct@ in upcoming 3.10 version of cabal, omit this line then.
test-show-details: direct
Expand All @@ -34,67 +34,59 @@ source-repository-package
tag: v1.7.3
--sha256: sha256-FYZMbh9Uz+RIjjXIf3PBK94mhd1XMX/wxHDA9LukvQg=

-- TODO: Temporary, until proposed changes are in upstream (track https://github.com/blockfrost/blockfrost-haskell/pull/59).
source-repository-package
type: git
location: https://github.com/sourabhxyz/blockfrost-haskell
tag: a0247472e3932a5cad523d8566a4404130ca6747
--sha256: sha256-QOjapkF+fxMTc5LwXk89IPkgjL8LwzpztfwvvAGRzDk=
subdir:
blockfrost-api

-- TODO: Temporary, until proposed changes are in upstream (track https://github.com/mlabs-haskell/clb/pull/44)
-- TODO: Temporary, until proposed changes are in upstream (track https://github.com/mlabs-haskell/clb/pull/62)
source-repository-package
type: git
location: https://github.com/sourabhxyz/clb
tag: 09414a93047b4c7f6e03e20d1730c9c0f88e1d46
--sha256: sha256-y5fF8IDywt/pQ3HsRE6CpAlqK4uiU/SRuDIqSHxBED0=
tag: 257475d987994db8dc5b1b27c9cdf6d6ea547a2c
--sha256: sha256-Tf9Pxh0W1cyvqPKKA07VVZCOLJBMk8W7BVLV+jwZeOM=
subdir:
clb
emulator

-- Obtaining cardano-node stuff for 9.1.0. These aren't published on CHaP yet.
-- Obtaining cardano-node stuff for 10.1.3 as cardano-testnet version available on CHaP is not correctly updated.
source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-node
tag: 9.1.0
--sha256: sha256-F5wgRA820x16f+8c/LlEEBG0rMJIA1XWw6X0ZwX5UWs=
tag: 10.1.3
--sha256: sha256-v0q8qHdI6LKc8mP43QZt3UGdTNDQXE0aF6QapvZsTvU=
subdir:
cardano-node
cardano-testnet
trace-dispatcher

-- TODO: Make changes upstream
-- TODO: Temporary, track https://github.com/IntersectMBO/cardano-api/issues/714.
source-repository-package
type: git
location: https://github.com/geniusyield/cardano-wallet
tag: 3413fdf74fd25b100662abf2a49c1afc892f1b79
--sha256: sha256-V5DNUzraaDJo6cXc1eeVVIJNWqC8JayQrJeNNLg/Els=
location: https://github.com/sourabhxyz/cardano-api
tag: 7081a82a4c6dd57cc0ab01027a18233d3bca2b3e
--sha256: sha256-JGyNbkEkBl69mfMc42Sq4sBwR2IY84aO2WcQihSKdLM=
subdir:
cardano-api
cardano-api-gen

source-repository-package
type: git
location: https://github.com/cardano-foundation/cardano-wallet
tag: 630ef0067c2c0df1b398256d75923db928beefa1
--sha256: sha256-0iDG3LW60pb+ih+nfqQ3vR+WI7JEm+0kI3Vg7jqm1L0=
subdir:
lib/address-derivation-discovery
lib/balance-tx/
lib/coin-selection/
lib/crypto-primitives/
lib/delta-store/
lib/delta-table
lib/coin-selection/
lib/delta-types/
lib/iohk-monitoring-extra
lib/launcher/
lib/network-layer/
lib/numeric/
lib/primitive/
lib/read
lib/secrets
lib/std-gen-seed/
lib/test-utils/
lib/text-class/
lib/wai-middleware-logging/
lib/wallet-benchmarks/
lib/wallet/

package postgresql-libpq
flags: +use-pkg-config

------ Following is mostly from @cardano-wallet@'s @cabal.project@ file. -------

--------------------------------------------------------------------------------
-- BEGIN Cardano Addresses Dependency

source-repository-package
type: git
Expand All @@ -110,11 +102,6 @@ source-repository-package
-- pragma are an exception to this rule.
-- This is why we need to manually control options that are applied to the
-- `cardano-addresses` package by declaring them explicitly here.
--
-- Cardano Addresses CLI uses an outdated version of the `optparse-applicative`
-- library. This causes a deprecation warning to be emitted when building.
-- We don't want to promote this warning to an error level as it break the
-- release build and cardano-addresses codebase is not under our control.
package cardano-addresses-cli
ghc-options:
-Wwarn=deprecations
Expand All @@ -138,20 +125,28 @@ source-repository-package
--sha256: 04q58c82wy6x9nkwqbvcxbv6s61fx08h5kf62sb511aqp08id4bb
subdir: generated

source-repository-package
type: git
location: https://github.com/cardano-foundation/cardano-wallet-agda
tag: f3479b501a2efe50bcf1ee0d09bc2d1325a982e7
--sha256: 10d6k7mw1zw9vpzz8dhb52vfmj2rshsk225nvyl8nrc94fr627kz
subdir:
lib/customer-deposit-wallet-pure
lib/cardano-wallet-read

--------------------------------------------------------------------------------
-- BEGIN Constraints tweaking section

allow-newer:
async-timer:unliftio-core
, servant-openapi3:*
, katip:Win32
, raven-haskell:aeson
, ekg-wai:time

constraints:
base >= 4.18.2.0 && < 5
, openapi3 >= 3.2.0
, persistent ^>= 2.14.6.0
, cardano-node ^>= 9.1.0

, bech32 >= 1.1.7

-- lower versions of katip won't build with the Win32-2.12.0.1
Expand All @@ -162,9 +157,10 @@ constraints:
-- Cardano Node dependencies:
, io-classes >= 1.4
, io-classes -asserts
, ouroboros-consensus-cardano ^>= 0.18
, ouroboros-network ^>= 0.16.1
, ouroboros-network-protocols ^>= 0.9

, cardano-ledger-api ^>= 1.9

, ouroboros-network ^>= 0.17

-- END Constraints tweaking section
--------------------------------------------------------------------------------
Expand Down
18 changes: 16 additions & 2 deletions src/GeniusYield/GYConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import GeniusYield.Providers.Blockfrost qualified as Blockfrost
-- import qualified GeniusYield.Providers.CachedQueryUTxOs as CachedQuery
import GeniusYield.Providers.Kupo qualified as KupoApi
import GeniusYield.Providers.Maestro qualified as MaestroApi
import GeniusYield.Providers.Node (nodeStakeAddressInfo)
import GeniusYield.Providers.Node (nodeGetDRepState, nodeGetDRepsState, nodeStakeAddressInfo)
import GeniusYield.Providers.Node qualified as Node
import GeniusYield.ReadJSON (readJSON)
import GeniusYield.Types
Expand Down Expand Up @@ -160,7 +160,7 @@ withCfgProviders
ns
f =
do
(gyGetParameters, gySlotActions', gyQueryUTxO', gyLookupDatum, gySubmitTx, gyAwaitTxConfirmed, gyGetStakeAddressInfo, gyGetStakePools) <- case cfgCoreProvider of
(gyGetParameters, gySlotActions', gyQueryUTxO', gyLookupDatum, gySubmitTx, gyAwaitTxConfirmed, gyGetStakeAddressInfo, gyGetDRepState, gyGetDRepsState, gyGetStakePools) <- case cfgCoreProvider of
GYNodeKupo path kupoUrl -> do
let info = nodeConnectInfo path cfgNetworkId
kEnv <- KupoApi.newKupoApiEnv $ Text.unpack kupoUrl
Expand All @@ -174,6 +174,8 @@ withCfgProviders
, Node.nodeSubmitTx info
, KupoApi.kupoAwaitTxConfirmed kEnv
, nodeStakeAddressInfo info
, nodeGetDRepState info
, nodeGetDRepsState info
, Node.nodeStakePools info
)
GYMaestro (Confidential apiToken) turboSubmit -> do
Expand All @@ -193,6 +195,8 @@ withCfgProviders
, MaestroApi.maestroSubmitTx (Just True == turboSubmit) maestroApiEnv
, MaestroApi.maestroAwaitTxConfirmed maestroApiEnv
, MaestroApi.maestroStakeAddressInfo maestroApiEnv
, error "Maestro does not support DRep state"
, error "Maestro does not support DReps state"
, MaestroApi.maestroStakePools maestroApiEnv
)
GYBlockfrost (Confidential key) -> do
Expand All @@ -212,6 +216,8 @@ withCfgProviders
, Blockfrost.blockfrostSubmitTx proj
, Blockfrost.blockfrostAwaitTxConfirmed proj
, Blockfrost.blockfrostStakeAddressInfo proj
, error "Blockfrost provider does not support DRep state"
, error "Blockfrost provider does not support DReps state"
, Blockfrost.blockfrostStakePools proj
)

Expand Down Expand Up @@ -255,6 +261,8 @@ logTiming providers@GYProviders {..} =
, gyGetParameters = gyGetParameters'
, gyQueryUTxO = gyQueryUTxO'
, gyGetStakeAddressInfo = gyGetStakeAddressInfo'
, gyGetDRepState = gyGetDRepState'
, gyGetDRepsState = gyGetDRepsState'
, gyLog' = gyLog'
, gyGetStakePools = gyGetStakePools'
}
Expand Down Expand Up @@ -323,6 +331,12 @@ logTiming providers@GYProviders {..} =
gyGetStakeAddressInfo' :: GYStakeAddress -> IO (Maybe GYStakeAddressInfo)
gyGetStakeAddressInfo' = wrap "gyGetStakeAddressInfo" . gyGetStakeAddressInfo

gyGetDRepState' :: GYCredential 'GYKeyRoleDRep -> IO (Maybe GYDRepState)
gyGetDRepState' = wrap "gyGetDRepState" . gyGetDRepState

gyGetDRepsState' :: Set (GYCredential 'GYKeyRoleDRep) -> IO (Map (GYCredential 'GYKeyRoleDRep) (Maybe GYDRepState))
gyGetDRepsState' = wrap "gyGetDRepsState" . gyGetDRepsState

duration :: IO a -> IO (a, NominalDiffTime)
duration m = do
start <- getCurrentTime
Expand Down
16 changes: 14 additions & 2 deletions src/GeniusYield/Providers/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ module GeniusYield.Providers.Node (
nodeSubmitTx,
nodeSlotActions,
nodeGetParameters,

-- * Low-level
nodeGetSlotOfCurrentBlock,
nodeStakeAddressInfo,
nodeStakePools,
nodeGetDRepState,
nodeGetDRepsState,

-- * Auxiliary
networkIdToLocalNodeConnectInfo,
Expand All @@ -26,6 +26,7 @@ import Cardano.Ledger.Coin qualified as Ledger
import Cardano.Slotting.Time (SystemStart)
import Control.Exception (throwIO)
import Data.Map.Strict qualified as Map
import Data.Maybe (listToMaybe)
import Data.Set qualified as Set
import Data.Text qualified as Txt
import GeniusYield.CardanoApi.Query
Expand Down Expand Up @@ -75,6 +76,17 @@ nodeGetParameters info = makeGetParameters (nodeGetProtocolParameters info) (sys
nodeGetProtocolParameters :: Api.LocalNodeConnectInfo -> IO ApiProtocolParameters
nodeGetProtocolParameters info = queryConwayEra info Api.QueryProtocolParameters

nodeGetDRepState :: Api.LocalNodeConnectInfo -> GYCredential 'GYKeyRoleDRep -> IO (Maybe GYDRepState)
nodeGetDRepState info drep = do
mcredState <- queryConwayEra info $ Api.QueryDRepState (Set.singleton $ credentialToLedger drep)
pure $ listToMaybe $ map snd $ Map.toList $ Map.map drepStateFromLedger mcredState

nodeGetDRepsState :: Api.LocalNodeConnectInfo -> Set.Set (GYCredential 'GYKeyRoleDRep) -> IO (Map.Map (GYCredential 'GYKeyRoleDRep) (Maybe GYDRepState))
nodeGetDRepsState info dreps = do
mcredState <- queryConwayEra info $ Api.QueryDRepState (Set.map credentialToLedger dreps)
let gymcredState = Map.foldlWithKey' (\m k v -> Map.insert (credentialFromLedger k) (Just $ drepStateFromLedger v) m) Map.empty mcredState
pure $ Set.foldl' (\mapAcc drep -> if Map.member drep mapAcc then mapAcc else Map.insert drep Nothing mapAcc) gymcredState dreps

nodeStakePools :: Api.LocalNodeConnectInfo -> IO (Set.Set Api.S.PoolId)
nodeStakePools info = queryConwayEra info Api.QueryStakePools

Expand Down
Loading
Loading