diff --git a/Cargo.lock b/Cargo.lock index 3cebb932..164e3e06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -471,7 +471,7 @@ dependencies = [ [[package]] name = "casper-binary-port" version = "1.0.0" -source = "git+https://github.com/casper-network/casper-node.git?branch=feat-2.0#2d6c295ae88efdfef10a1297d8845bdfe19fd774" +source = "git+https://github.com/casper-network/casper-node.git?branch=feat-2.0#488a5f96534b26580cfee18c96fd7af1cf57af33" dependencies = [ "bincode", "bytes", @@ -673,7 +673,7 @@ dependencies = [ [[package]] name = "casper-types" version = "5.0.0" -source = "git+https://github.com/casper-network/casper-node.git?branch=feat-2.0#2d6c295ae88efdfef10a1297d8845bdfe19fd774" +source = "git+https://github.com/casper-network/casper-node.git?branch=feat-2.0#488a5f96534b26580cfee18c96fd7af1cf57af33" dependencies = [ "base16", "base64 0.13.1", diff --git a/resources/test/rpc_schema.json b/resources/test/rpc_schema.json index 44648560..fa4702fb 100644 --- a/resources/test/rpc_schema.json +++ b/resources/test/rpc_schema.json @@ -1571,7 +1571,8 @@ "api_version", "delegation_rate", "era_id", - "reward_amount" + "reward_amount", + "switch_block_hash" ], "properties": { "api_version": { @@ -1591,6 +1592,10 @@ "type": "integer", "format": "uint8", "minimum": 0.0 + }, + "switch_block_hash": { + "description": "The switch block hash at which the reward was distributed.", + "$ref": "#/components/schemas/BlockHash" } }, "additionalProperties": false @@ -1621,7 +1626,8 @@ "api_version": "2.0.0", "reward_amount": "42", "era_id": 1, - "delegation_rate": 20 + "delegation_rate": 20, + "switch_block_hash": "0000000000000000000000000000000000000000000000000000000000000000" } } } diff --git a/rpc_sidecar/src/rpcs/info.rs b/rpc_sidecar/src/rpcs/info.rs index 08b74970..632e2d68 100644 --- a/rpc_sidecar/src/rpcs/info.rs +++ b/rpc_sidecar/src/rpcs/info.rs @@ -104,6 +104,7 @@ static GET_REWARD_RESULT: Lazy = Lazy::new(|| GetRewardResult { reward_amount: U512::from(42), era_id: EraId::new(1), delegation_rate: 20, + switch_block_hash: BlockHash::default(), }); /// Params for "info_get_deploy" RPC request. @@ -550,6 +551,8 @@ pub struct GetRewardResult { pub era_id: EraId, /// The delegation rate of the validator. pub delegation_rate: u8, + /// The switch block hash at which the reward was distributed. + pub switch_block_hash: BlockHash, } impl DocExample for GetRewardResult { @@ -588,6 +591,7 @@ impl RpcWithParams for GetReward { reward_amount: result.amount(), era_id: result.era_id(), delegation_rate: result.delegation_rate(), + switch_block_hash: result.switch_block_hash(), }) } } @@ -820,12 +824,14 @@ mod tests { let validator = PublicKey::random(rng); let delegator = rng.gen::().then(|| PublicKey::random(rng)); let delegation_rate = rng.gen_range(0..100); + let switch_block_hash = BlockHash::random(rng); let resp = GetReward::do_handle_request( Arc::new(RewardMock { reward_amount, era_id, delegation_rate, + switch_block_hash, }), GetRewardParams { era_identifier: Some(EraIdentifier::Era(era_id)), @@ -842,7 +848,8 @@ mod tests { api_version: CURRENT_API_VERSION, reward_amount, era_id, - delegation_rate + delegation_rate, + switch_block_hash } ); } @@ -901,6 +908,7 @@ mod tests { reward_amount: U512, era_id: EraId, delegation_rate: u8, + switch_block_hash: BlockHash, } #[async_trait] @@ -914,8 +922,12 @@ mod tests { if InformationRequestTag::try_from(info_type_tag) == Ok(InformationRequestTag::Reward) => { - let resp = - RewardResponse::new(self.reward_amount, self.era_id, self.delegation_rate); + let resp = RewardResponse::new( + self.reward_amount, + self.era_id, + self.delegation_rate, + self.switch_block_hash, + ); Ok(BinaryResponseAndRequest::new( BinaryResponse::from_value(resp, SUPPORTED_PROTOCOL_VERSION), &[],