Skip to content

Commit

Permalink
chore(workflow): evm ci (#1866)
Browse files Browse the repository at this point in the history
* add ci for evm

* toolchain nightly will do

* add cargo clippy ci

* Add EVM BlockHandler (#1864)

* Make handlers extensible, add block handler

* Move EVMHandler

* Fix build errors

* Add connect_block

* Fix Eth_GetBlockByHash

* Fix incomplete merge

* Add bin files to gitignore

* Change RPC methods to lowerCamelCase

* Formatting

* EVM in/out refinements (#1865)

* Return error on sub balance failure.

* Change to expected return type

* Update EVM in/out TX

* Use array instead of rust::Vec

* Pass context to CustomTxVisit

* Add temporary state to TransactionQueue

* Improve readability

* Block integration test

---------

Co-authored-by: Bushstar <[email protected]>
Co-authored-by: Prasanna Loganathar <[email protected]>

* Revert "EVM in/out refinements (#1865)" (#1867)

This reverts commit 35c85d4.

* EVM in/out refinements  (#1868)

* Return error on sub balance failure.

* Change to expected return type

* Update EVM in/out TX

* Use array instead of rust::Vec

* Pass context to CustomTxVisit

* Add temporary state to TransactionQueue

* Improve readability

* Block integration test

---------

Co-authored-by: Bushstar <[email protected]>

* Fix warnings (#1869)

* Got correct hash for public key recovery. Add test. (#1870)

* Got correct hash for public key recovery. Add test.

* Add support for EIP1559 TXs address recovery

* Add support for EIP2930 TXs address recovery

* Add failing test

* Improve error handling (#1872)

* Improve error handling

* Correct test addresses

* Fix public key extraction from Eth TXs and add tests (#1875)

* Get correct hash for public key recovery. Add test.

* Update test for EIP-2930

* EVM block integration test (#1874)

* Add smart contract create && call tests

* evm ci event triggered by path

* fmt

---------

Co-authored-by: Shoham Chakraborty <[email protected]>
Co-authored-by: Jouzo <[email protected]>
Co-authored-by: Bushstar <[email protected]>
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
5 people authored Apr 10, 2023
1 parent ec47dbf commit 7b8102a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/tests-evm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Tests - EVM

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

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

jobs:
lint_cargo_fmt:
name: Lint (cargo fmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
default: true
override: true
components: rustfmt, clippy

- run: |
cd src/rust
cargo fmt --all -- --check
lint_cargo_clippy:
name: Lint (cargo clippy)
runs-on: ubuntu-latest
steps:
- uses: arduino/setup-protoc@64c0c85d18e984422218383b81c52f8b077404d3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
default: true
override: true
components: rustfmt, clippy

- run: |
cd src/rust
cargo clippy
test_cargo:
name: Test (cargo)
runs-on: ubuntu-latest
steps:
- uses: arduino/setup-protoc@64c0c85d18e984422218383b81c52f8b077404d3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
default: true
override: true
components: rustfmt, clippy

- run: |
cd src/rust
cargo test --no-fail-fast
6 changes: 5 additions & 1 deletion src/rust/crates/ain-evm-state/src/tx_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ impl TransactionQueueMap {
}

pub fn state(&self, context_id: u64) -> Option<EVMState> {
self.queues.read().unwrap().get(&context_id).map(|queue| queue.state())
self.queues
.read()
.unwrap()
.get(&context_id)
.map(|queue| queue.state())
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/rust/crates/ain-evm/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl TryFrom<TransactionV2> for SignedTx {
tx.signature.s(),
tx.signature.standard_v(),
)
},
}
TransactionV2::EIP2930(tx) => {
let msg = ethereum::EIP2930TransactionMessage {
chain_id: tx.chain_id,
Expand All @@ -138,7 +138,7 @@ impl TryFrom<TransactionV2> for SignedTx {
let signing_message = libsecp256k1::Message::parse_slice(&msg.hash()[..]).unwrap();
let hash = H256::from(signing_message.serialize());
recover_public_key(&hash, &tx.r, &tx.s, tx.odd_y_parity as u8)
},
}
TransactionV2::EIP1559(tx) => {
let msg = ethereum::EIP1559TransactionMessage {
chain_id: tx.chain_id,
Expand Down Expand Up @@ -317,6 +317,9 @@ mod tests {
// EIP-2930
let signed_tx = crate::transaction::SignedTx::try_from("01f86d050185689451eee18252089434c1ca09a2dc717d89baef2f30ff6a6b2975e17e872386f26fc1000080c080a0632502442f6bd0dbe14c087798277ce04bdede53c4642559a0a7d7e20fc7e8f1a0517c7504cb9adfe67f58dd43e00e77b4b2159e9f2c378b7616ba30dfa711ec8f").unwrap();

assert_eq!(hex::encode(signed_tx.sender.as_fixed_bytes()), "f829754bae400b679febefdcfc9944c323e1f94e");
assert_eq!(
hex::encode(signed_tx.sender.as_fixed_bytes()),
"f829754bae400b679febefdcfc9944c323e1f94e"
);
}
}

0 comments on commit 7b8102a

Please sign in to comment.