Skip to content

Commit

Permalink
Merge #2508
Browse files Browse the repository at this point in the history
2508: Introduce separate shared state r=paweljakubas a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue that this PR relates to and which requirements it tackles. Jira issues of the form ADP- will be auto-linked. -->
adp-685

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have introduced SharedState
- [x] I have added impl of newSharedState and extendSharedState
- [x] I have added updating shared state functions 
- [x] I have added isShared
- [x] I have added property tests
- [x] I have removed script state from SeqState and cleaned unit testing, sqlite
- [x] Add design docs in specification dir
- [x] I have dealt with migration of the removal

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


Co-authored-by: Pawel Jakubas <[email protected]>
Co-authored-by: IOHK <[email protected]>
Co-authored-by: KtorZ <[email protected]>
  • Loading branch information
4 people authored Mar 8, 2021
2 parents f4d697a + c2f14e8 commit da099bf
Show file tree
Hide file tree
Showing 21 changed files with 1,212 additions and 950 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do
}|]
r <- request @AnyAddress ctx Link.postAnyAddress Default payload
expectResponseCode HTTP.status400 r
let msg = "The script is ill-formed and is not going to be accepted by ledger."
let msg = "The script is ill-formed and is not going to be accepted by the ledger."
expectErrorMessage msg r

it "ANY_ADDRESS_POST_15c - at_least 4 is not valid when validation is recommended" $ \ctx -> do
Expand All @@ -759,7 +759,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do
}|]
r <- request @AnyAddress ctx Link.postAnyAddress Default payload
expectResponseCode HTTP.status400 r
let msg = "The script is ill-formed and is not going to be accepted by ledger."
let msg = "The script is ill-formed and is not going to be accepted by the ledger."
expectErrorMessage msg r

it "ANY_ADDRESS_POST_16a - script with duplicated verification keys is valid when non-validated" $ \ctx -> do
Expand Down Expand Up @@ -872,7 +872,7 @@ spec = describe "SHELLEY_ADDRESSES" $ do
}|]
r <- request @AnyAddress ctx Link.postAnyAddress Default payload
expectResponseCode HTTP.status400 r
let msg = "Some timelocks used are redundant (which is not recommended)."
let msg = "The timelocks used are contradictory when used with 'all' (which is not recommended)."
expectErrorMessage msg r

it "POST_ACCOUNT_01 - Can retrieve account public keys" $ \ctx -> runResourceT $ do
Expand Down
5 changes: 3 additions & 2 deletions lib/core/cardano-wallet-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ library
Cardano.Wallet.Primitive.Slotting
Cardano.Wallet.Primitive.AddressDiscovery.Random
Cardano.Wallet.Primitive.AddressDiscovery.Sequential
Cardano.Wallet.Primitive.AddressDiscovery.Shared
Cardano.Wallet.Primitive.AddressDiscovery.Script
Cardano.Wallet.Primitive.SyncProgress
Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobin
Cardano.Wallet.Primitive.Model
Cardano.Wallet.Primitive.Scripts
Cardano.Wallet.Primitive.Types
Cardano.Wallet.Primitive.Types.Address
Cardano.Wallet.Primitive.Types.Coin
Expand Down Expand Up @@ -346,10 +347,10 @@ test-suite unit
Cardano.Wallet.Primitive.AddressDerivationSpec
Cardano.Wallet.Primitive.AddressDiscovery.RandomSpec
Cardano.Wallet.Primitive.AddressDiscovery.SequentialSpec
Cardano.Wallet.Primitive.AddressDiscovery.SharedSpec
Cardano.Wallet.Primitive.AddressDiscoverySpec
Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobinSpec
Cardano.Wallet.Primitive.ModelSpec
Cardano.Wallet.Primitive.ScriptsSpec
Cardano.Wallet.Primitive.Slotting.Legacy
Cardano.Wallet.Primitive.SlottingSpec
Cardano.Wallet.Primitive.SyncProgressSpec
Expand Down
5 changes: 3 additions & 2 deletions lib/core/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ createIcarusWallet
, PaymentAddress n k
, k ~ IcarusKey
, s ~ SeqState n k
, Typeable n
)
=> ctx
-> WalletId
Expand All @@ -617,7 +618,6 @@ createIcarusWallet ctx wid wname credentials = db & \DBLayer{..} -> do
(Seq.pendingChangeIxs s)
(Seq.rewardAccountKey s)
(Seq.derivationPrefix s)
(Seq.scriptPool s)
now <- lift getCurrentTime
let meta = WalletMetadata
{ name = wname
Expand Down Expand Up @@ -2015,7 +2015,8 @@ derivePublicKey ctx wid role_ ix = db & \DBLayer{..} -> do

-- NOTE: Alternatively, we could use 'internalPool', they share the same
-- account public key.
let acctK = Seq.accountPubKey $ Seq.externalPool $ getState cp
let (Seq.ParentContextUtxoExternal acctK) =
Seq.context $ Seq.externalPool $ getState cp
let addrK = deriveAddressPublicKey acctK role_ addrIx

return addrK
Expand Down
4 changes: 4 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ postAccountWallet
, WalletKey k
, HasWorkerRegistry s k ctx
, IsOurs s RewardAccount
, Typeable n
)
=> ctx
-> MkApiWallet ctx s w
Expand Down Expand Up @@ -938,6 +939,7 @@ postIcarusWallet
, k ~ IcarusKey
, HasWorkerRegistry s k ctx
, PaymentAddress n IcarusKey
, Typeable n
)
=> ctx
-> ByronWalletPostData '[12,15,18,21,24]
Expand All @@ -958,6 +960,7 @@ postTrezorWallet
, k ~ IcarusKey
, HasWorkerRegistry s k ctx
, PaymentAddress n IcarusKey
, Typeable n
)
=> ctx
-> ByronWalletPostData '[12,15,18,21,24]
Expand All @@ -978,6 +981,7 @@ postLedgerWallet
, k ~ IcarusKey
, HasWorkerRegistry s k ctx
, PaymentAddress n IcarusKey
, Typeable n
)
=> ctx
-> ByronWalletPostData '[12,15,18,21,24]
Expand Down
Loading

0 comments on commit da099bf

Please sign in to comment.