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

Refactor projects, flatten, resolve warnings #1898

Merged
merged 6 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ LIBDEFI_SPV_INCLUDES = \
-I$(srcdir)/spv/bcash

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

$(LIBAIN_RS_SRC):
$(LIBAIN_RS_H):
Expand Down
2 changes: 1 addition & 1 deletion src/defid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <util/threadnames.h>
#include <util/translation.h>

#include <libain_evm.h>
#include <ain_rs_exports.h>

#include <functional>

Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <index/txindex.h>
#include <key.h>
#include <key_io.h>
#include <libain_evm.h>
#include <ain_rs_exports.h>
#include <masternodes/accountshistory.h>
#include <masternodes/anchors.h>
#include <masternodes/govvariables/attributes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <masternodes/vaulthistory.h>
#include <masternodes/errors.h>

#include <libain_evm.h>
#include <ain_rs_exports.h>
#include <core_io.h>
#include <index/txindex.h>
#include <txmempool.h>
Expand Down
2 changes: 1 addition & 1 deletion src/masternodes/rpc_evm.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <masternodes/mn_rpc.h>

#include <libain_evm.h>
#include <ain_rs_exports.h>
#include <key_io.h>

UniValue evmtx(const JSONRPCRequest& request) {
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <consensus/tx_check.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <libain_evm.h>
#include <ain_rs_exports.h>
#include <masternodes/anchors.h>
#include <masternodes/govvariables/attributes.h>
#include <masternodes/masternodes.h>
Expand Down
42 changes: 21 additions & 21 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[workspace]
members = [
"crates/ain-evm",
"crates/ain-evm-ffi",
"crates/ain-evm-cpp-ffi",
"crates/ain-grpc",
"ain-*",
]

10 changes: 6 additions & 4 deletions src/rust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ RUST_TARGET ?= x86_64-unknown-linux-gnu
.PHONY:
all: build-evm-pkg build-grpc-pkg


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

.PHONY:
build-grpc-pkg:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ain-evm-cpp-ffi"
name = "ain-cpp-imports"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::traits::{PersistentState, PersistentStateError};
use ethereum::BlockAny;
use primitive_types::{H256, U256};
use primitive_types::H256;
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::traits::{PersistentState, PersistentStateError};
use crate::tx_queue::TransactionQueueMap;
use crate::{executor::AinExecutor, traits::Executor, transaction::SignedTx};
use anyhow::anyhow;
use ethereum::{AccessList, Block, PartialHeader, TransactionV2};
use ethereum::{AccessList, TransactionV2};
use evm::backend::MemoryAccount;
use evm::{
backend::{MemoryBackend, MemoryVicinity},
Expand Down
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 @@ -6,7 +6,7 @@ build = "build.rs"

[dependencies]
ain-evm = { path = "../ain-evm" }
ain-evm-cpp-ffi = { path = "../ain-evm-cpp-ffi" }
ain-cpp-imports = { path = "../ain-cpp-imports" }
cxx = "1.0"
env_logger = "0.9"
jsonrpsee-core = "0.15"
Expand Down
13 changes: 5 additions & 8 deletions src/rust/crates/ain-grpc/build.rs → src/rust/ain-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use heck::{ToLowerCamelCase, ToPascalCase, ToSnekCase};
use heck::{ToPascalCase, ToSnekCase};
use proc_macro2::{Span, TokenStream};
use prost_build::{Config, Service, ServiceGenerator};
use quote::{quote, ToTokens};
Expand Down Expand Up @@ -298,7 +298,7 @@ fn modify_codegen(
&quote!(
#[derive(Clone)]
pub struct #service {
adapter: Arc<Handlers>
#[allow(dead_code)] adapter: Arc<Handlers>
}

impl #service {
Expand Down Expand Up @@ -761,14 +761,10 @@ fn get_path_bracketed_ty_simple(ty: &Type) -> Type {

fn main() {
let manifest_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let proto_path = manifest_path
.parent()
.unwrap()
.parent()
.unwrap()
.join("protobuf");
let proto_path = manifest_path.parent().unwrap().join("proto");
let src_path = manifest_path.join("src");
let gen_path = src_path.join("gen");
std::fs::create_dir_all(&gen_path).unwrap();

let methods = generate_from_protobuf(&proto_path, Path::new(&gen_path));
let _tt = modify_codegen(
Expand All @@ -777,6 +773,7 @@ fn main() {
&Path::new(&gen_path).join("rpc.rs"),
&src_path.join("lib.rs"),
);

println!(
"cargo:rerun-if-changed={}",
src_path.join("rpc.rs").to_string_lossy()
Expand Down
Loading