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

build: update for preview 11 #136

Merged
merged 4 commits into from
Oct 6, 2023
Merged

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Sep 19, 2023

  • Pin soroban-cli to latest commit from chore: update ts bindings stellar-cli#973. This PR will be mergeable once a new quickstart image is released and we can verify that its tests pass.
  • Update the contract's SDK version
    • Copy in abundance source from token contract at Changes for the next release soroban-examples#277. Note that I did not author most of the changes in the contracts/abundance folder. I only copied in the changes originally authored by @leighmcculloch, then updated for the single tweak that this abundance contract already had: 1. comments on the mint method; 2. slightly modified mint behavior.
  • New CLI's typescript-bindings-generated libraries export a Contract class, rather than a flat bag of functions. Instantiating these contracts is now taken care of in shared/contracts.ts, with code throughout the rest of the codebase referencing these instances.
  • Instantiating these classes required access to the network and rpcUrl used with the initialize.sh script. NextJS doesn't allow reading the files we already write (like .soroban-example-dapp/network), so for now I've also echod relevant values to a shared/config.json file, which is hidden. This could probably be cleaned up in the future by putting all relevant settings in an .env file, and cleaning up the package.json scripts to use dotenv cross-env or similar.


export interface IDepositsProps {
address: string
decimals: number
name?: string
symbol?: string
idCrowdfund: string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already obsolete; we just missed removing it previously

- Pin soroban-cli to latest commit from
  stellar/stellar-cli#973. This PR will be
  mergeable once a new quickstart image is released and we can verify
  that its tests pass.
- Update the contract's SDK version
  - Copy in abundance source from token contract at "Changes for the next
    release," stellar/soroban-examples#277. Note
    that I did not author most of the changes in the contracts/abundance
    folder. I only copied in the changes originally authored by
    @leighmcculloch, then updated for the single tweak that this
    abundance contract already had: 1. comments on the mint method; and
    2.  slightly modified mint behavior.
- New CLI's typescript-bindings-generated libraries export a `Contract`
  class, rather than a flat bag of functions. Instantiating these
  contracts is now taken care of in `shared/contracts.ts`, with code
  throughout the rest of the codebase referencing these instances.
- Instantiating these classes required access to the `network` and
  `rpcUrl` used with the `initialize.sh` script. NextJS doesn't allow
  reading the files we already write (like `.soroban-example-dapp/network`),
  so for now I've also `echo`d relevant values to a `shared/config.json`
  file, which is hidden. This could probably be cleaned up in the future
  by putting all relevant settings in an `.env` file, and cleaning up
  the package.json scripts to use `dotenv cross-env` or similar.
chadoh added a commit to AhaLabs/soroban-dapps-challenge that referenced this pull request Sep 20, 2023
- copy abundance source from stellar/soroban-example-dapp#136
- pin soroban-cli from stellar/stellar-cli#973
- update everything else as needed
@sreuland sreuland self-requested a review September 20, 2023 21:37
@sreuland
Copy link
Contributor

@chadoh , can probably use the latest commit off quickstart:master of b58a1127ada30a477f49f330e21038426fb272e4 , also, the network config here could now allow running against testnet as well since it's on soroban/p20.

@Julian-dev28
Copy link
Contributor

Just tried this out. Everything is working an no issue to report!

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

@Julian-dev28
Copy link
Contributor

Just tried this out. Everything is working an no issue to report!

I want to point out that I initially tried this out on futurenet which worked with no issues to report. However, after trying it again on standalone, I ran into the error: 'xdr processing error: xdr value invalid.'

@@ -1,7 +1,7 @@
# paths = ["/path/to/override"] # path dependency overrides

[alias] # command aliases
install_soroban = "install --git https://github.com/stellar/soroban-tools --rev cb3c44f9d8080917a7cb019d6be25019f6cf78c3 --root ./target soroban-cli --debug"
install_soroban = "install --git https://github.com/AhaLabs/soroban-tools --rev dc2a543993a293155516df52e79cc120cbd3dfe0 --root ./target soroban-cli --debug"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this use https://github.com/stellar/soroban-tools --rev 20.0.0-rc2 or is there a branch on your fork that needs to be merged back to stellar/soroban-tools?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there's a branch (stellar/stellar-cli#973), see PR description.

This branch is waiting on a quickstart that works with preview 11 + standalone.

The lack of such a quickstart is probably also the cause of your troubles running this on standalone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see, you are referring to the stellar/quickstart:soroban-dev docker image? yes, it's been recently published for preview11 as stellar/quickstart:testing@sha256:1c98f895f8b69cc843eeaa5230d67044dbeb390a5529d51dd7762d8ff685c3f8

@sreuland
Copy link
Contributor

@chadoh , can probably use the latest commit off quickstart:master of b58a1127ada30a477f49f330e21038426fb272e4 , also, the network config here could now allow running against testnet as well since it's on soroban/p20.

I replied here for the quickstart docker version which you were probably more interested in.

on the 'testnet' enablement, that would be adding it as another network choice in initialize.sh and quickstart.sh.

also, in regards to using the preview11 quickstart version, it has deprecated the usage of --standalone in favor of --local instead now, it will print a warning for the former usage. so, it may be good to adjust terminology here to be consistent, i.e. replace 'standalone' with 'local' or should we carve that out to separate ticket?

@chadoh
Copy link
Contributor Author

chadoh commented Sep 24, 2023

I do think that changing all the language from quickstart to local or localnet is a separate issue. Partly because I'm not clear on what the new name is. Just local? Or localnet? Or does it depend on context? Seems like a bike-shed-type change that doesn't need to slow this one down.

I would also prefer the addition of testnet to the options here be a separate PR, too. Is that ok? This one was just meant to get things working with the latest Futurenet, as quickly as possible.

I updated the quickstart image in stellar/stellar-cli#973 and here, and I switched the --standalone flag to --local in the quickstart.sh script. However, you can see that the change to the CLI has a failing build:

Error: Failed to initialize container stellar/quickstart:testing@sha256:1c98f895f8b69cc843eeaa5230d67044dbeb390a5529d51dd7762d8ff685c3f8

@sreuland
Copy link
Contributor

I would also prefer the addition of testnet to the options here be a separate PR, too. Is that ok? This one was just meant to get things working with the latest Futurenet, as quickly as possible.

@chadoh , thanks sounds good.

I updated the quickstart image in stellar/stellar-cli#973 and here, and I switched the --standalone flag to --local in the quickstart.sh script. However, you can see that the change to the CLI has a failing build:

ok, will try out locally, we just need to verify initialize&run of dapp for local and futurenet network types correct?

@sreuland
Copy link
Contributor

@chadoh , that format error from gh workflow is a platform discrepancy of host and image, that sha is pointing at wrong image version actually, you can see earlier in the logs of it downloading the image it reports the issue WARNING: The requested image's platform (linux/arm64) does not match .

So, that's one issue, which needs to get fixed in soroban docs also, as it should be the multi-platform sha instead and needs to be updated to newer build anyways, because, I'm trying the pr locally on an arm64 host for the standalone network, where that image gets past format errors, but errors for real on contract deploys during init due to resource limits on the local network fromquickstart:testing image, the latest build of stellar/quickstart:soroban-dev actually has more recent changes to disable resource limits on that image per stellar/quickstart#492, so, should grab that, and change QUICKSTART_SOROBAN_DOCKER_SHA=stellar/quickstart:soroban-dev and add --pull always to the docker run command in quickstart.sh to make sure getting the latest, this will also allow docker to pull the correct platform image automatically.

I've manually installed latest cli - cargo install [email protected] --root ./target

With that in place , i'm able to run ./quickstart.sh standalone and then NETWORK=standalone npm run reset , init logs that it used my cli -Using soroban binary from ./target/bin and contracts are built/deployed.

but when I run the server - npm run dev i get a js error in browser:

Screen Shot 2023-09-26 at 2 17 55 PM

@chadoh
Copy link
Contributor Author

chadoh commented Sep 28, 2023

@sreuland this one should be working now

@@ -19,7 +19,7 @@ esac

# this is set to the quickstart `soroban-dev` image annointed as the release
# for a given Soroban Release, it is captured on Soroban Releases - https://soroban.stellar.org/docs/reference/releases
QUICKSTART_SOROBAN_DOCKER_SHA=stellar/quickstart:soroban-dev@sha256:a6b03cf6b0433c99f2f799b719f0faadbb79684b1b763e7674ba749fb0f648ee
QUICKSTART_SOROBAN_DOCKER_SHA=stellar/quickstart:soroban-dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had recommended not using pinned version earlier, I think it might be good to re-introduce the pinned version of quickstart though, sorry for churn, the preview11 version of quickstart has changed often as newer rc's coming out, but it looks like rc4 versions of cli/rpc are now in quickstart, and would be best to reference that for now, docker.io/stellar/quickstart:testing@sha256:40636cdb1b9168b47e5dc120949fe3610ff914e8dd43409edb6fa66496bdd9c3 , and avoid regression from latest un-pinned usage, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quickstart:testing or quickstart:soroban-dev?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the quickstart:testing, docker will resolve the same sha from both docker.io/stellar/quickstart:testing@sha256:40636cdb1b9168b47e5dc120949fe3610ff914e8dd43409edb6fa66496bdd9c3 or docker.io/stellar/quickstart@sha256:40636cdb1b9168b47e5dc120949fe3610ff914e8dd43409edb6fa66496bdd9c3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chadoh , one minor cleanup, can you set QUICKSTART_SOROBAN_DOCKER_SHA=docker.io/stellar/quickstart:testing@sha256:40636cdb1b9168b47e5dc120949fe3610ff914e8dd43409edb6fa66496bdd9c3 , then this pr is done, and ready to merge both @Julian-dev28 and I have tested locally as well.

@@ -1,7 +1,7 @@
# paths = ["/path/to/override"] # path dependency overrides

[alias] # command aliases
install_soroban = "install --git https://github.com/stellar/soroban-tools --rev cb3c44f9d8080917a7cb019d6be25019f6cf78c3 --root ./target soroban-cli --debug"
install_soroban = "install --git https://github.com/AhaLabs/soroban-tools --rev c7fb7e08ba8efa9828d9df863d991558f269e35b --root ./target soroban-cli --debug"
Copy link
Contributor

@sreuland sreuland Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chadoh , can this be changed now to use a released version of cli like:

install --root ./target [email protected] --debug

@sreuland
Copy link
Contributor

@sreuland this one should be working now

@chadoh , I tried latest from pr, it's initializing correctly but the dapp in browser is getting different js error:

I did in one terminal:

./quckstart.sh standalone

and in second terminal:

rm -rf ./node-modules
npm install
NETWORK=standalone npm run reset
npm run dev

in browser i get:
Screen Shot 2023-09-28 at 12 51 24 PM

@sreuland
Copy link
Contributor

sreuland commented Sep 29, 2023

@chadoh , I tried latest from pr, it's initializing correctly but the dapp in browser is getting different js error:

@chadoh , I think this error was due to the local 'target' directory on my machine not being wiped as part of dapp init steps so, some older contract was in there, and bindings got generated from that, or at least after purging the target directory and init'ing dapp from npm reset again, this forced new cli, ontract wasm, contract bindings from the wasm to be re-built regardless, and eliminated the error on ts gen code saw earlier, and the dapp loads now.

During investigation, I tried following the steps in README for how to init, and it gets pretty complex with different instructions for different networks, so, I took a small step back and tried to consolidate dapp init to always just be npm run reset, to avoid any old state between dapp restarts, etc and a single way to init regardless of network type.

I put up PR with these suggestions based on your build/preview11 branch, in case you agree the suggestions and want to pull in. AhaLabs/soroban-example-dapp/pull/1

Copy link
Contributor

@sreuland sreuland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chadoh , looks good, I just tested out standalone and futurenet back to back, and both cases worked, the only thing I found was the 'clean' behavior between resets and put up a pr with a suggestion - AhaLabs/soroban-example-dapp/1

@Julian-dev28
Copy link
Contributor

Julian-dev28 commented Oct 2, 2023

@chadoh , looks good, I just tested out standalone and futurenet back to back, and both cases worked, the only thing I found was the 'clean' behavior between resets and put up a pr with a suggestion - AhaLabs/soroban-example-dapp/1

Just tested both cases back to back as well and can confirm this is working

@Julian-dev28 Julian-dev28 merged commit 81a535e into stellar:main Oct 6, 2023
5 checks passed
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 this pull request may close these issues.

5 participants