Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Add Solidity compiler to solana installer #31184

Merged
merged 3 commits into from
May 3, 2023

Conversation

seanyoung
Copy link
Contributor

@seanyoung seanyoung commented Apr 13, 2023

Problem

We would like Solidity to be language which is easy to use, and easy to set up. Anchor now has support for Solidity in the master branch. However, this support depends on the solang binary being available in the path.

I've noticed that asking some developers to download a binary, make it executable and it put somewhere in the path is a big ask. This requires too much shell knowledge. We need an automated way of doing this.

Summary of Changes

This adds the solang binary to the solana installer. The binary is about 58M (depending on the plaform) and compresses down to 17M with bz2. So, the installer is not much larger.

This has been tested on Linux and build is running on my Mac right now. I am not sure how I can test Windows, I can setup a VM but I don't quite understand how this shell script gets executed on Windows.

@mvines
Copy link
Contributor

mvines commented Apr 13, 2023

Coupling solang with the Labs validator client release doesn't feel too good to me. In fact in the glorious future I think it makes sense to move the BPF SDK bits into a separate release from the validator client itself, so adding more developer-related tooling is moving against that grain.

I feel this is better solved directly at the solang level with maybe (?) an easier way to install it directly? But honestly, option 1 and 2 at https://solang.readthedocs.io/en/latest/installing.html don't feel like a big burden.

@seanyoung
Copy link
Contributor Author

Coupling solang with the Labs validator client release doesn't feel too good to me. In fact in the glorious future I think it makes sense to move the BPF SDK bits into a separate release from the validator client itself, so adding more developer-related tooling is moving against that grain.

Separating the BPF SDK makes a lot of sense, and if such a release does exist, then solang should definitely be part of that. For now the BPF SDK lives with the client release, so until that changes having solang there is just a compromise (it's not ideal, I agree).

I feel this is better solved directly at the solang level with maybe (?) an easier way to install it directly? But honestly, option 1 and 2 at https://solang.readthedocs.io/en/latest/installing.html don't feel like a big burden.

I felt the same way, but my experience at hacker houses tells me differently. People get stuck with this, or get it wrong and then don't know what to do. We want folks to have a super-smooth experience when moving from ethereum solidity to solana solidity. Downloading a binary and putting it your path is the opposite of that.

@mvines
Copy link
Contributor

mvines commented Apr 13, 2023

I felt the same way, but my experience at hacker houses tells me differently. People get stuck with this, or get it wrong and then don't know what to do

Really? Do you know what part of "Option 2" people get stuck on? These may not be the devs we're looking for frankly.

But putting that aside, what does it take to build solang from source? Trusting and redistributing binaries from https://github.com/hyperledger/solang/releases/download also feels bad from within scripts/cargo-install-all.sh that currently builds all artifacts from source.

@seanyoung
Copy link
Contributor Author

Really? Do you know what part of "Option 2" people get stuck on? These may not be the devs we're looking for frankly.

From experience the first thing they save it somewhere, then either struggle to add it to their path, or then when they have done that, they miss that they only added to their path in their current terminal, not in other terminals. Also it's lost after a reboot/logout.

Sure, I agree that if a developer struggles with this they may miss some foundational stuff. However:

  • Many devs are pretty specialized and they may be good Solidity devs even though they don't get the shell environment. I certainly spoke to devs who had written very complete eth Solidity contracts with tests, who struggled with this.
  • It's still not a great experience having to do this manually. We want still want Ethereum Solidity developers to have a great experience when they try Solidity on Solana.

But putting that aside, what does it take to build solang from source? Trusting and redistributing binaries from https://github.com/hyperledger/solang/releases/download also feels bad from within scripts/cargo-install-all.sh that currently builds all artifacts from source.

Building solang from source depends on a build of our forked llvm tree with the various Solana patches. I can certainly change the shell script to do this, however:

  • This will dramatically increase build time (adds about 4 hours depending on how fast the build machine is)
  • Increases dependencies (will need various C++ tools like cmake, pkg-config etc)
  • The solana rust compiler and other llvm tools are already downloaded directly from https://github.com/solana-labs/platform-tools/releases, so scripts/cargo-install-all.sh does not build everything from source. This PR is exactly like that.

Copy link
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

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

Hmm, ok.
Since Solana 1.16.0 is unlikely to ship for a month or so, if this needs to be made available to the dev community sooner then we'll need to do backport to v1.14 as well. This seems fine enough given the scope of change.

@dmakarov dmakarov merged commit 1438d9e into solana-labs:master May 3, 2023
@seanyoung seanyoung deleted the solang branch May 3, 2023 14:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants