oasisprotocol / oasis-core

Performant and Confidentiality-Preserving Smart Contracts + Blockchains
https://oasisprotocol.org
Apache License 2.0
332 stars 109 forks source link

Revamp synchronized management of Rust- and non-Rust dependencies for contracts #16

Closed ryscheng closed 6 years ago

ryscheng commented 6 years ago

Ekiden, as a library, doesn't fit neatly into Cargo, because it needs to provide some non-Rust resources to dependent contracts, and Cargo does not naturally manage non-Rust resources. These non-Rust dependencies include, for example Makefile.toml files, EDL files from the Rust SGX SDK, and miscellaneous enclave signing configuration files.

We have currently been delivering these non-Rust dependencies through a Git submodule. However, this solution of using both Cargo and Git submodules has some undesirable properties, compared to a hypothetical ideal build system (HIBS):

This issue identifies several ways our build system falls short of HIBS and asks that we bring our build system closer to HIBS. We have collected some proposals for achieving this, which for example involve getting rid of the submodules and further extending our Makefile.toml's and adding additional scripts to be run by Cargo.

(previous title and description below)


Remove need for git submodule from contract repos

Currently there's a possibility that the ekiden git submodule in the contract repo is out of sync with Cargo.toml.

The only reason we need this is to extend the Makefile, proposal is to replace the git submodule with a script that fetches the correct Makefile based on the ekiden version in cargo.toml

I acknowledge that our build system can pose issues to beginners and that it would be nice to minimize possible complications in onboarding and that doing so may involve changes to our build system. As we move forward with this revamp, I want us to keep in mind some things that our build system does well and that an ideal build system would do well too.


If everything could be provided in crates, I think Cargo can handle these use cases because it supports dependency overrides.

It is easy to make changes to Ekiden while working on a contract and test changes together. This is important when, in the course of developing a contract, you find a bug in Ekiden and want to fix it and verify that the fix resolves the problem.

The canonical way to handle these is the [patch] section. Also see documentation on overriding dependencies which specifically mentions this scenario (you find a bug in an upstream create or you even need to add a feature to the upstream crate).

It is possible to have CI build a contract with a modified version of Ekiden without having that modified version be approved and merged into master.

As long as the CI can fetch the modified version of Ekiden, this can also be achieved with the patch method above. You just need to specify the repository containing your patched version of Ekiden and it will be used.

The build process is satisfactorily decoupled from the conceptually separate systems of version control and code repository hosting. It is reasonably easy to make a fork of Ekiden, even if that fork were never to be distributed publicly or never to be managed with Git or to be distributed as a source archive.

The same applies to the patch method as you can specify local paths in case you are not using Git.

Another question is how to distribute binaries like the compute and consensus nodes? Should we just cargo install them?

kostko commented 6 years ago

So as of #77 we've simplified the way we do external contracts as we basically use our contract builder (part of ekiden-tools) for building contracts, so there is no need to fetch any makefiles or use any Git submodules.

The only thing that currently still needs to be fetched separately is the sgx-enter.sh script (and the hw-mode counterpart). This could be further improved as described in #80.

ryscheng commented 6 years ago

Great. Let's close this for now