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

Different lovelace amount on wallet creation in PAB Simulator #17

Closed
manonthemat opened this issue Sep 19, 2021 · 1 comment · Fixed by #291
Closed

Different lovelace amount on wallet creation in PAB Simulator #17

manonthemat opened this issue Sep 19, 2021 · 1 comment · Fixed by #291

Comments

@manonthemat
Copy link

Area

Plutus Application Framework Related to the Plutus application backend (PAB), emulator, Plutus libraries

Summary

The default config of the simulator creates 10 wallets with 100000000000 lovelaces each.
However, manually created wallets get 10000000000 lovelaces (tested for up to 4 extra wallets).

Steps to reproduce

Using the PAB Simulator from the plutus-starter (version 1.0.9, commit: a85818c27926f34d627225636f463cc6698706fc), I'm getting some odd behavior in terms of wallet creation.

I've created a simple contract (GiftContract) and use a shell script to create four wallets. I have not changed the main function within the pab/Main.hs.

Yet, I am getting this output after shutting down the PAB via hitting return.

[INFO]     {, ""}: 59999999960
[INFO] Wallet 36cb1d44654c33ed6b26cbe2da0848de2ebfdb20010679a06c5f609c474f349b8003380446e9159a34504f9fd19da3e93f215efa30cae9455d441be0eac8db66291a5a5e8c961f9da5fb8cb616ab630a6600f4a44acd520fa701b330849e4446d7d1711ac606ae93a2b3d457dd7f4f36b3af92dd0de82a7caf471fb5ed2b5ea3: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet 3e983a2291ed95a079bfbbf1c447180c90241c6eb288ca1d7fa9f3a4f1f4879e1d5b3a2dcc7f6a4207c71987e38a66172d5111c8ef874408f786cafba51a74fc2b68037bbb9a4507f9268eea9fc89e8035fa867020d74f16bc9dc65cc8bd876798585d84f5bd641ec9fa6e44be139edbbab1d6fefb42a303415903e79fe19738: 
[INFO]     {, ""}: 10000000000
[INFO] Wallet 562f269ac4ce35c9be75343cb9d76b3149d1ea5a509299204de6b61dfec1908ec7a4aeed5057be46ff9881d276f9b4050acf9fbc68b61708e33f64db34f479bddd497ff6d3a59aadc10782de888dc139213f444fe7af7b469cab15d50e1cb6d58fba680762c1963f345178e1a7daf62c2eac026b62ceba08c1c5020326d75c20: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet 7628f55f34ca6d864c05aae491e67a5cc0998c4e9461d716fa728fefa837058e3adcc42d910d0404fbddaa157f4d0869f2863faf6cc706eae8eafd204af69a33bd3f819a795f4f7388759a4355436e7bddebbdc14a903df8e4ee733d98616cade35c741d39593e68ea7e331bb145f032cf704ed6d1324d9647ecc1aaaee4f7e8: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet 76d5e1291d51f16eb442267faccd0ab51a3b0c4a21eb6b8f72d5f0a4ca467189ac5f70a018c6df3f632b48fd8ead1b68f39a44de06f5a5de42a6a131af0f085d44becd56fa30041efea5ff2637205181837dffd03545d3db1c11e6dcbbd3415ce8f85aad41776b99eb62a797b8c5abbe82061e1634efc4c7d5ac6fff3ca94d7f: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet 7e203f38109d82c064e95ff2008d84cf6f5c95ec5dbea86d24f407011f65e3868232a16b2bdab56ccff3ab77e24b6a5c88291dd6519b32943fe85ec52c7e6ffe4ab780e3653ceefb79a9e697805ccd430501b09b9a932def195173d96c91013c8b2e8b948109b07a0cae8725f7a8b2b4a892954971891425b4ef3b2eec05f9a1: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet 86c4c1d06a6cd0480865a836fafd97daeba7c79bdc043dff34f9d4553c026e831a4a36760c1d8a0a5458efcb33394ce936b139549570e0f2e80739d50abb6402fcd5201fc11e20cdba72c7440a5e406d314cd1f63fa1d87c83881e0dc1fe3ac5bf6f6a576cf7c56f8d46926bcd24b7de630455a7df7cebb0afadce72d1ede55c: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet 86c6ea24ce790fd9e422a3d22fa6cbc4cf72802675f40b8e2783b4cf38bd4a89a20ee5f32e19499768d274044f825d7251d2bf05c0ce85bfd183127b87376acf115f3ee432684888a2a7b059ba6bffedded97918daf53582e3790082d62856450d8e0efdd7e7b81bcba6c333bb10af271637a9c781d8788db7dc8a8a30763b7e: 
[INFO]     {, ""}: 10000000000
[INFO] Wallet b6d40a76f3fd73233a7e0c52a1bb99174151b3643f462016b8b39f776acd4081429729fd15129139332ede3e94ac805090d6e80b78e187ea85c29012c7b4f4b6e9929aa98f85a5d3173cfc128f4198c437ee3484f676ae741412698a00603111c2b887a0b36c23620aca53026dddc27a4c078aec919e739e2b81bb2f729c5943: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet c6794804ca7d19368487af2aa7324296b34274cc69137d1c6187b18a2cb2ce873cb2519aee42967cb4e9661fb3cd106dd68158f16bdfc9b4da04046d06c9d5accaafea24be9b96b417e47d713c3481db821bce2dab3d4bee156d4ef80b249310f227a7eaefdc7a311ea4c93437610d16b02119e4300778573d96107e829035d7: 
[INFO]     {, ""}: 10000000000
[INFO] Wallet ce5bf0869d6720212e4dcf3ea6992cf4a9b88c39261fd9d6a635f046a17da49b6125ba6748c542e5821ec9d1e9d2f0564bc7572c1ec0e1a82cce88951dec70639e228ed6586bd2946247d66f88fac7e266a9cf37ab49ef1b9b17befd34a3db085e5af768f7297f0e1138220378a2d13c470da5a79639d8313911adeb0436d91e: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet e6778caeed9911d9b0b49f4fd026052395b6b7025b016052c7ca937e8f332e82338bbe4abdb5d91b348b8361c04117e538f8e6c98f716354837ec822b970419f61636d94a191bc8efbe1e7b53ef59d7b77c67adeb5a3f11fe754ee5ce407045f0da5b9850ac337f62d3bacbbd5ec336736dcb26dcebdea6fb5620b3e4837d177: 
[INFO]     {, ""}: 100000000000
[INFO] Wallet e6a9e1d3c75218fe4658682642498ddc2de21d4c852985d86aa574642e4aa98332ee626af31520ec3a6425bfb19492f04bdf09e0a1c9d17c32712870f4649acc8c6ef7b2d2ac09cfbdf8b9894393f8cfd6375a9380864d7003dd52c022e81b449459eccd92f62fb1797abf4dd421772635497fd195a4fd0263a4f1c0d4f64f3c: 
[INFO]     {, ""}: 10000000000

As you can see, we have our 10 regular wallets with a balance of 100,000,000,000 lovelaces each. Yet, there is also three wallets with a balance of 10,000,000,000 lovelaces each and a wallet of 59,999,999,960 lovelaces. The sum of those last wallets minus 4 * 10 lovelaces fee (for creation?) would add up to 100,000,000,000 lovelaces (the value of one default simulator wallet), but it is not intuitive nor did I find any documentation on this behavior.

I have followed the plutus-starter readme to create the wallets and activate the contracts in this manner:

input-output-hk/plutus#1/bin/sh
export W1=`curl -s -d '' http://localhost:9080/wallet/create | jq '.wiWallet.getWalletId'`
export W2=`curl -s -d '' http://localhost:9080/wallet/create | jq '.wiWallet.getWalletId'`
export W3=`curl -s -d '' http://localhost:9080/wallet/create | jq '.wiWallet.getWalletId'`
export W4=`curl -s -d '' http://localhost:9080/wallet/create | jq '.wiWallet.getWalletId'`

export W1_IID=$(curl -s -H "Content-Type: application/json" -X POST -d '{"caID": "GiftContract", "caWallet":{"getWalletId": '$W1'}}' http://localhost:9080/api/contract/activate | jq .unContractInstanceId | tr -d '"')
export W2_IID=$(curl -s -H "Content-Type: application/json" -X POST -d '{"caID": "GiftContract", "caWallet":{"getWalletId": '$W2'}}' http://localhost:9080/api/contract/activate | jq .unContractInstanceId | tr -d '"')
export W3_IID=$(curl -s -H "Content-Type: application/json" -X POST -d '{"caID": "GiftContract", "caWallet":{"getWalletId": '$W3'}}' http://localhost:9080/api/contract/activate | jq .unContractInstanceId | tr -d '"')
export W4_IID=$(curl -s -H "Content-Type: application/json" -X POST -d '{"caID": "GiftContract", "caWallet":{"getWalletId": '$W4'}}' http://localhost:9080/api/contract/activate | jq .unContractInstanceId | tr -d '"')

To make things more explainable, is there a way for me to disable the automatic creation of the 10 wallets and instead pass how many lovelaces I want the manually created wallets to start with?

Expected behavior

Wallets created by hitting the /wallet/create endpoint should have the same amount of lovelaces as the default wallets.

System info (please complete the following information):

  • OS: Arch Linux
  • Version 5.14.3-arch1-1
  • Plutus version 1.0.9 (plutus-starter a85818c27926f34d627225636f463cc6698706fc)

Screenshots and attachments

Additional context

The previous Plutus-Starter version worked as expected (with varying curl commands).

@michaelpj michaelpj transferred this issue from IntersectMBO/plutus Oct 21, 2021
@ghost
Copy link

ghost commented Jan 31, 2022

The reason behind this is that mock wallets are created with funds transferred from the second known wallet:

https://github.com/input-output-hk/plutus-apps/blob/5ffdb6362b9ba3e7095beccde56df0280abf12d0/plutus-pab/src/Cardano/Wallet/Mock/Handlers.hs#L138-L142

I don't know if there is a better way for this scenario.

But I agree it would be nice to be able to configure the wallet's funds.

@ghost ghost self-assigned this Feb 2, 2022
@ghost ghost closed this as completed in #291 Feb 2, 2022
ghost pushed a commit that referenced this issue Feb 2, 2022
* Allow to create a new wallet with the provided funds (#17).

* remove useless import
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant