Agoric / dapp-agoric-basics

This is a simple app for the Agoric smart contract platform.
0 stars 3 forks source link

feat: deploy-contract tooling; e2e testing support #16

Closed dckc closed 4 months ago

dckc commented 4 months ago

closes #15

uses rollup rather than agoric run to bundle core eval scripts

Supporting agoric run within deploy-contract.js is left for future work.

refs

dckc commented 4 months ago

e2e test harness refactored as deployment tool: works in 1 case

So now this is progress on 2 issues:

Recording:

"screenshot":

11 2024-03-06T01:58:58.623679523Z PROPOSAL_STATUS_PASSED                                                                                                                                       
{ step: 'run', propsal: '11', delay: 1 } ...
{ step: 'run', propsal: '11', delay: 1 } ...
{ step: 'run', propsal: '11', delay: 1 } ...
{
  proposal_id: '11',
  content: {
    '@type': '/agoric.swingset.CoreEvalProposal',
    title: 'postal-service',
    description: 'postal-service',
    evals: [ [Object] ]
  },
  status: 'PROPOSAL_STATUS_PASSED',
  final_tally_result: { yes: '5000000000', abstain: '0', no: '0', no_with_veto: '0' },
  submit_time: '2024-03-06T01:58:48.623679523Z',
  deposit_end_time: '2024-03-08T01:58:48.623679523Z',
  total_deposit: [ { denom: 'ubld', amount: '60000000' } ],
  voting_start_time: '2024-03-06T01:58:48.623679523Z',
  voting_end_time: '2024-03-06T01:58:58.623679523Z'
}
dckc commented 4 months ago

deploys mint, swap, pay contracts automatically

yarn start:contract ``` ~/projects/dapp-agoric-basics/contract 18:15 connolly@bldbox$ make start-contract yarn node scripts/deploy-contract.js \ --install src/sell-concert-tickets.contract.js \ --evals src/platform-goals/board-aux.core.js \ src/sell-concert-tickets.proposal.js yarn node v1.22.22 bundles add: sell-concert-tickets from src/sell-concert-tickets.contract.js bundles bundled 141 files in bundle-sell-concert-tickets.js at 2024-03-12T23:15:46.943Z mint 100 IST installing sell-concert-tickets b1-6ab29 $$$ agd tx swingset install-bundle @bundles/bundle-sell-concert-tickets.json --gas auto --keyring-backend test --chain-id agoriclocal --from agoric1ydzxwh6f893jvpaslmaz6l8j2ulup9a7x8qvvq --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 53948577 { id: 'b1-6ab29', installTx: 'F0E1F8617EBD87B053D156DD7FD1D54E0894320789667A7C1F51C318B22C3148', height: '969' } follow { delay: 2 } ... { name: 'sell-concert-tickets', id: 'b1-6ab29', installHeight: '969', installed: true } submit proposal board-aux [ 'bundles/deploy-board-aux-permit.json', 'bundles/deploy-board-aux.js' ] await tx [ 'bundles/deploy-board-aux-permit.json', 'bundles/deploy-board-aux.js' ] $$$ agd tx gov submit-proposal swingset-core-eval bundles/deploy-board-aux-permit.json bundles/deploy-board-aux.js --title board-aux --description board-aux --deposit 10000000ubld --keyring-backend test --chain-id agoriclocal --from agoric1estsewt6jqsx77pwcxkn5ah0jqgu8rhgflwfdl --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 891745 { txhash: 'FB08D9A6ECB3199731628F3D48A80B0BD1F99185DF8A82217DA4C280ED3BB3B2', code: 0, height: '975', gas_used: '633941' } await voteLatestProposalAndWait [ 'bundles/deploy-board-aux-permit.json', 'bundles/deploy-board-aux.js' ] { before: 'deposit', on: '12', delay: 1 } ... $$$ agd tx gov deposit 12 50000000ubld --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 283626 $$$ agd tx gov vote 12 yes --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 93027 Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '12', delay: 1 } ... Waiting for proposal 12 to pass (status=PROPOSAL_STATUS_PASSED) { step: 'voting', on: '12', delay: 1 } ... 12 2024-03-12T23:16:06.981144008Z PROPOSAL_STATUS_PASSED { step: 'run', propsal: '12', delay: 1 } ... { step: 'run', propsal: '12', delay: 1 } ... { step: 'run', propsal: '12', delay: 1 } ... { proposal_id: '12', content: { '@type': '/agoric.swingset.CoreEvalProposal', title: 'board-aux', description: 'board-aux', evals: [ [Object] ] }, status: 'PROPOSAL_STATUS_PASSED', final_tally_result: { yes: '5000000000', abstain: '0', no: '0', no_with_veto: '0' }, submit_time: '2024-03-12T23:15:56.981144008Z', deposit_end_time: '2024-03-14T23:15:56.981144008Z', total_deposit: [ { denom: 'ubld', amount: '60000000' } ], voting_start_time: '2024-03-12T23:15:56.981144008Z', voting_end_time: '2024-03-12T23:16:06.981144008Z' } submit proposal sell-concert-tickets [ 'bundles/deploy-sell-concert-tickets-permit.json', 'bundles/deploy-sell-concert-tickets.js' ] await tx [ 'bundles/deploy-sell-concert-tickets-permit.json', 'bundles/deploy-sell-concert-tickets.js' ] $$$ agd tx gov submit-proposal swingset-core-eval bundles/deploy-sell-concert-tickets-permit.json bundles/deploy-sell-concert-tickets.js --title sell-concert-tickets --description sell-concert-tickets --deposit 10000000ubld --keyring-backend test --chain-id agoriclocal --from agoric1estsewt6jqsx77pwcxkn5ah0jqgu8rhgflwfdl --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 1515130 { txhash: '41D23C8BB67F67F82613351F23F05C08A9F4E111E31DD57B659D09D6E2CAB29C', code: 0, height: '991', gas_used: '1079216' } await voteLatestProposalAndWait [ 'bundles/deploy-sell-concert-tickets-permit.json', 'bundles/deploy-sell-concert-tickets.js' ] { before: 'deposit', on: '13', delay: 1 } ... $$$ agd tx gov deposit 13 50000000ubld --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 435762 $$$ agd tx gov vote 13 yes --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 106857 Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '13', delay: 1 } ... { step: 'voting', on: '13', delay: 1 } ... Waiting for proposal 13 to pass (status=PROPOSAL_STATUS_PASSED) { step: 'voting', on: '13', delay: 1 } ... 13 2024-03-12T23:16:23.148031881Z PROPOSAL_STATUS_PASSED { step: 'run', propsal: '13', delay: 1 } ... { step: 'run', propsal: '13', delay: 1 } ... { step: 'run', propsal: '13', delay: 1 } ... { proposal_id: '13', content: { '@type': '/agoric.swingset.CoreEvalProposal', title: 'sell-concert-tickets', description: 'sell-concert-tickets', evals: [ [Object] ] }, status: 'PROPOSAL_STATUS_PASSED', final_tally_result: { yes: '5000000000', abstain: '0', no: '0', no_with_veto: '0' }, submit_time: '2024-03-12T23:16:13.148031881Z', deposit_end_time: '2024-03-14T23:16:13.148031881Z', total_deposit: [ { denom: 'ubld', amount: '60000000' } ], voting_start_time: '2024-03-12T23:16:13.148031881Z', voting_end_time: '2024-03-12T23:16:23.148031881Z' } Done in 45.58s. yarn node scripts/deploy-contract.js \ --install src/swaparoo.contract.js \ --evals src/swaparoo.proposal.js yarn node v1.22.22 bundles bundle-swaparoo.js valid: 158 files bundled at 2024-03-12T23:15:55.863Z mint 100 IST installing swaparoo b1-013d4 $$$ agd tx swingset install-bundle @bundles/bundle-swaparoo.json --gas auto --keyring-backend test --chain-id agoriclocal --from agoric1ydzxwh6f893jvpaslmaz6l8j2ulup9a7x8qvvq --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 59387026 { id: 'b1-013d4', installTx: '362823A7E3454C83C41AA5C4D643522EF6AC24603E946707C366F44AE41323EC', height: '1011' } follow { delay: 2 } ... { name: 'swaparoo', id: 'b1-013d4', installHeight: '1011', installed: true } submit proposal swaparoo [ 'bundles/deploy-swaparoo-permit.json', 'bundles/deploy-swaparoo.js' ] await tx [ 'bundles/deploy-swaparoo-permit.json', 'bundles/deploy-swaparoo.js' ] $$$ agd tx gov submit-proposal swingset-core-eval bundles/deploy-swaparoo-permit.json bundles/deploy-swaparoo.js --title swaparoo --description swaparoo --deposit 10000000ubld --keyring-backend test --chain-id agoriclocal --from agoric1estsewt6jqsx77pwcxkn5ah0jqgu8rhgflwfdl --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 1317751 { txhash: '40A88C720B3FA7AAB055D0CDF64A8268FAF9E4104010454DD217A9B4E9C9824E', code: 0, height: '1014', gas_used: '938231' } await voteLatestProposalAndWait [ 'bundles/deploy-swaparoo-permit.json', 'bundles/deploy-swaparoo.js' ] { before: 'deposit', on: '14', delay: 1 } ... $$$ agd tx gov deposit 14 50000000ubld --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 387945 $$$ agd tx gov vote 14 yes --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 102510 Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '14', delay: 1 } ... Waiting for proposal 14 to pass (status=PROPOSAL_STATUS_PASSED) { step: 'voting', on: '14', delay: 1 } ... 14 2024-03-12T23:16:48.096790298Z PROPOSAL_STATUS_PASSED { step: 'run', propsal: '14', delay: 1 } ... { step: 'run', propsal: '14', delay: 1 } ... { step: 'run', propsal: '14', delay: 1 } ... { proposal_id: '14', content: { '@type': '/agoric.swingset.CoreEvalProposal', title: 'swaparoo', description: 'swaparoo', evals: [ [Object] ] }, status: 'PROPOSAL_STATUS_PASSED', final_tally_result: { yes: '5000000000', abstain: '0', no: '0', no_with_veto: '0' }, submit_time: '2024-03-12T23:16:38.096790298Z', deposit_end_time: '2024-03-14T23:16:38.096790298Z', total_deposit: [ { denom: 'ubld', amount: '60000000' } ], voting_start_time: '2024-03-12T23:16:38.096790298Z', voting_end_time: '2024-03-12T23:16:48.096790298Z' } Done in 23.82s. yarn node scripts/deploy-contract.js \ --install src/postal-service.contract.js \ --evals src/postal-service.proposal.js yarn node v1.22.22 bundles bundle-postal-service.js valid: 130 files bundled at 2024-03-12T23:15:56.827Z mint 100 IST installing postal-service b1-6a5e7 $$$ agd tx swingset install-bundle @bundles/bundle-postal-service.json --gas auto --keyring-backend test --chain-id agoriclocal --from agoric1ydzxwh6f893jvpaslmaz6l8j2ulup9a7x8qvvq --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 51163581 { id: 'b1-6a5e7', installTx: '0FC2E97DC5D1BFCD043D56C6DFF1B6743143AECD0F728B31224D27CDF6136AA6', height: '1034' } follow { delay: 2 } ... { name: 'postal-service', id: 'b1-6a5e7', installHeight: '1034', installed: true } submit proposal postal-service [ 'bundles/deploy-postal-service-permit.json', 'bundles/deploy-postal-service.js' ] await tx [ 'bundles/deploy-postal-service-permit.json', 'bundles/deploy-postal-service.js' ] $$$ agd tx gov submit-proposal swingset-core-eval bundles/deploy-postal-service-permit.json bundles/deploy-postal-service.js --title postal-service --description postal-service --deposit 10000000ubld --keyring-backend test --chain-id agoriclocal --from agoric1estsewt6jqsx77pwcxkn5ah0jqgu8rhgflwfdl --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 1472458 { txhash: 'CCBC4672FD8864EE4C145FA3079CC6B44C7BCCA185F255C727066DC281CF80DC', code: 0, height: '1037', gas_used: '1048490' } await voteLatestProposalAndWait [ 'bundles/deploy-postal-service-permit.json', 'bundles/deploy-postal-service.js' ] { before: 'deposit', on: '15', delay: 1 } ... $$$ agd tx gov deposit 15 50000000ubld --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 425506 $$$ agd tx gov vote 15 yes --keyring-backend test --chain-id agoriclocal --from validator --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json gas estimate: 105925 Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_VOTING_PERIOD) { step: 'voting', on: '15', delay: 1 } ... Waiting for proposal 15 to pass (status=PROPOSAL_STATUS_PASSED) { step: 'voting', on: '15', delay: 1 } ... 15 2024-03-12T23:17:12.009733713Z PROPOSAL_STATUS_PASSED { step: 'run', propsal: '15', delay: 1 } ... { step: 'run', propsal: '15', delay: 1 } ... { step: 'run', propsal: '15', delay: 1 } ... { proposal_id: '15', content: { '@type': '/agoric.swingset.CoreEvalProposal', title: 'postal-service', description: 'postal-service', evals: [ [Object] ] }, status: 'PROPOSAL_STATUS_PASSED', final_tally_result: { yes: '5000000000', abstain: '0', no: '0', no_with_veto: '0' }, submit_time: '2024-03-12T23:17:02.009733713Z', deposit_end_time: '2024-03-14T23:17:02.009733713Z', total_deposit: [ { denom: 'ubld', amount: '60000000' } ], voting_start_time: '2024-03-12T23:17:02.009733713Z', voting_end_time: '2024-03-12T23:17:12.009733713Z' } Done in 23.82s. ```
dckc commented 4 months ago

Cleaning this up is reaching a point of diminishing returns...

dckc commented 4 months ago

thanks for trying it out...

When I ran yarn start:contract I got the following error:

Error#1: controller refused message admission: 201250000uist is smaller than 2312200000uistact.js:114:5)

Looks like we need to mint more IST?

201.25 IST should be plenty. That 2312.2 IST corresponds to a pathologically large bundle:

IST IST / Kb Kb / Mb Mb
2312.2 0.02 1024 112.9

What does yarn test test/test-build-proposal.js say? It tests that bundles, when compressed, are <0.5Mb

I get:

  ✔ bundles from build:deployer meet 1MB request limit (1.9s)
    ℹ {
        bundleName: 'postal-service',
        compressedSize: '0.277 MB',
        originallySize: '1.064 MB',
      }
    ℹ {
        bundleName: 'sell-concert-tickets',
        compressedSize: '0.291 MB',
        originallySize: '1.123 MB',
      }
    ℹ {
        bundleName: 'swaparoo',
        compressedSize: '0.322 MB',
        originallySize: '1.236 MB',
      }
LuqiPan commented 4 months ago

Bundle compressing seems to be working as expected:

yarn test test/test-build-proposal.js
yarn run v1.22.21
$ yarn workspaces run test test/test-build-proposal.js

> agoric-basics-contract
$ ava --verbose test/test-build-proposal.js

bundles bundle-postal-service.js valid: 134 files bundled at 2024-03-13T21:03:02.648Z
bundles bundle-sell-concert-tickets.js valid: 139 files bundled at 2024-03-13T19:31:55.227Z
bundles bundle-swaparoo.js valid: 162 files bundled at 2024-03-13T21:03:02.018Z
  ✔ bundles from build:deployer meet 1MB request limit (2.2s)
    ℹ {
        bundleName: 'postal-service',
        compressedSize: '0.277 MB',
        originallySize: '1.080 MB',
      }
    ℹ {
        bundleName: 'sell-concert-tickets',
        compressedSize: '0.285 MB',
        originallySize: '1.103 MB',
      }
    ℹ {
        bundleName: 'swaparoo',
        compressedSize: '0.321 MB',
        originallySize: '1.251 MB',
      }
  ─
dckc commented 4 months ago

Bundle compressing seems to be working as expected:

        bundleName: 'sell-concert-tickets',
        compressedSize: '0.285 MB',
        originallySize: '1.103 MB',

@LuqiPan try the refinement I just pushed, please? It logs the size of the bundle at install-time:

installing sell-concert-tickets b1-4da2a 1.178 Mb
$$$ agd tx swingset install-bundle @bundles/bundle-sell-concert-tickets.json --gas auto --keyring-backend test --chain-id agoriclocal --from agoric1ydzxwh6f893jvpaslmaz6l8j2ulup9a7x8qvvq --broadcast-mode block --gas auto --gas-adjustment 1.4 --yes --output json
dckc commented 4 months ago

... I'd also ask for more documentation on the tools directory. ... Also what is the concept of -goals? ... Consider a tools/README.md to explain

added 3 READMEs.

LuqiPan commented 3 months ago

Well, I finally found out why I'm getting this error- my local docker's latest tag is no longer pointing at the actual latest tag from ghcr.io.

I ran a docker prune system --all and then re-pull the latest tag and that fixed it. On retrospective I could probably just untag the image locally and pull again.

dckc commented 3 months ago

Thanks for getting to the bottom of that.

I think we talked about a flag in docker-compose.yml that makes it more likely that you'll be current, but I don't recall the details. Maybe you want to open an issue in dapp-offer-up (and/or dapp-agoric-basics)?