Skip to content

feat(runtime): use committee origin for pallet asset-index#300

Merged
mattsse merged 8 commits intomainfrom
cl/origins
Aug 31, 2021
Merged

feat(runtime): use committee origin for pallet asset-index#300
mattsse merged 8 commits intomainfrom
cl/origins

Conversation

@clearloop
Copy link
Contributor

@clearloop clearloop commented Aug 30, 2021

@clearloop clearloop changed the title feat(runtime): check and update origins for all pallets feat(runtime): use committee origin for pallet asset-index Aug 30, 2021
@dutterbutter dutterbutter added the WIP Work in progress - do not review or merge label Aug 30, 2021
@clearloop
Copy link
Contributor Author

clearloop commented Aug 31, 2021

This PR simply add an interface for creating feed in pallet price-feed

The benchmarks of asset-index is still broken with:

Error:                                                                                                                                 
* Pallet: AssetIndex                                                                                                                   
* Benchmark: deposit                                                                                                                   
* Lowest_range_values: []                                                                                                              
* Highest_range_values: []                                                                                                             
* Steps: []                                                                                                                            
* Repeat: 1                                                                                                                            
* Verify: true                                                                                                                         
* Error message: An overflow would occur 

Which is from the pallet-chainlink-feed, tried submit round in the chainlink-feed node-template directly, not working as well with Error::ReportingOrder

@clearloop clearloop marked this pull request as ready for review August 31, 2021 06:55
@clearloop clearloop requested a review from mattsse August 31, 2021 06:55
@clearloop clearloop added needs review PR needs reviewing and removed WIP Work in progress - do not review or merge labels Aug 31, 2021
Copy link
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the price feed benchmark extensions and I don't think we should add this like that because the PriceFeedBenchmarks is very invasive. But maybe I didn't get the problem.

Comment on lines +268 to +306
#[cfg(feature = "runtime-benchmarks")]
impl<T: Config> PriceFeedBenchmarks<T::AccountId, T::AssetId> for Pallet<T> {
fn create_feed(
caller: <T as frame_system::Config>::AccountId,
asset_id: T::AssetId,
) -> DispatchResultWithPostInfo {
use frame_benchmarking::vec;

pallet_chainlink_feed::Pallet::<T>::set_feed_creator(
<frame_system::Origin<T>>::Signed(pallet_chainlink_feed::Pallet::<T>::pallet_admin()).into(),
caller.clone(),
)?;

pallet_chainlink_feed::Pallet::<T>::create_feed(
<frame_system::Origin<T>>::Signed(caller.clone()).into(),
100u32.into(),
Zero::zero(),
(1u8.into(), 100u8.into()),
1u8.into(),
8u8,
vec![1; T::StringLimit::get() as usize],
Zero::zero(),
vec![(caller.clone(), caller.clone())],
None,
None,
)?;

let feed_id = <pallet_chainlink_feed::FeedCounter<T>>::get() - 1.into();
AssetFeeds::<T>::insert(&asset_id, feed_id);
pallet_chainlink_feed::Pallet::<T>::submit(
<frame_system::Origin<T>>::Signed(caller.clone()).into(),
feed_id,
1_u32.into(),
42.into(),
)?;
Ok(().into())
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially a mock?
I'm rather against adding this. Can you extend on why this is necessary, we should fix this upstream if this is a problem of the chainlink pallet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'm thinking of fixing it in the chainlink repo and open another issue for this

@mattsse mattsse added needs changes PR needs changes and removed needs review PR needs reviewing labels Aug 31, 2021
@mattsse
Copy link
Contributor

mattsse commented Aug 31, 2021

Also there is already the Feedbuilder we use for price feed tests https://github.com/ChainSafe/PINT/blob/bb27364ebe9cc7021860630aa7502e80bc6b7999/pallets/price-feed/src/mock.rs
can't we use that instead?

@clearloop
Copy link
Contributor Author

Also there is already the Feedbuilder we use for price feed tests https://github.com/ChainSafe/PINT/blob/bb27364ebe9cc7021860630aa7502e80bc6b7999/pallets/price-feed/src/mock.rs
can't we use that instead?

The dependencies benchmarks depend on are not as same as the tests, they are using the real runtimes, and whatever we have MockPriceFeed or Feedbuilder, the benchmarks don't care about these, they only work for tests ( including the tests in benchmarks ), but not work for benchmarks,

So if we want to generate weights for extrinsics like deposit in pallet asset-index, we need to create_feed and submit a round in the pallet asset-index, it used to be workable because we had a cache for the price of a new asset before

@mattsse
Copy link
Contributor

mattsse commented Aug 31, 2021

gotcha,
this is probably solvable because the PriceFeed pallet is also chainlink_feed_pallet::Pallet so you should be able to access that, and we need to enable this in the runtime section as well?
this could work?

@clearloop
Copy link
Contributor Author

clearloop commented Aug 31, 2021

gotcha,
this is probably solvable because the PriceFeed pallet is also chainlink_feed_pallet::Pallet so you should be able to access that, and we need to enable this in the runtime section as well?
this could work?

Yep, and this PriceFeedBenchmarks is for this creating feed requirement, tried to re-generate weights for all pallets, both asset-index and saft-registry have the overflow problem mentioned above, not certain about why it happens currently now

Considering if it is caused by the chainlink pallet is that I had tried to submit a feed directly on the UI with the node-template of chainlink-feed in master branch, and it has problems, but after seeing the saft-registry has the same overflow problem, I'm thinking of if there are any other problems

@mattsse
Copy link
Contributor

mattsse commented Aug 31, 2021

Okay seems we need to track this down.
Can you please split the committee origin and create a separate PR for this?

@clearloop
Copy link
Contributor Author

Okay seems we need to track this down.
Can you please split the committee origin and create a separate PR for this?

Yep, in #305 now =.=

Copy link
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mattsse mattsse merged commit 8f0a83e into main Aug 31, 2021
@mattsse mattsse deleted the cl/origins branch August 31, 2021 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs changes PR needs changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Supports creating feed in price-feed in feature runtime-benchmarks

3 participants