diff --git a/db/migrations/002_relayers_table_update.sql b/db/migrations/002_relayers_table_update.sql new file mode 100644 index 0000000..24e3053 --- /dev/null +++ b/db/migrations/002_relayers_table_update.sql @@ -0,0 +1,5 @@ +ALTER TABLE relayers +RENAME COLUMN gas_limits TO gas_price_limits; + +ALTER TABLE relayers +ADD COLUMN enabled BOOL NOT NULL DEFAULT TRUE; diff --git a/manual_test_kms.nu b/manual_test_kms.nu index e426991..7ad746a 100644 --- a/manual_test_kms.nu +++ b/manual_test_kms.nu @@ -21,7 +21,7 @@ echo "Creating relayer" let relayer = http post -t application/json $"($txSitter)/1/admin/relayer" { "name": "My Relayer", "chainId": 11155111 } http post -t application/json $"($txSitter)/1/admin/relayer/($relayer.relayerId)" { - gasLimits: [ + gasPriceLimits: [ { chainId: 11155111, value: "0x123" } ] } diff --git a/src/broadcast_utils.rs b/src/broadcast_utils.rs index 35c9318..ba6b405 100644 --- a/src/broadcast_utils.rs +++ b/src/broadcast_utils.rs @@ -25,7 +25,7 @@ pub async fn should_send_transaction( ) -> eyre::Result { let relayer = app.db.get_relayer(relayer_id).await?; - for gas_limit in &relayer.gas_limits.0 { + for gas_limit in &relayer.gas_price_limits.0 { let chain_fees = app .db .get_latest_block_fees_by_chain_id(relayer.chain_id) diff --git a/src/db.rs b/src/db.rs index 0504c67..90b65d1 100644 --- a/src/db.rs +++ b/src/db.rs @@ -101,16 +101,16 @@ impl Database { .await?; } - if let Some(gas_limits) = &update.gas_limits { + if let Some(gas_price_limits) = &update.gas_price_limits { sqlx::query( r#" UPDATE relayers - SET gas_limits = $2 + SET gas_price_limits = $2 WHERE id = $1 "#, ) .bind(id) - .bind(Json(gas_limits)) + .bind(Json(gas_price_limits)) .execute(tx.as_mut()) .await?; } @@ -132,7 +132,7 @@ impl Database { nonce, current_nonce, max_inflight_txs, - gas_limits + gas_price_limits FROM relayers "#, ) @@ -152,7 +152,7 @@ impl Database { nonce, current_nonce, max_inflight_txs, - gas_limits + gas_price_limits FROM relayers WHERE id = $1 "#, @@ -1090,7 +1090,7 @@ mod tests { use super::*; use crate::db::data::U256Wrapper; - use crate::types::RelayerGasLimit; + use crate::types::RelayerGasPriceLimit; async fn setup_db() -> eyre::Result<(Database, DockerContainerGuard)> { let db_container = postgres_docker_utils::setup().await?; @@ -1230,14 +1230,14 @@ mod tests { assert_eq!(relayer.nonce, 0); assert_eq!(relayer.current_nonce, 0); assert_eq!(relayer.max_inflight_txs, 5); - assert_eq!(relayer.gas_limits.0, vec![]); + assert_eq!(relayer.gas_price_limits.0, vec![]); db.update_relayer( relayer_id, &RelayerUpdate { relayer_name: None, max_inflight_txs: Some(10), - gas_limits: Some(vec![RelayerGasLimit { + gas_price_limits: Some(vec![RelayerGasPriceLimit { chain_id: 1, value: U256Wrapper(U256::from(10_123u64)), }]), @@ -1256,8 +1256,8 @@ mod tests { assert_eq!(relayer.current_nonce, 0); assert_eq!(relayer.max_inflight_txs, 10); assert_eq!( - relayer.gas_limits.0, - vec![RelayerGasLimit { + relayer.gas_price_limits.0, + vec![RelayerGasPriceLimit { chain_id: 1, value: U256Wrapper(U256::from(10_123u64)), }] diff --git a/src/types.rs b/src/types.rs index 47fd120..c7373aa 100644 --- a/src/types.rs +++ b/src/types.rs @@ -42,7 +42,7 @@ pub struct RelayerInfo { pub current_nonce: u64, #[sqlx(try_from = "i64")] pub max_inflight_txs: u64, - pub gas_limits: Json>, + pub gas_price_limits: Json>, } #[derive(Deserialize, Serialize, Debug, Clone, Default)] @@ -55,12 +55,12 @@ pub struct RelayerUpdate { pub max_inflight_txs: Option, #[serde(default)] - pub gas_limits: Option>, + pub gas_price_limits: Option>, } #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] #[serde(rename_all = "camelCase")] -pub struct RelayerGasLimit { +pub struct RelayerGasPriceLimit { pub value: U256Wrapper, pub chain_id: i64, } @@ -82,7 +82,7 @@ mod tests { nonce: 0, current_nonce: 0, max_inflight_txs: 0, - gas_limits: Json(vec![RelayerGasLimit { + gas_price_limits: Json(vec![RelayerGasPriceLimit { value: U256Wrapper(U256::zero()), chain_id: 1, }]), @@ -100,7 +100,7 @@ mod tests { "nonce": 0, "currentNonce": 0, "maxInflightTxs": 0, - "gasLimits": [ + "gasPriceLimits": [ { "value": "0x0", "chainId": 1