Git Product home page Git Product logo

octopus-pallets's Introduction

octopus-pallets

Collection of pallets used in Octopus Network

pallets

  • Metadata of an appchain. Including appchain identifier, RPC endpoint of mainchain, etc.
  • Validators of the appchain will observe the mainchain and submit the observed events using OCW for consensus.
  • An implementation of Octopus Network's LPoS.
  • This pallet depends on pallet-octopus-appchain.
  • Some common traits and types.
  • This pallet manages the cross-chain messages sent from appchain to mainchain.

octopus-pallets's People

Contributors

anonymousgiga avatar davirain-su avatar en avatar payfv avatar stewartye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

octopus-pallets's Issues

branch main: test failed need to fix

warning: use of deprecated associated function `frame_support::pallet_prelude::StorageDoubleMap::<Prefix, Hasher1, Key1, Hasher2, Key2, Value, QueryKind, OnEmpty, MaxValues>::remove_prefix`: Use `clear_prefix` instead
   --> lpos/src/lib.rs:794:21
    |
794 |         <ErasStakers<T>>::remove_prefix(era_index, None);
    |                           ^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: `pallet-octopus-lpos` (lib) generated 1 warning
error[E0437]: type `ClassId` is not a member of trait `pallet_uniques::Config`
   --> appchain/src/mock.rs:268:2
    |
268 |     type ClassId = ClassId;
    |     ^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `pallet_uniques::Config`

error[E0437]: type `InstanceId` is not a member of trait `pallet_uniques::Config`
   --> appchain/src/mock.rs:269:2
    |
269 |     type InstanceId = InstanceId;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `pallet_uniques::Config`

error[E0437]: type `ClassDeposit` is not a member of trait `pallet_uniques::Config`
   --> appchain/src/mock.rs:272:2
    |
272 |     type ClassDeposit = ClassDeposit;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `pallet_uniques::Config`

error[E0437]: type `InstanceDeposit` is not a member of trait `pallet_uniques::Config`
   --> appchain/src/mock.rs:273:2
    |
273 |     type InstanceDeposit = InstanceDeposit;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `pallet_uniques::Config`
....

Should we manage assets type automatically in substrate side?

We've noticed that AssetIdByName is configured in genesis config, and tokens in NEAR should be placed into it and never updated.
Can we just update it automatically every time when substrate finds it is a new token type.

octopus-pallets/appchain/src/lib.rs

        #[pallet::genesis_build]
	impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
		fn build(&self) {
			<AnchorContract<T>>::put(self.anchor_contract.as_bytes());

			<NextSetId<T>>::put(1); // set 0 is already in the genesis
			<PlannedValidators<T>>::put(self.validators.clone());

			let account_id = <Pallet<T>>::account_id();
			let min = T::Currency::minimum_balance();
			let amount =
				self.premined_amount.checked_into().ok_or(Error::<T>::AmountOverflow).unwrap();
			if amount >= min {
				T::Currency::make_free_balance_be(&account_id, amount);
			}

			<PalletAccount<T>>::put(account_id);

			for (token_id, id) in self.asset_id_by_name.iter() {
				<AssetIdByName<T>>::insert(token_id.as_bytes(), id);
			}
		}
	}
       Observation::LockAsset(event) => {
            Self::increase_next_notification_id()?;
            let mut result = NotificationResult::Success;
            if let Ok(asset_id) = <AssetIdByName<T>>::try_get(&event.token_id) {
              log!(
                info,
                "️️️mint asset:{:?}, sender_id:{:?}, receiver:{:?}, amount:{:?}",
                asset_id,
                event.sender_id,
                event.receiver,
                event.amount,
              );
              if let Err(error) = Self::mint_asset_inner(
                asset_id,
                event.sender_id.clone(),
                event.receiver.clone(),
                event.amount,
              ) {
                log!(warn, "️️️failed to mint asset: {:?}", error);
                Self::deposit_event(Event::AssetMintFailed(
                  asset_id,
                  event.sender_id,
                  event.receiver,
                  event.amount,
                ));
                result = NotificationResult::AssetMintFailed;
              }
            }                                

cargo test: pallet-appchain test faild

octopus-pallets on  feature/add-chainbridge [!?] via 🦀 v1.65.0-nightly took 7s
❯ cargo test
   Compiling pallet-octopus-appchain v4.0.0-pre.0 (/Users/davirain/octopus/octopus-pallets/appchain)
   Compiling pallet-octopus-lpos v4.0.0-pre.0 (/Users/davirain/octopus/octopus-pallets/lpos)
error[E0061]: this function takes 7 arguments but 6 arguments were supplied
    --> appchain/src/tests.rs:659:3
     |
659  |         OctopusAppchain::observing_mainchain(
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
662  |             b"oct-test.testnet".to_vec(),
     |             ---------------------------- an argument of type `&str` is missing
     |
note: associated function defined here
    --> appchain/src/lib.rs:1228:10
     |
1228 |         pub fn observing_mainchain(
     |                ^^^^^^^^^^^^^^^^^^^
1229 |             block_number: T::BlockNumber,
     |             ----------------------------
1230 |             mainchain_rpc_endpoint: &str,
     |             ----------------------------
1231 |             secondary_mainchain_rpc_endpoint: &str,
     |             --------------------------------------
1232 |             anchor_contract: Vec<u8>,
     |             ------------------------
1233 |             public: <T as SigningTypes>::Public,
     |             -----------------------------------
1234 |             key_data: Vec<u8>,
     |             -----------------
1235 |             _validator_id: T::AccountId,
     |             ---------------------------
help: provide the argument
     |
659  |         OctopusAppchain::observing_mainchain(2, "https://rpc.testnet.near.org", /* &str */, b"oct-test.testnet".to_vec(), public.clone(), public.into_account().encode(), account)
     |

error[E0061]: this function takes 7 arguments but 6 arguments were supplied
    --> appchain/src/tests.rs:732:3
     |
732  |         OctopusAppchain::observing_mainchain(
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
735  |             b"oct-test.testnet".to_vec(),
     |             ---------------------------- an argument of type `&str` is missing
     |
note: associated function defined here
    --> appchain/src/lib.rs:1228:10
     |
1228 |         pub fn observing_mainchain(
     |                ^^^^^^^^^^^^^^^^^^^
1229 |             block_number: T::BlockNumber,
     |             ----------------------------
1230 |             mainchain_rpc_endpoint: &str,
     |             ----------------------------
1231 |             secondary_mainchain_rpc_endpoint: &str,
     |             --------------------------------------
1232 |             anchor_contract: Vec<u8>,
     |             ------------------------
1233 |             public: <T as SigningTypes>::Public,
     |             -----------------------------------
1234 |             key_data: Vec<u8>,
     |             -----------------
1235 |             _validator_id: T::AccountId,
     |             ---------------------------
help: provide the argument
     |
732  |         OctopusAppchain::observing_mainchain(2, "https://rpc.testnet.near.org", /* &str */, b"oct-test.testnet".to_vec(), public.clone(), public.into_account().encode(), account)
     |

For more information about this error, try `rustc --explain E0061`.
error: could not compile `pallet-octopus-appchain` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.