Skip to content
2 changes: 1 addition & 1 deletion rs/ethereum/cketh/minter/src/deposit_address/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn deposit_derivation_path(schema: DepositAddressSchema, account: &Account) -> V
]
}

fn sweeper_derivation_path() -> Vec<ByteBuf> {
pub(crate) fn sweeper_derivation_path() -> Vec<ByteBuf> {
vec![ByteBuf::from(vec![SWEEPER_SCHEMA_TAG])]
}

Expand Down
3 changes: 3 additions & 0 deletions rs/ethereum/cketh/minter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod memo;
pub mod numeric;
pub mod state;
pub mod storage;
pub mod sweep;
pub mod timed_sized_map;
pub mod tx;
pub mod withdraw;
Expand All @@ -40,6 +41,8 @@ pub const BALANCE_SCAN_INTERVAL: Duration = Duration::from_secs(30);
pub const PROCESS_ETH_RETRIEVE_TRANSACTIONS_INTERVAL: Duration = Duration::from_secs(6 * 60);
pub const PROCESS_REIMBURSEMENT: Duration = Duration::from_secs(3 * 60);
pub const PROCESS_ETH_RETRIEVE_TRANSACTIONS_RETRY_INTERVAL: Duration = Duration::from_secs(3 * 60);
pub const PROCESS_SWEEPER_TRANSACTIONS_INTERVAL: Duration = Duration::from_secs(6 * 60);
pub const PROCESS_SWEEPER_TRANSACTIONS_RETRY_INTERVAL: Duration = Duration::from_secs(3 * 60);
pub const MINT_RETRY_DELAY: Duration = Duration::from_secs(3 * 60);
pub const EVM_RPC_ID_PRODUCTION: Principal =
Principal::from_slice(&[0, 0, 0, 0, 2, 48, 0, 204, 1, 1]);
Expand Down
7 changes: 6 additions & 1 deletion rs/ethereum/cketh/minter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use ic_cketh_minter::state::transactions::{
use ic_cketh_minter::state::{
STATE, State, lazy_call_ecdsa_public_key, mutate_state, read_state, transactions,
};
use ic_cketh_minter::sweep::process_sweeper_transactions;
use ic_cketh_minter::timed_sized_map::Timestamp;
use ic_cketh_minter::tx::lazy_refresh_gas_fee_estimate;
use ic_cketh_minter::withdraw::{
Expand All @@ -46,7 +47,8 @@ use ic_cketh_minter::withdraw::{
};
use ic_cketh_minter::{
BALANCE_SCAN_INTERVAL, PROCESS_ETH_RETRIEVE_TRANSACTIONS_INTERVAL, PROCESS_REIMBURSEMENT,
REFRESH_LATEST_BLOCK_HEIGHT_INTERVAL, SCRAPING_ETH_LOGS_INTERVAL, state, storage,
PROCESS_SWEEPER_TRANSACTIONS_INTERVAL, REFRESH_LATEST_BLOCK_HEIGHT_INTERVAL,
SCRAPING_ETH_LOGS_INTERVAL, state, storage,
};
use ic_cketh_minter::{endpoints, erc20};
use ic_ethereum_types::Address;
Expand Down Expand Up @@ -99,6 +101,9 @@ fn setup_timers() {
ic_cdk_timers::set_timer_interval(PROCESS_ETH_RETRIEVE_TRANSACTIONS_INTERVAL, async || {
process_retrieve_eth_requests().await;
});
ic_cdk_timers::set_timer_interval(PROCESS_SWEEPER_TRANSACTIONS_INTERVAL, async || {
process_sweeper_transactions().await;
});
ic_cdk_timers::set_timer_interval(PROCESS_REIMBURSEMENT, async || {
process_reimbursement().await;
});
Expand Down
2 changes: 2 additions & 0 deletions rs/ethereum/cketh/minter/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ impl State {
Some(ecdsa_public_key_to_address(&pubkey))
}

/// The minter's dedicated sweeper address, `None` until the ECDSA public key is cached.
pub fn sweeper_address(&self) -> Option<Address> {
let (master_public_key, chain_code) = self.public_key_and_chain_code()?;
Some(sweeper_address(&master_public_key, &chain_code))
Expand Down Expand Up @@ -951,4 +952,5 @@ pub enum TaskType {
MintCkErc20,
RefreshLatestBlockHeight,
BalanceScan,
SweeperSend,
}
17 changes: 9 additions & 8 deletions rs/ethereum/cketh/minter/src/state/transactions/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2906,11 +2906,12 @@ mod sweep_lane {
use super::{gas_fee_estimate, sign_transaction, transaction_receipt};
use crate::eth_rpc_client::responses::TransactionStatus;
use crate::lifecycle::EthereumNetwork;
use crate::numeric::{GasAmount, TransactionCount, TransactionNonce, Wei, WeiPerGas};
use crate::numeric::{TransactionCount, TransactionNonce, Wei, WeiPerGas};
use crate::state::transactions::{
CreateSweepTransactionError, PipelineRequest, ResubmitTransactionError, SweepId,
SweepRequest, TransactionPipeline,
};
use crate::sweep::SWEEP_TRANSACTION_GAS_LIMIT;
use crate::tx::{
DelegatingSweep, Eip1559TransactionRequest, Eip7702TransactionRequest, GasFeeEstimate,
SignableTransaction, SignedAuthorization, SweepTransaction,
Expand All @@ -2919,7 +2920,6 @@ mod sweep_lane {
use ethnum::u256;
use ic_ethereum_types::Address;

const SWEEP_GAS_LIMIT: GasAmount = GasAmount::new(100_000);
const EIP1559_TX_ID: u8 = 2;
const SET_CODE_TX_ID: u8 = 4;

Expand Down Expand Up @@ -2975,7 +2975,7 @@ mod sweep_lane {
.create_transaction(
pipeline.next_transaction_nonce(),
gas_fee_estimate(),
SWEEP_GAS_LIMIT,
SWEEP_TRANSACTION_GAS_LIMIT,
EthereumNetwork::Sepolia,
)
.expect("BUG: the fixture allowance covers the fixture fee");
Expand Down Expand Up @@ -3177,7 +3177,7 @@ mod sweep_lane {
.create_transaction(
pipeline.next_transaction_nonce(),
gas_fee_estimate(),
SWEEP_GAS_LIMIT,
SWEEP_TRANSACTION_GAS_LIMIT,
EthereumNetwork::Sepolia,
)
.expect("BUG: the fixture allowance covers the fixture fee")
Expand All @@ -3194,7 +3194,8 @@ mod sweep_lane {
};

assert_eq!(
tx.max_fee_per_gas.transaction_cost(SWEEP_GAS_LIMIT),
tx.max_fee_per_gas
.transaction_cost(SWEEP_TRANSACTION_GAS_LIMIT),
Some(request.max_transaction_fee)
);
assert_eq!(
Expand All @@ -3214,7 +3215,7 @@ mod sweep_lane {
let created = request.create_transaction(
TransactionNonce::ZERO,
spiked_fee,
SWEEP_GAS_LIMIT,
SWEEP_TRANSACTION_GAS_LIMIT,
EthereumNetwork::Sepolia,
);

Expand All @@ -3240,14 +3241,14 @@ mod sweep_lane {
gas_fee_estimate().max_priority_fee_per_gas
> request
.max_transaction_fee
.into_wei_per_gas(SWEEP_GAS_LIMIT)
.into_wei_per_gas(SWEEP_TRANSACTION_GAS_LIMIT)
.unwrap()
);

let created = request.create_transaction(
TransactionNonce::ZERO,
gas_fee_estimate(),
SWEEP_GAS_LIMIT,
SWEEP_TRANSACTION_GAS_LIMIT,
EthereumNetwork::Sepolia,
);

Expand Down
Loading
Loading