Skip to content

Commit 0754403

Browse files
committed
cleanup
1 parent 053dba0 commit 0754403

File tree

5 files changed

+30
-41
lines changed

5 files changed

+30
-41
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ rust-version = "1.85.0"
2828
[workspace.dependencies]
2929
aes-gcm = { version = "0.10.3" }
3030
alloy = { version = "1.0", features = ["default", "arbitrary", "k256", "serde", "rlp"] }
31-
alloy-signer = { version = "1.0.24" }
31+
alloy-signer = { version = "1.0" }
3232
alloy-chains = "0.2"
3333
# derive feature is not exposed via `alloy`, thus has to explicitly declare here
3434
alloy-rlp = { version = "0.3.12", features = ["derive"] }

timeboost-types/src/bundle.rs

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,45 +121,35 @@ impl Bundle {
121121
Ok(b)
122122
}
123123

124-
pub fn create_testnode_transaction_bundle(nonce: u64) -> Result<Bundle, InvalidTransaction> {
125-
// private key from pre funded dev account on test node
126-
// https://docs.arbitrum.io/run-arbitrum-node/run-local-full-chain-simulation
127-
let private_key = "b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659";
128-
let to_address: alloy::primitives::Address =
129-
address!("6A568afe0f82d34759347bb36F14A6bB171d2CBe");
124+
pub fn create_dev_acct_txn_bundle(nonce: u64) -> anyhow::Result<Bundle> {
130125
let chain_id = 412346;
131-
let value = U256::from(1);
132-
let gas_limit = 21000;
133-
let max_fee_per_gas = 1000000000;
134-
let max_priority_fee_per_gas = 1000000000;
135-
136126
let mut tx = TxEip1559 {
137127
chain_id,
138128
nonce,
139-
max_priority_fee_per_gas,
140-
max_fee_per_gas,
141-
gas_limit,
142-
to: TxKind::Call(to_address),
143-
value,
129+
max_priority_fee_per_gas: 1000000000,
130+
max_fee_per_gas: 1000000000,
131+
gas_limit: 21000,
132+
to: TxKind::Call(address!("6A568afe0f82d34759347bb36F14A6bB171d2CBe")),
133+
value: U256::from(1),
144134
input: alloy::primitives::Bytes::new(),
145135
access_list: AccessList::default(),
146136
};
147137

148-
let signer = PrivateKeySigner::from_str(private_key).expect("valid private key");
149-
let signature = signer
150-
.sign_transaction_sync(&mut tx)
151-
.expect("valid signature");
152-
let signed_tx = tx.into_signed(signature);
153-
let tx_envelope = TxEnvelope::Eip1559(signed_tx);
154-
155-
let mut rlp_encoded = Vec::new();
156-
tx_envelope.encode(&mut rlp_encoded);
157-
158-
let encoded = ssz::ssz_encode(&vec![&rlp_encoded]);
159-
160-
let bundle = Bundle::new(chain_id.into(), Epoch::now(), encoded.into(), false);
138+
// private key from pre funded dev account on test node
139+
// https://docs.arbitrum.io/run-arbitrum-node/run-local-full-chain-simulation
140+
let signer = PrivateKeySigner::from_str(
141+
"b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659",
142+
)?;
143+
let sig = signer.sign_transaction_sync(&mut tx)?;
144+
let signed_tx = tx.into_signed(sig);
145+
let env = TxEnvelope::Eip1559(signed_tx);
146+
let mut rlp = Vec::new();
147+
env.encode(&mut rlp);
148+
149+
let encoded = ssz::ssz_encode(&vec![&rlp]);
150+
let b = Bundle::new(chain_id.into(), Epoch::now(), encoded.into(), false);
161151

162-
Ok(bundle)
152+
Ok(b)
163153
}
164154
}
165155

timeboost-utils/src/load_generation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn make_bundle(pubkey: &ThresholdEncKeyCell) -> anyhow::Result<BundleVariant
4343
}
4444
}
4545

46-
pub fn make_nitro_bundle(
46+
pub fn make_dev_acct_bundle(
4747
pubkey: &ThresholdEncKeyCell,
4848
nonce: u64,
4949
) -> anyhow::Result<BundleVariant> {
@@ -53,7 +53,7 @@ pub fn make_nitro_bundle(
5353
let mut u = Unstructured::new(&v);
5454

5555
let max_seqno = 10;
56-
let mut bundle = Bundle::create_testnode_transaction_bundle(nonce)?;
56+
let mut bundle = Bundle::create_dev_acct_txn_bundle(nonce)?;
5757

5858
if let Some(pubkey) = &*pubkey.get_ref()
5959
&& rng.gen_bool(0.5)

yapper/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ async fn main() -> Result<()> {
7070
}
7171

7272
let mut jh = tokio::spawn(async move {
73-
if !cli.nitro_integration {
74-
yap(&addresses, cli.tps).await
75-
} else {
73+
if cli.nitro_integration {
7674
yap_with_nitro(&addresses, cli.nitro_txn_limit).await
75+
} else {
76+
yap(&addresses, cli.tps).await
7777
}
7878
});
7979

yapper/src/tx.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use reqwest::{Client, Url};
88
use std::{collections::HashMap, time::Duration};
99
use timeboost::types::BundleVariant;
1010
use timeboost_crypto::prelude::{ThresholdEncKey, ThresholdEncKeyCell};
11-
use timeboost_utils::load_generation::{make_bundle, make_nitro_bundle, tps_to_millis};
11+
use timeboost_utils::load_generation::{make_bundle, make_dev_acct_bundle, tps_to_millis};
1212
use tokio::time::{interval, sleep};
1313

1414
use anyhow::{Context, Result};
@@ -178,16 +178,15 @@ pub async fn yap_with_nitro(addresses: &[Address], txn_limit: u64) -> Result<()>
178178

179179
let mut acc =
180180
ThresholdEncKeyCellAccumulator::new(c.clone(), urls.iter().map(|url| url.2.clone()));
181-
let rpc_url = "http://localhost:8547";
182-
let provider = RootProvider::<Ethereum>::connect(rpc_url)
181+
let provider = RootProvider::<Ethereum>::connect("http://localhost:8547")
183182
.await
184183
.expect("to connect");
185184
let address = address!("0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E");
186185

187186
let mut txns_sent = 0;
188187
loop {
189188
let nonce = provider.get_transaction_count(address).await?;
190-
let Ok(b) = make_nitro_bundle(acc.enc_key().await, nonce) else {
189+
let Ok(b) = make_dev_acct_bundle(acc.enc_key().await, nonce) else {
191190
warn!("failed to generate bundle");
192191
continue;
193192
};
@@ -198,7 +197,7 @@ pub async fn yap_with_nitro(addresses: &[Address], txn_limit: u64) -> Result<()>
198197
.await;
199198
txns_sent += 1;
200199
if txns_sent == txn_limit {
201-
tracing::error!("hit txn limit, terminating yapper");
200+
warn!("hit txn limit, terminating yapper");
202201
return Ok(());
203202
}
204203
sleep(Duration::from_secs(1)).await;

0 commit comments

Comments
 (0)