aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

Enable cargo build cache to be used

Open null-ref-ex opened this issue 2 years ago • 0 comments

🚀 Feature Request

As a node runner operating via source I would like to be able to use the cargo build caching capabilities to reduce both time and server burden when compiling new versions. Currently, the usage of shadow as the means of getting GitHub context details in a source context causes an incorrect hash and version to be present on the compiled binary unless cargo clean is run before hand.

Motivation

Re-compiling already compiled crates which haven't changed between commits is suboptimal, wastes resources and time.

Pitch

A lot of validators operate using the source route, this tends to be bare metal operators which in my opinion is an industry trend that we are seeing mature before us. It provides both optimal costs and optimal performance as compared to VM's and network storage which doesn't provide massive benefit in a decentralized network; it's better to run multiple instances with lower cost than a single high end massively redundant node. To this end, we should enable this mode of operation to be as efficient as possible when it comes to compilation efforts by facilitating usage of the cargo build cache without it causing issues for the mechanism used to verify that node operators are running the correct binary version.

Possible Solutions:

  • Additional cargo build step that produces a json blob at a known location/embedded in binary as a resource for reference to obtain git data.

    • cons: additional complexity
  • Additional cargo build step that sets the environment variable GIT_SHA which is already present in the codebase for usage in a docker runtime context: https://github.com/aptos-labs/aptos-core/blob/86b29874ff68bece908494a8c54ea35ac2cb0c43/crates/aptos-build-info/src/lib.rs#L109

    • pros: leverages existing aptos-build-info code without change

null-ref-ex avatar Oct 14 '22 14:10 null-ref-ex