From 7ed8621216e7b232ae715d8e0d8d22893bef47b1 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 9 Sep 2024 07:55:06 +0200 Subject: [PATCH 1/4] [pallet-revive] move event topics in event's body --- substrate/frame/revive/src/benchmarking/mod.rs | 6 +----- substrate/frame/revive/src/exec.rs | 10 ++++------ substrate/frame/revive/src/lib.rs | 10 ++-------- substrate/frame/revive/src/tests.rs | 5 +++-- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/substrate/frame/revive/src/benchmarking/mod.rs b/substrate/frame/revive/src/benchmarking/mod.rs index 8cdd7da5db9d..8601f5f53542 100644 --- a/substrate/frame/revive/src/benchmarking/mod.rs +++ b/substrate/frame/revive/src/benchmarking/mod.rs @@ -772,11 +772,7 @@ mod benchmarks { assert_eq!( record.event, - crate::Event::ContractEmitted { contract: instance.address(), data }.into(), - ); - assert_eq!( - record.topics.iter().map(|t| H256::from_slice(t.as_ref())).collect::>(), - topics, + crate::Event::ContractEmitted { contract: instance.address(), data, topics }.into(), ); } diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 016bdec37afd..468f5aa8240e 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -1487,13 +1487,11 @@ where } fn deposit_event(&mut self, topics: Vec, data: Vec) { - Contracts::::deposit_indexed_event( + Contracts::::deposit_event(Event::ContractEmitted { + contract: T::AddressMapper::to_address(self.account_id()), + data, topics, - Event::ContractEmitted { - contract: T::AddressMapper::to_address(self.account_id()), - data, - }, - ); + }); } fn block_number(&self) -> U256 { diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 4c6e5cd26a11..18117c7e6f68 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -406,6 +406,8 @@ pub mod pallet { /// Data supplied by the contract. Metadata generated during contract compilation /// is needed to decode it. data: Vec, + /// A list of topics used to index the event. + topics: Vec, }, /// A code with the specified hash was removed. @@ -1186,14 +1188,6 @@ where fn deposit_event(event: Event) { >::deposit_event(::RuntimeEvent::from(event)) } - - /// Deposit a pallet contracts indexed event. - fn deposit_indexed_event(topics: Vec, event: Event) { - >::deposit_event_indexed( - &topics.into_iter().map(Into::into).collect::>(), - ::RuntimeEvent::from(event).into(), - ) - } } // Set up a global reference to the boolean flag used for the re-entrancy guard. diff --git a/substrate/frame/revive/src/tests.rs b/substrate/frame/revive/src/tests.rs index f2944c7932a6..73914c9aae07 100644 --- a/substrate/frame/revive/src/tests.rs +++ b/substrate/frame/revive/src/tests.rs @@ -678,9 +678,10 @@ mod run_tests { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { contract: addr, - data: vec![1, 2, 3, 4] + data: vec![1, 2, 3, 4], + topics: vec![H256::repeat_byte(42)], }), - topics: vec![H256::repeat_byte(42)], + topics: vec![], }, EventRecord { phase: Phase::Initialization, From 6e608044cebdcaf8f0f252923fd8bead536a379f Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 9 Sep 2024 07:56:55 +0200 Subject: [PATCH 2/4] Add prdoc --- prdoc/pr_5640.prdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 prdoc/pr_5640.prdoc diff --git a/prdoc/pr_5640.prdoc b/prdoc/pr_5640.prdoc new file mode 100644 index 000000000000..a589816f8828 --- /dev/null +++ b/prdoc/pr_5640.prdoc @@ -0,0 +1,10 @@ +title: "[pallet-revive] Move event's topics" + +doc: + - audience: Runtime Dev + description: | + Move event's topics inside body + +crates: + - name: pallet-revive + bump: patch From b59530fbefce1c705c402861a8d063f2f9ca1fda Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 9 Sep 2024 08:26:48 +0200 Subject: [PATCH 3/4] fix prdoc --- prdoc/pr_5640.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_5640.prdoc b/prdoc/pr_5640.prdoc index a589816f8828..fdd7f5e1b893 100644 --- a/prdoc/pr_5640.prdoc +++ b/prdoc/pr_5640.prdoc @@ -7,4 +7,4 @@ doc: crates: - name: pallet-revive - bump: patch + bump: major From f772a978cd44e1d6d0c7e4525fad4db91bdd4ee8 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Mon, 9 Sep 2024 08:30:08 +0200 Subject: [PATCH 4/4] Update doc --- substrate/frame/revive/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/frame/revive/src/lib.rs b/substrate/frame/revive/src/lib.rs index 18117c7e6f68..d1e17fb7b390 100644 --- a/substrate/frame/revive/src/lib.rs +++ b/substrate/frame/revive/src/lib.rs @@ -406,7 +406,8 @@ pub mod pallet { /// Data supplied by the contract. Metadata generated during contract compilation /// is needed to decode it. data: Vec, - /// A list of topics used to index the event. + /// A list of topics used to index the event. + /// Number of topics is capped by [`limits::NUM_EVENT_TOPICS`]. topics: Vec, },