Skip to content

Commit

Permalink
Merge pull request #2 from WeBankBlockchain/dev
Browse files Browse the repository at this point in the history
implement analysis of conflict keys
  • Loading branch information
bxq2011hust authored Dec 7, 2021
2 parents 8c8c5bf + 6280ec0 commit 6f4431f
Show file tree
Hide file tree
Showing 42 changed files with 7,673 additions and 535 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Cargo-liquid Github Actions
on:
push:
pull_request:
release:
types: [published, created, edited]

jobs:
win_test:
name: win_test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2019]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: install rust nightly
uses: actions-rs/toolchain@v1
with:
components: rustc-dev, rust-src
- name: install cargo-liquid
run: cargo install --path . --force
- name: compile test contract
run: cd .\tests\conflict_analysis_test\contract && cargo liquid build
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '3.x'
architecture: 'x64'
- name: verify conflict analysis result
run: cd .\tests\conflict_analysis_test && python .\verify_conflict.py
26 changes: 23 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-liquid"
version = "1.0.0-rc1"
version = "1.0.0-rc2"
authors = ["vita-dounai <lichenxi.webank@gmail.com>"]
build = "build.rs"
edition = "2018"
Expand All @@ -20,9 +20,29 @@ parity-wasm = "0.41.0"
pwasm-utils = "0.14.0"
which = "4.0.2"
indicatif = { version = "0.15.0", features = ["rayon", "improved_unicode"] }
console = { version = "0.13.0" }
console = "0.13.0"
env_logger = "*"
log = "*"
log-derive = "*"
petgraph = "0.6"
either = "*"
serde = "*"
serde_json = "*"
itertools = "*"
leb128 = "*"
tiny-keccak = { version = "*", features = ["keccak"] }
libsm = "*"
wabt = "*"

[build-dependencies]
anyhow = "1.0.32"
zip = "0.5.6"
walkdir = "2.3.1"
walkdir = "2.3.1"

[[bin]]
name = "cargo-liquid"
path = "src/main/main.rs"

[[bin]]
name = "liquid-analy"
path = "src/analyzer/main.rs"
33 changes: 17 additions & 16 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{
ffi::OsStr,
fs::File,
io::{Read, Write},
path::PathBuf,
path::{Path, PathBuf},
};
use walkdir::WalkDir;
use zip::{write::FileOptions, CompressionMethod, ZipWriter};
Expand Down Expand Up @@ -52,13 +52,13 @@ fn main() {
});
}

fn zip_dir(src_dir: &PathBuf, dst_file: &PathBuf) -> Result<()> {
fn zip_dir(src_dir: &Path, dst_file: &Path) -> Result<()> {
if !src_dir.exists() {
anyhow::bail!("src_dir '{}' does not exist", src_dir.display());
anyhow::bail!("src_dir `{}` does not exist", src_dir.display());
}

if !src_dir.is_dir() {
anyhow::bail!("src_dir '{}' is not a directory");
anyhow::bail!("src_dir `{}` is not a directory", src_dir.display());
}

let file = File::create(dst_file)?;
Expand All @@ -77,20 +77,21 @@ fn zip_dir(src_dir: &PathBuf, dst_file: &PathBuf) -> Result<()> {

// Cargo.toml files cause the folder to excluded from `cargo package` so need to be renamed
if name.file_name() == Some(OsStr::new("_Cargo.toml")) {
name.set_file_name("Cargo.toml")
name.set_file_name("Cargo.toml");
}

if path.is_file() {
#[allow(deprecated)]
zip.start_file_from_path(name.as_path(), options)?;
let mut f = File::open(path)?;

f.read_to_end(&mut buffer)?;
zip.write_all(&*buffer)?;
buffer.clear();
} else if name.as_os_str().len() != 0 {
#[allow(deprecated)]
zip.add_directory_from_path(name.as_path(), options)?;
if let Some(name) = name.to_str() {
if path.is_file() {
zip.start_file(name, options)?;
let mut f = File::open(path)?;
f.read_to_end(&mut buffer)?;
zip.write_all(&*buffer)?;
buffer.clear();
} else if !name.is_empty() {
zip.add_directory(name, options)?;
}
} else {
anyhow::bail!("the path contains invalid UTF-8 characters: `{:?}`", name);
}
}
zip.finish()?;
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2021-06-23
Loading

0 comments on commit 6f4431f

Please sign in to comment.