Skip to content

Commit

Permalink
Refactor projects, flatten, resolve warnings (#1898)
Browse files Browse the repository at this point in the history
* Rename and flatten

* cargo fix

* Resolve all warning, rename to cpp-imports

* Resolve warnings, rename to cpp-exports

* set local C to work with OSX out of the box

rm whitespaces

* Revert "set local C to work with OSX out of the box"

This reverts commit db54529.

---------

Co-authored-by: dcorral <hi@dcorral.com>
  • Loading branch information
prasannavl and dcorral authored Apr 13, 2023
1 parent 543f84d commit cc1644d
Showing 59 changed files with 812 additions and 1,980 deletions.
6 changes: 3 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -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):
2 changes: 1 addition & 1 deletion src/defid.cpp
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
#include <util/threadnames.h>
#include <util/translation.h>

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

#include <functional>

2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
@@ -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>
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) {
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
@@ -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>
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
@@ -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:
File renamed without changes.
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"

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
@@ -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;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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},
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.
Original file line number Diff line number Diff line change
@@ -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"
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};
@@ -298,7 +298,7 @@ fn modify_codegen(
&quote!(
#[derive(Clone)]
pub struct #service {
adapter: Arc<Handlers>
#[allow(dead_code)] adapter: Arc<Handlers>
}

impl #service {
@@ -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(
@@ -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()
File renamed without changes.
Loading

0 comments on commit cc1644d

Please sign in to comment.