Skip to content

Commit

Permalink
Refactor rust tree into lib (#1903)
Browse files Browse the repository at this point in the history
* Fix typo in clang dockerfile (#1842)

* Update PULL_REQUEST_TEMPLATE.md

* mingw fixes for bcrypt, suppress depends related warnings  (#1847)

* Suppress depends related superfluous warnings

* Fix passthrough string quote

* Fix windres, bcrypt failures

* Cleanup build process and workflows (#1851)

* Suppress depends related superfluous warnings

* Fix passthrough string quote

* Fix windres, bcrypt failures

* Cleanup build, workflows, dockerfiles

* Cleanup comments

* Refactor default var setup

* Cleanup comments

* Add safe_rm_rf and simplify left file list

* Fix shellcheck

* Fix arm core images

* More cleanup, unify packaging, safer rm

* Apply default conf across all arch, conf args append

* Apply glibc compat only on linux builds

* Clean up obsolete comments

* Cleanup unmaintained deps, configs and tools (#1855)

* Suppress depends related superfluous warnings

* Fix passthrough string quote

* Fix windres, bcrypt failures

* Cleanup build, workflows, dockerfiles

* Cleanup comments

* Refactor default var setup

* Cleanup comments

* Add safe_rm_rf and simplify left file list

* Fix shellcheck

* Fix arm core images

* More cleanup, unify packaging, safer rm

* Apply default conf across all arch, conf args append

* Apply glibc compat only on linux builds

* Clean up obsolete comments

* Cleanup unmaintained files

* Remove install.md

* Remove libdeficonsensus dyn lib, defi-wallet

* Enable static linking

* Revert boost changes

* Remove outdated man pages

* Remove debian packaging related file

* Bump boost min to 1.77, remove obsolete checks

* Revert boost config cleanup

* More cleanups, nsis, gitian

* Remove boost reduce exports change

* Cleanup boost obsolete check

* Remove wallet tool test

* Update toolchains, deps and further cleanup (#1857)

* Suppress depends related superfluous warnings

* Fix passthrough string quote

* Fix windres, bcrypt failures

* Cleanup build, workflows, dockerfiles

* Cleanup comments

* Refactor default var setup

* Cleanup comments

* Add safe_rm_rf and simplify left file list

* Fix shellcheck

* Fix arm core images

* More cleanup, unify packaging, safer rm

* Apply default conf across all arch, conf args append

* Apply glibc compat only on linux builds

* Clean up obsolete comments

* Cleanup unmaintained files

* Remove install.md

* Remove libdeficonsensus dyn lib, defi-wallet

* Enable static linking

* Revert boost changes

* Remove outdated man pages

* Remove debian packaging related file

* Bump boost min to 1.77, remove obsolete checks

* Revert boost config cleanup

* More cleanups, nsis, gitian

* Remove boost reduce exports change

* Cleanup boost obsolete check

* Reorganize scripts, merge share and contrib

* Fix docker script

* Remove wallet tool test

* static libgcc, disable tests and benches on CI builds

* Fix CI builds to use consistent compilers

* Better consistency in toolchains

* Remove cdrkit, libdmg and switch to docker multiplatform base

* Update cppcheck version

* Switch libdeficonsensus to internal, toolchain cleanups  (#1860)

* Cleanup deps

* Switch libdeficonsensus to an internal lib

* Update ubuntu bases

* Update darwin llvm to 16, update cctools and all depends (#1862)

* Update toolchains

* Remove obsolete zeromq patches

* Make libtapi path agnostic of version

* Update XCode SDK

* Rename target to x86_64-apple-darwin

* Revert to older behavior of zeromq

* Remove superfluous LIBADD

* Couple LDFLAGS together

* Skip unrecognized flag on clang

* Fix unintended quote

* Overhaul of build, CI tests and lints, packaging and deps (#1880)

* Fix spv out of tree builds

* Sync dockerignore and gitignore

* Overhaul of builds (to out of tree), deps updates, simplify dockefiles, CI test, lints and more

* Uncomment benchmark code, disable with flags instead

* Resolve compiler warnings

* Fix arm64 crc intrinsics flags

* Minor CI updates and docker login fixes

* Add `--prefix` into configure to workaround surviving config.sub rechecks

* Update ignores (#1888)

* Fixes for make.sh undeclared locals and clean-artifacts (#1887)

* Fix local decls in make.sh

* Fix lints

* Actually fix lints

* Move rust crate to lib

* Fix CI lib path

* Fix Cargo fmt

* Revert the bench change

* Switch to stable toolchain and x64 platform

* Fix stable toolchain

---------

Co-authored-by: Shoham Chakraborty <[email protected]>
Co-authored-by: jouzo <[email protected]>
  • Loading branch information
3 people authored Apr 13, 2023
1 parent 5af36f2 commit 5f93587
Show file tree
Hide file tree
Showing 53 changed files with 66 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Tests - EVM
name: Tests - Rust

on:
push:
paths: [ src/rust/** ]
paths: [ lib/** ]

pull_request:
paths: [ src/rust/** ]
paths: [ lib/** ]

jobs:
lint_cargo_fmt:
Expand All @@ -17,16 +17,15 @@ jobs:
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
toolchain: stable
default: true
override: true
components: rustfmt, clippy

- run: |
cd src/rust
cd lib
cargo fmt --all -- --check
lint_cargo_clippy:
name: Lint (cargo clippy)
runs-on: ubuntu-latest
Expand All @@ -40,16 +39,15 @@ jobs:
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
toolchain: stable
default: true
override: true
components: rustfmt, clippy

- run: |
cd src/rust
cd lib
cargo clippy
test_cargo:
name: Test (cargo)
runs-on: ubuntu-latest
Expand All @@ -63,12 +61,11 @@ jobs:
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
toolchain: stable
default: true
override: true
components: rustfmt, clippy

- run: |
cd src/rust
cd lib
cargo test --no-fail-fast
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ case $host in
;;
esac

AC_CONFIG_FILES([Makefile src/Makefile src/rust/Makefile test/config.ini])
AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile test/config.ini])
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions lib/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CARGO ?= cargo

TARGET ?= $(RUST_TARGET)
TARGET ?= x86_64-unknown-linux-gnu

.PHONY:
all: build-ain-rs-exports build-ain-grpc


# TODO: assumes release builds atm
.PHONY:
build-ain-rs-exports: build-ain-grpc
@cd $(abs_srcdir) && \
CRATE_CC_NO_DEFAULTS=1 BUILD_DIR="$(abs_builddir)" $(CARGO) build --package ain-rs-exports \
--release $(if $(TARGET),--target $(TARGET),) --target-dir $(abs_builddir)/target && \
mkdir -p $(abs_builddir)/gen/{include,lib,src} && \
cp $(abs_builddir)/target/$(TARGET)/release/libain_rs_exports.a $(abs_builddir)/gen/lib/ && \
cp $(abs_builddir)/ain_rs_exports.h $(abs_builddir)/gen/include/ && \
cp $(abs_builddir)/ain_rs_exports.cpp $(abs_builddir)/gen/src/

.PHONY:
build-ain-grpc:
@cd $(abs_srcdir) && \
CRATE_CC_NO_DEFAULTS=1 BUILD_DIR="$(abs_builddir)" $(CARGO) build --package ain-grpc \
--release $(if $(TARGET),--target $(TARGET),) --target-dir $(abs_builddir)

.PHONY:
clean-local:
@cd $(abs_srcdir) && \
$(CARGO) clean --target-dir $(abs_builddir) && \
rm -rf $(abs_builddir)/gen
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ mod ffi {
fn evm_get_context() -> u64;
fn evm_discard_context(context: u64);
fn evm_queue_tx(context: u64, raw_tx: &str) -> Result<bool>;
fn evm_finalise(context: u64, update_state: bool, miner_address: [u8; 20]) -> Result<Vec<u8>>;
fn evm_finalise(
context: u64,
update_state: bool,
miner_address: [u8; 20],
) -> Result<Vec<u8>>;

fn init_runtime();
fn start_servers(json_addr: &str, grpc_addr: &str) -> Result<()>;
Expand Down Expand Up @@ -86,7 +90,14 @@ fn evm_queue_tx(context: u64, raw_tx: &str) -> Result<bool, Box<dyn Error>> {
}

use rlp::Encodable;
fn evm_finalise(context: u64, update_state: bool, miner_address: [u8; 20]) -> Result<Vec<u8>, Box<dyn Error>> {
let (block, _failed_tx) = RUNTIME.handlers.finalize_block(context, update_state, miner_address)?;
fn evm_finalise(
context: u64,
update_state: bool,
miner_address: [u8; 20],
) -> Result<Vec<u8>, Box<dyn Error>> {
let (block, _failed_tx) =
RUNTIME
.handlers
.finalize_block(context, update_state, miner_address)?;
Ok(block.header.rlp_bytes().into())
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.

SUBDIRS = rust
SUBDIRS = ../lib
DIST_SUBDIRS = secp256k1 univalue

AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
Expand All @@ -26,15 +26,16 @@ LIBDEFI_SPV_INCLUDES = \
-I$(srcdir)/spv/bitcoin \
-I$(srcdir)/spv/bcash

LIBAIN_RS_INCLUDES = -I$(builddir)/rust/include
LIBAIN_RS_LIB = -L$(builddir)/rust/lib -lain_rs_exports
LIBAIN_RS_SRC = $(builddir)/rust/src/ain_rs_exports.cpp
LIBAIN_DIR = $(abs_top_builddir)/lib/gen
LIBAIN_RS_INCLUDES = -I$(LIBAIN_DIR)/include
LIBAIN_RS_LIB = -L$(LIBAIN_DIR)/lib -lain_rs_exports
LIBAIN_RS_SRC = $(LIBAIN_DIR)/src/ain_rs_exports.cpp
LIBAIN_RS_H = ain_rs_exports.h

$(LIBAIN_RS_SRC):
$(LIBAIN_RS_H):
$(LIBAIN_RS_LIB): FORCE
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C rust
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(abs_top_srcdir)/lib

DEFI_INCLUDES = -I$(builddir) $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS)
DEFI_INCLUDES += -I$(srcdir)/secp256k1/include
Expand Down
31 changes: 0 additions & 31 deletions src/rust/Makefile.am

This file was deleted.

0 comments on commit 5f93587

Please sign in to comment.