From 5037171f4e929c216ffbbdba3c3b90ef08f9ad84 Mon Sep 17 00:00:00 2001 From: bap2pecs <111917526+bap2pecs@users.noreply.github.com> Date: Sat, 5 Oct 2024 07:23:21 -0400 Subject: [PATCH] [OP] chore: remove unused activated_height (#77) ## Summary after https://github.com/babylonlabs-io/finality-provider/pull/42, we no longer need to read activated height from the cw contract. instead, we properly find the time when the first delegation became active (see https://github.com/babylonchain/finality-provider/issues/432) so this cleans up the unused field ## Test Plan ``` cargo optimize cargo precommit cargo integration cargo test ``` --- .../schema/op-finality-gadget.json | 12 ------------ .../op-finality-gadget/schema/raw/instantiate.json | 6 ------ .../schema/raw/response_to_config.json | 6 ------ contracts/op-finality-gadget/src/contract.rs | 4 ---- contracts/op-finality-gadget/src/msg.rs | 1 - contracts/op-finality-gadget/src/state/config.rs | 2 -- contracts/op-finality-gadget/tests/integration.rs | 4 ---- 7 files changed, 35 deletions(-) diff --git a/contracts/op-finality-gadget/schema/op-finality-gadget.json b/contracts/op-finality-gadget/schema/op-finality-gadget.json index 3562c8a5..0b2950d7 100644 --- a/contracts/op-finality-gadget/schema/op-finality-gadget.json +++ b/contracts/op-finality-gadget/schema/op-finality-gadget.json @@ -7,17 +7,11 @@ "title": "InstantiateMsg", "type": "object", "required": [ - "activated_height", "admin", "consumer_id", "is_enabled" ], "properties": { - "activated_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "admin": { "type": "string" }, @@ -374,15 +368,9 @@ "description": "Config are OP finality gadget's configuration", "type": "object", "required": [ - "activated_height", "consumer_id" ], "properties": { - "activated_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "consumer_id": { "type": "string" } diff --git a/contracts/op-finality-gadget/schema/raw/instantiate.json b/contracts/op-finality-gadget/schema/raw/instantiate.json index 2a3c35d7..f4a72b19 100644 --- a/contracts/op-finality-gadget/schema/raw/instantiate.json +++ b/contracts/op-finality-gadget/schema/raw/instantiate.json @@ -3,17 +3,11 @@ "title": "InstantiateMsg", "type": "object", "required": [ - "activated_height", "admin", "consumer_id", "is_enabled" ], "properties": { - "activated_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "admin": { "type": "string" }, diff --git a/contracts/op-finality-gadget/schema/raw/response_to_config.json b/contracts/op-finality-gadget/schema/raw/response_to_config.json index d003b077..a2d0a736 100644 --- a/contracts/op-finality-gadget/schema/raw/response_to_config.json +++ b/contracts/op-finality-gadget/schema/raw/response_to_config.json @@ -4,15 +4,9 @@ "description": "Config are OP finality gadget's configuration", "type": "object", "required": [ - "activated_height", "consumer_id" ], "properties": { - "activated_height": { - "type": "integer", - "format": "uint64", - "minimum": 0.0 - }, "consumer_id": { "type": "string" } diff --git a/contracts/op-finality-gadget/src/contract.rs b/contracts/op-finality-gadget/src/contract.rs index 375a17a4..98eb0c88 100644 --- a/contracts/op-finality-gadget/src/contract.rs +++ b/contracts/op-finality-gadget/src/contract.rs @@ -23,7 +23,6 @@ pub fn instantiate( let config = Config { consumer_id: msg.consumer_id, - activated_height: msg.activated_height, }; CONFIG.save(deps.storage, &config)?; @@ -117,13 +116,11 @@ pub(crate) mod tests { let mut deps = mock_dependencies(); let init_admin = deps.api.addr_make(INIT_ADMIN); let consumer_id = "op".to_string(); - let activated_height = 1000; // Create an InstantiateMsg with admin set to init_admin let msg = InstantiateMsg { admin: init_admin.to_string(), consumer_id, - activated_height, is_enabled: true, }; @@ -153,7 +150,6 @@ pub(crate) mod tests { let instantiate_msg = InstantiateMsg { admin: init_admin.to_string(), // Admin provided consumer_id: "op-stack-l2-11155420".to_string(), - activated_height: 13513311, is_enabled: true, }; diff --git a/contracts/op-finality-gadget/src/msg.rs b/contracts/op-finality-gadget/src/msg.rs index d3aa3f70..fa6c6300 100644 --- a/contracts/op-finality-gadget/src/msg.rs +++ b/contracts/op-finality-gadget/src/msg.rs @@ -13,7 +13,6 @@ use babylon_merkle::Proof; pub struct InstantiateMsg { pub admin: String, pub consumer_id: String, - pub activated_height: u64, pub is_enabled: bool, } diff --git a/contracts/op-finality-gadget/src/state/config.rs b/contracts/op-finality-gadget/src/state/config.rs index 932e6e76..aee89183 100644 --- a/contracts/op-finality-gadget/src/state/config.rs +++ b/contracts/op-finality-gadget/src/state/config.rs @@ -11,6 +11,4 @@ pub const IS_ENABLED: Item = Item::new("is_enabled"); #[cw_serde] pub struct Config { pub consumer_id: String, - // activated_height is the consumer chain block height at which the finality gadget is activated - pub activated_height: u64, } diff --git a/contracts/op-finality-gadget/tests/integration.rs b/contracts/op-finality-gadget/tests/integration.rs index d78aa1ba..1145c175 100644 --- a/contracts/op-finality-gadget/tests/integration.rs +++ b/contracts/op-finality-gadget/tests/integration.rs @@ -18,7 +18,6 @@ fn instantiate_works() { let msg = InstantiateMsg { admin: mock_api.addr_make(CREATOR), consumer_id: "op-stack-l2-11155420".to_string(), - activated_height: 13513311, is_enabled: false, }; let info = mock_info(CREATOR, &[]); @@ -30,7 +29,6 @@ fn instantiate_works() { let res: Config = from_json(query(&mut deps, mock_env(), QueryMsg::Config {}).unwrap()).unwrap(); assert_eq!(msg.consumer_id, res.consumer_id); - assert_eq!(msg.activated_height, res.activated_height); // Check the admin is properly stored in the state and returned let res: AdminResponse = @@ -51,7 +49,6 @@ fn disable_and_reenable_works() { let msg = InstantiateMsg { admin: mock_api.addr_make(CREATOR), consumer_id: "op-stack-l2-11155420".to_string(), - activated_height: 13513311, is_enabled: false, }; let info = mock_info(CREATOR, &[]); @@ -111,7 +108,6 @@ fn instantiate_enabled() { let msg = InstantiateMsg { admin: mock_api.addr_make(CREATOR), consumer_id: "op-stack-l2-11155420".to_string(), - activated_height: 13513311, is_enabled: true, }; let info = mock_info(CREATOR, &[]);