Skip to content

Commit

Permalink
Merge branch 'main' into adding-cors
Browse files Browse the repository at this point in the history
  • Loading branch information
Blu-J authored Dec 12, 2024
2 parents b578f18 + 295bab3 commit ffbc599
Show file tree
Hide file tree
Showing 11 changed files with 412 additions and 197 deletions.
477 changes: 326 additions & 151 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ rundler-utils = { path = "crates/utils" }
rundler-bindings-fastlz = { path = "crates/bindings/fastlz" }

# alloy core
alloy-primitives = "0.8.5"
alloy-sol-macro = "0.8.5"
alloy-sol-types = "0.8.5"
alloy-primitives = "0.8.15"
alloy-sol-macro = "0.8.15"
alloy-sol-types = "0.8.15"

# alloy
alloy-consensus = "0.4.1"
alloy-contract = "0.4.1"
alloy-eips = "0.4.1"
alloy-json-rpc = "0.4.1"
alloy-provider = { version = "0.4.1", default-features = false, features = ["reqwest", "reqwest-rustls-tls"] }
alloy-rpc-client = "0.4.1"
alloy-rpc-types-eth = "0.4.1"
alloy-rpc-types-trace = "0.4.1"
alloy-signer = "0.4.1"
alloy-signer-aws = "0.4.1"
alloy-signer-local = "0.4.1"
alloy-transport = "0.4.1"
alloy-transport-http = { version = "0.4.1", default-features = false, features = ["reqwest", "reqwest-rustls-tls"] }

alloy-consensus = "0.7.3"
alloy-contract = "0.7.3"
alloy-eips = "0.7.3"
alloy-json-rpc = "0.7.3"
alloy-provider = { version = "0.7.3", default-features = false, features = ["reqwest", "reqwest-rustls-tls"] }
alloy-rpc-client = "0.7.3"
alloy-rpc-types-eth = "0.7.3"
alloy-rpc-types-trace = "0.7.3"
alloy-signer = "0.7.3"
alloy-signer-aws = "0.7.3"
alloy-signer-local = "0.7.3"
alloy-transport = "0.7.3"
alloy-transport-http = { version = "0.7.3", default-features = false, features = ["reqwest", "reqwest-rustls-tls"] }
alloy-network = { version = "0.7.3" }
# alloy other
alloy-rlp = "0.3.8"

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ build-%:
fmt: ## format code with nightly rust
cargo +nightly fmt

.PHONY: lint
lint: ## lint and improve code quality
cargo clippy --all --all-features --tests -- -D warnings

# Note: This requires a buildx builder with emulation support. For example:
#
# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64`
Expand Down
36 changes: 27 additions & 9 deletions crates/builder/src/transaction_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// You should have received a copy of the GNU General Public License along with Rundler.
// If not, see https://www.gnu.org/licenses/.

use alloy_consensus::Transaction;
use alloy_primitives::{Address, B256};
use anyhow::{bail, Context};
use async_trait::async_trait;
Expand Down Expand Up @@ -244,7 +245,7 @@ where
self.provider.get_transaction_by_hash(tx_hash),
self.provider.get_transaction_receipt(tx_hash),
)?;
let gas_limit = tx.map(|t| t.gas).or_else(|| {
let gas_limit = tx.map(|t| t.inner.gas_limit()).or_else(|| {
warn!("failed to fetch transaction data for tx: {}", tx_hash);
None
});
Expand Down Expand Up @@ -542,7 +543,11 @@ struct TransactionTrackerMetrics {

#[cfg(test)]
mod tests {
use alloy_primitives::Address;
use alloy_consensus::{
Signed, TxEip1559,
TxEnvelope::{self, Eip1559},
};
use alloy_primitives::{Address, PrimitiveSignature};
use mockall::Sequence;
use rundler_provider::{
MockEvmProvider, Transaction, TransactionReceipt, TransactionReceiptEnvelope,
Expand Down Expand Up @@ -758,6 +763,25 @@ mod tests {
));
}

fn sign_transaction(hash: B256) -> Transaction {
let txn = TxEip1559 {
gas_limit: 0,
..Default::default()
};
let inner = Eip1559(Signed::new_unchecked(
txn,
PrimitiveSignature::test_signature(),
hash,
));
Transaction::<TxEnvelope> {
inner,
block_hash: None,
block_number: None,
transaction_index: None,
effective_gas_price: None,
from: Address::default(),
}
}
#[tokio::test]
async fn test_check_for_update_mined() {
let (mut sender, mut provider) = create_base_config();
Expand All @@ -781,12 +805,7 @@ mod tests {

provider
.expect_get_transaction_by_hash()
.returning(|_: B256| {
Ok(Some(Transaction {
gas: 0,
..Default::default()
}))
});
.returning(|hash: B256| Ok(Some(sign_transaction(hash))));

provider
.expect_get_transaction_receipt()
Expand All @@ -806,7 +825,6 @@ mod tests {
from: Address::ZERO,
to: None,
contract_address: None,
state_root: None,
authorization_list: None,
}))
});
Expand Down
1 change: 1 addition & 0 deletions crates/pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository.workspace = true
publish = false

[dependencies]
alloy-consensus.workspace = true
rundler-contracts.workspace = true
rundler-provider.workspace = true
rundler-sim.workspace = true
Expand Down
7 changes: 5 additions & 2 deletions crates/pool/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,11 @@ mod tests {
Some(Block {
header: BlockHeader {
hash,
parent_hash,
number: number as u64,
inner: alloy_consensus::Header {
parent_hash,
number: number as u64,
..Default::default()
},
..Default::default()
},
..Default::default()
Expand Down
8 changes: 2 additions & 6 deletions crates/provider/src/alloy/entry_point/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// If not, see https://www.gnu.org/licenses/.

use alloy_consensus::{transaction::SignableTransaction, TxEnvelope, TypedTransaction};
use alloy_primitives::{address, Address, Bytes, Parity, Signature, U256};
use alloy_primitives::{address, Address, Bytes, PrimitiveSignature, U256};
use alloy_rlp::Encodable;
use alloy_rpc_types_eth::TransactionRequest;

Expand Down Expand Up @@ -49,11 +49,7 @@ fn max_bundle_transaction_data(to_address: Address, data: Bytes, gas_price: u128

// use a max signature
let tx_envelope: TxEnvelope = tx_1559
.into_signed(Signature::new(
U256::MAX,
U256::MAX,
Parity::Eip155(u64::MAX),
))
.into_signed(PrimitiveSignature::new(U256::MAX, U256::MAX, false))
.into();
let mut encoded = vec![];
tx_envelope.encode(&mut encoded);
Expand Down
2 changes: 2 additions & 0 deletions crates/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repository.workspace = true
publish = false

[dependencies]
alloy-consensus.workspace = true
rundler-contracts.workspace = true
rundler-provider.workspace = true
rundler-sim.workspace = true
Expand Down Expand Up @@ -40,6 +41,7 @@ url.workspace = true

[dev-dependencies]
alloy-consensus.workspace = true
alloy-network.workspace = true
mockall.workspace = true
rundler-provider = { workspace = true, features = ["test-utils"] }
rundler-sim = { workspace = true, features = ["test-utils"] }
Expand Down
28 changes: 21 additions & 7 deletions crates/rpc/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ where
mod tests {
use std::sync::Arc;

use alloy_primitives::{Log as PrimitiveLog, LogData, U256};
use alloy_consensus::{Signed, TxEip1559, TxEnvelope::Eip1559};
use alloy_primitives::{Log as PrimitiveLog, LogData, PrimitiveSignature, TxKind, U256};
use alloy_sol_types::SolInterface;
use mockall::predicate::eq;
use rundler_contracts::v0_6::IEntryPoint::{handleOpsCall, IEntryPointCalls};
Expand Down Expand Up @@ -270,20 +271,33 @@ mod tests {
})
.abi_encode();

let tx = Transaction {
to: Some(ep),
let inner_txn = TxEip1559 {
to: TxKind::Call(ep),
input: tx_data.into(),
block_number: Some(block_number),
block_hash: Some(block_hash),
..Default::default()
};
let tx_hash = tx.hash;

let inner = Eip1559(Signed::new_unchecked(
inner_txn,
PrimitiveSignature::test_signature(),
hash,
));
let tx = Transaction {
inner,
block_hash: Some(block_hash),
block_number: Some(block_number),
transaction_index: None,
effective_gas_price: None,
from: Address::default(),
};

let tx_hash = *tx.inner.tx_hash();
let log = Log {
inner: PrimitiveLog {
address: ep,
data: LogData::default(),
},
transaction_hash: Some(tx.hash),
transaction_hash: Some(tx_hash),
..Default::default()
};

Expand Down
11 changes: 7 additions & 4 deletions crates/rpc/src/eth/events/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use std::{collections::VecDeque, marker::PhantomData};

use alloy_consensus::Transaction;
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_sol_types::SolEvent;
use anyhow::Context;
Expand Down Expand Up @@ -87,12 +88,14 @@ where
return Ok(None);
}
let to = tx
.to
.context("tx.to should be present on transaction containing user operation event")?;
.inner
.to()
.expect("tx.to should be present on transaction containing user operation event");

let input = tx.input();

// Find first op matching the hash
let user_operation = if E::address(&self.chain_spec) == to {
E::get_user_operations_from_tx_data(tx.input, &self.chain_spec)
E::get_user_operations_from_tx_data(input.clone(), &self.chain_spec)
.into_iter()
.find(|op| op.hash(to, self.chain_spec.id) == hash)
.context("matching user operation should be found in tx data")?
Expand Down
1 change: 0 additions & 1 deletion crates/rpc/src/eth/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ mod tests {
from: Address::ZERO,
to: None,
contract_address: None,
state_root: None,
authorization_list: None,
}
}
Expand Down

0 comments on commit ffbc599

Please sign in to comment.