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

1.0.3-rc3 #78

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions amm-executor/resources/config.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ in
, createIfMissing = True
},

unsafeEval =
{ unsafeTxFee = +310000
, exUnits = 160000000
, exMem = 400000
, unsafeEval =
{ unsafeTxFee = +320000
, exUnits = 165000000
, exMem = 530000
}
}
9 changes: 7 additions & 2 deletions amm-executor/src/Spectrum/Executor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ import Explorer.Config
( ExplorerConfig )
import SubmitAPI.Service
( mkTransactions )
import NetworkAPI.HttpService
( HttpServiceConfig(..), mkHttpCardanoNetwork )

import Spectrum.LedgerSync.Config
( NetworkParameters, NodeSocketConfig(..), parseNetworkParameters )
Expand Down Expand Up @@ -175,6 +177,7 @@ data Env = Env
, mkLogging' :: !(MakeLogging IO IO)
, networkId :: !C.NetworkId
, unsafeEval :: !UnsafeEvalConfig
, httpSubmit :: !HttpServiceConfig
} deriving stock (Generic)

type F = ReaderT Env IO
Expand Down Expand Up @@ -221,6 +224,7 @@ runApp args = do
mkLogging
networkId
unsafeEval
httpSubmit
runContext env wireApp

wireApp :: App ()
Expand Down Expand Up @@ -256,15 +260,16 @@ wireApp = App { unApp = interceptSigTerm >> do

scriptsValidators <- mkScriptsValidators scriptsConfig
transactionsLogging <- forComponent mkLogging "Bots.Transactions"
httpSubmitNetwork <- mkHttpCardanoNetwork mkLogging httpSubmit
let
validatorsV1 = scriptsValidators2AmmValidatorsV1 scriptsValidators
validatorsV2 = scriptsValidators2AmmValidatorsV2 scriptsValidators
refScriptsMap = mkRefScriptsMap txsInsRefs scriptsValidators
(uPoolsRd, _) = mkNoopTopic
(disPoolsRd, _) = mkNoopTopic
tracker = mkPoolTracker pools newPoolsRd uPoolsRd disPoolsRd
transactions = mkTransactions unsafeEval transactionsLogging networkService networkId refScriptsMap walletOutputs vault txAssemblyConfig
poolActionsV1 = mkPoolActions unsafeEval (PaymentPubKeyHash executorPkh) validatorsV1
transactions = mkTransactions unsafeEval transactionsLogging networkService httpSubmitNetwork networkId refScriptsMap walletOutputs vault txAssemblyConfig
poolActionsV1 = mkPoolActions unsafeEval (PaymentPubKeyHash executorPkh) validatorsV1
poolActionsV2 = mkPoolActions unsafeEval (PaymentPubKeyHash executorPkh) validatorsV2
refInputs <- liftIO $ mkRefInputs txsInsRefs explorer
executorService <- mkOrdersExecutorService backlogService transactions explorer resolver poolActionsV1 poolActionsV2 refInputs
Expand Down
3 changes: 3 additions & 0 deletions amm-executor/src/Spectrum/Executor/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import Spectrum.Common.Parsers
( parseTxIn )
import WalletAPI.UtxoStoreConfig
( UtxoStoreConfig )
import NetworkAPI.HttpService
( HttpServiceConfig )

data NetworkConfig = NetworkConfig
{ cardanoNetworkId :: !Natural
Expand Down Expand Up @@ -104,6 +106,7 @@ data AppConfig = AppConfig
, mainnetMode :: !Bool
, utxoStoreConfig :: !UtxoStoreConfig
, unsafeEval :: !UnsafeEvalConfig
, httpSubmit :: !HttpServiceConfig
} deriving (Generic, FromDhall)

loadAppConfig :: MonadIO f => Maybe String -> f AppConfig
Expand Down
10 changes: 5 additions & 5 deletions amm-executor/src/Spectrum/Executor/EventSink/Handlers/Orders.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,23 @@ processOrder logging OrdersExecutorService{..} txTime out = do
)

parseOrder :: (MonadIO m) => Logging m -> FullTxOut -> m (Maybe Order)
parseOrder Logging{..} out =
parseOrder Logging{..} out@FullTxOut{..} =
let
swap = parseFromLedger @Swap out
deposit = parseFromLedger @Deposit out
redeem = parseFromLedger @Redeem out
in case (swap, deposit, redeem) of
(Just (OnChain _ swap'), _, _) -> do
debugM ("Swap order: " ++ show swap)
infoM ("Swap order in " ++ show fullTxOutRef)
pure $ Just . OnChain out $ AnyOrder (swapPoolId swap') (SwapAction swap')
(_, Just (OnChain _ deposit'), _) -> do
debugM ("Deposit order: " ++ show deposit)
infoM ("Deposit order in " ++ show fullTxOutRef)
pure $ Just . OnChain out $ AnyOrder (depositPoolId deposit') (DepositAction deposit')
(_, _, Just (OnChain _ redeem')) -> do
debugM ("Redeem order: " ++ show redeem)
infoM ("Redeem order in " ++ show fullTxOutRef)
pure $ Just . OnChain out $ AnyOrder (redeemPoolId redeem') (RedeemAction redeem')
_ -> do
debugM ("Order not found in: " ++ show out)
infoM ("Order not found in: " ++ show fullTxOutRef)
pure $ Nothing

mkEliminatedOrdersHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ parsePool Logging{..} ScriptsValidators{poolV1Address, poolV2Address} out@FullTx
Just a -> do
if addressCredential fullTxOutAddress == addressCredential poolV1Address
then do
infoM ("Pool v1 found in: " ++ show fullTxOutRef)
infoM ("Pool v1 found in:" ++ show fullTxOutRef)
pure $ Just $ Confirmed (Pool a V1)
else if addressCredential fullTxOutAddress == addressCredential poolV2Address
then do
Expand Down
15 changes: 9 additions & 6 deletions amm-executor/src/Spectrum/Executor/OrdersExecutor/RefInputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ data RefInputs = RefInputs
{ swapOutput :: FullTxOut
, redeemOutput :: FullTxOut
, depositOutput :: FullTxOut
, poolOutput :: FullTxOut
, poolOutputV1 :: FullTxOut
, poolOutputV2 :: FullTxOut
}

data CouldnotRetriveRefInputs = CouldnotRetriveRefInputs deriving Show
Expand All @@ -20,15 +21,17 @@ instance Exception CouldnotRetriveRefInputs
mkRefInputs :: (MonadIO m, MonadThrow m) => TxRefs -> Explorer m -> m RefInputs
mkRefInputs TxRefs{..} Explorer{..} = do
let
poolOutRef = Interop.fromCardanoTxIn poolV1Ref
poolOutV1Ref = Interop.fromCardanoTxIn poolV1Ref
poolOutV2Ref = Interop.fromCardanoTxIn poolV2Ref
depositOutRef = Interop.fromCardanoTxIn depositRef
redeemOutRef = Interop.fromCardanoTxIn redeemRef
swapOutRef = Interop.fromCardanoTxIn swapRef
poolV1RefOuput <- getOutput poolOutRef
poolV1RefOuput <- getOutput poolOutV1Ref
poolV2RefOutput <- getOutput poolOutV2Ref
depositRefOut <- getOutput depositOutRef
redeemRefOut <- getOutput redeemOutRef
swapRefOut <- getOutput swapOutRef
case catMaybes [swapRefOut, redeemRefOut, depositRefOut, poolV1RefOuput] <&> toCardanoTx of
[swap, redeem, deposit, pool] ->
pure $ RefInputs swap redeem deposit pool
case catMaybes [swapRefOut, redeemRefOut, depositRefOut, poolV1RefOuput, poolV2RefOutput] <&> toCardanoTx of
[swap, redeem, deposit, poolV1, poolV2] ->
pure $ RefInputs swap redeem deposit poolV1 poolV2
_ -> throwM CouldnotRetriveRefInputs
15 changes: 11 additions & 4 deletions amm-executor/src/Spectrum/Executor/OrdersExecutor/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ executeOrder'
V1 -> runOrder txRefs explorer pool order poolActionsV1 l
V2 -> runOrder txRefs explorer pool order poolActionsV2 l
tx <- finalizeTx txCandidate
_ <- submitTxByHttp tx
pPool <- throwMaybe (PoolNotFoundInFinalTx poolId) (extractPoolTxOut pool tx)
let
tracedPredictedPool = Traced
Expand Down Expand Up @@ -244,7 +245,7 @@ executeOrderUnsafe'
V1 -> runOrderUnsafe refInputs explorer pool order poolActionsV1 l
V2 -> runOrderUnsafe refInputs explorer pool order poolActionsV2 l
tx <- finalizeTxUnsafe txCandidate changeValue
_ <- submitTx tx
_ <- submitTxByHttp tx
pPool <- throwMaybe (PoolNotFoundInFinalTx poolId) (extractPoolTxOut pool tx)
let
tracedPredictedPool = Traced
Expand All @@ -269,7 +270,11 @@ runOrderUnsafe
-> PoolActions ver
-> Logging m
-> m (TxCandidate, Predicted Core.Pool, Integer)
runOrderUnsafe RefInputs{..} Explorer{..} (Pool (OnChain poolOut pool) _) (OnChain orderOut Core.AnyOrder{..}) PoolActions{..} Logging{..} = do
runOrderUnsafe RefInputs{..} Explorer{..} (Pool (OnChain poolOut pool) version) (OnChain orderOut Core.AnyOrder{..}) PoolActions{..} Logging{..} = do
let
poolOutput = case version of
V1 -> poolOutputV1
V2 -> poolOutputV2
case anyOrderAction of
DepositAction deposit -> do
throwEither (runDeposit [poolOutput, depositOutput] (OnChain orderOut deposit) (poolOut, pool))
Expand All @@ -287,9 +292,11 @@ runOrder
-> PoolActions ver
-> Logging m
-> m (TxCandidate, Predicted Core.Pool)
runOrder TxRefs{..} Explorer{..} (Pool (OnChain poolOut pool) _) (OnChain orderOut Core.AnyOrder{..}) PoolActions{..} Logging{..} = do
runOrder TxRefs{..} Explorer{..} (Pool (OnChain poolOut pool) version) (OnChain orderOut Core.AnyOrder{..}) PoolActions{..} Logging{..} = do
let
poolOutRef = Interop.fromCardanoTxIn poolV1Ref
poolOutRef = case version of
V1 -> Interop.fromCardanoTxIn poolV1Ref
V2 -> Interop.fromCardanoTxIn poolV2Ref
poolV1RefOuput <- getOutput poolOutRef
case anyOrderAction of
DepositAction deposit -> do
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/ergolabs/cardano-dex-sdk-haskell
tag: bb3299d354e55cec79e2993db9cb8e4a0e796974
tag: f9253ed7aa5a7f6f7d28df8f8c3ff48cfd97359a
subdir:
cardano-tx
ergo-hs-common
Expand Down
6 changes: 3 additions & 3 deletions dcConfigs/dcSpectrumConfig.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ in
, levelOverrides = [] : List { _1 : Text, _2 : LogLevel }
}
, unsafeEval =
{ unsafeTxFee = +310000
, exUnits = 160000000
, exMem = 400000
{ unsafeTxFee = +320000
, exUnits = 165000000
, exMem = 530000
}
}
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
max-size: "200k"
max-file: "10"
spectrum-cardano-backend:
image: spectrumlabs/spectrum-cardano-backend:1.0.0
image: spectrumlabs/spectrum-cardano-backend:1.0.2
volumes:
- spectrum-backend-volume:/data
- ./config/mainnet:/config
Expand Down
2 changes: 1 addition & 1 deletion nix/pkgs/haskell/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let
"https://github.com/input-output-hk/hedgehog-extras"."714ee03a5a786a05fc57ac5d2f1c2edce4660d85" = "6KQFEzb9g2a0soVvwLKESEbA+a8ygpROcMr6bkatROE=";
"https://github.com/ergolabs/cardano-dex-contracts"."c25c8ab7daf52871d29efd00d3dac236cc9d6a36" = "/A2kO/ABqElTxeIcyA2SIqwX9StNLTe5GyE80h+Rf8w=";
"https://github.com/ergolabs/hlog"."f62f1cc1e2ed933d99dfeca8ade634bfe8984ee4" = "YSeEjFPSxbeKkFo+uhDkgMo841DpMygHngY/V07Gj8c=";
"https://github.com/ergolabs/cardano-dex-sdk-haskell"."bb3299d354e55cec79e2993db9cb8e4a0e796974" = "KPK6QxcuHWj3QAbVQNc6kKf6nrk4+DkRZ6ZtFNIJx18=";
"https://github.com/ergolabs/cardano-dex-sdk-haskell"."f9253ed7aa5a7f6f7d28df8f8c3ff48cfd97359a" = "lImv2nALUYhOCZU1DpC4NowUT3jubSX6W2D9wPOzQHA=";
"https://github.com/daleiz/rocksdb-haskell"."109af08f95b40f458d4933e3725ecb3e59337c39" = "1i1ya491fapa0g96527krarv0w0iybizqcz518741iw06hhpikiy";
};

Expand Down