1.0.2 • Published 2 months ago

@ipcexplorer/ipcpay-sdk v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

IPCPay

Introduction

Welcome to project, where we showcase the power of scalability through Interplanetary Consensus (IPC). In this project, we demonstrate how IPC enables on-demand horizontal scalability of networks, making it possible for decentralized applications (dApps) to reach planetary scale.

Project Overview

Our project focuses on creating and interacting with different subsets within the IPC framework. By leveraging IPC's capabilities, we aim to highlight the seamless scalability and robustness it offers for dApps.

Features

  • Dynamic Subnet Creation: We demonstrate the ability to create subsets within the IPC framework on demand, showcasing the flexibility and scalability of IPC.

  • Subnet Transactions: Our project includes transactions performed within these subsets, illustrating the sub-second transaction capabilities enabled by IPC.

  • Hierarchical Subnet Organization: We organize subsets in a hierarchical structure, showcasing IPC's capability to manage and communicate between different layers of subnets efficiently.

  • Cross-Subnet Communication: We highlight IPC's native support for cross-subnet communication, eliminating the need for custom bridges and enabling seamless interaction between subsets.

  • Scalability Demo: Through simulated workload scenarios, we demonstrate how IPC dynamically adjusts throughput by spawning and closing temporary subnets as needed, ensuring optimal performance.

Technologies Used

  • Interplanetary Consensus (IPC): Our project is built on top of IPC, leveraging its framework for scalability and consensus.

  • Filecoin Virtual Machine (FVM): We utilize FVM as the execution layer, enabling us to deploy smart contracts and execute transactions within IPC subnets.

  • Tendermint Core: Tendermint is utilized as the consensus engine within the IPC subnets, ensuring Byzantine fault tolerance and consistent ledger maintenance.

  • WebAssembly (WASM): We leverage WASM for smart contract execution, providing flexibility and compatibility with multiple programming languages.

(https://github.com/theincubators/ipcpay-sdk)

IPC Subnet - Creating and Demonstration

Overview

In this section, we delve into the process of creating IPC subnets and demonstrate their functionality within our project. IPC subnets are the building blocks of scalable networks, offering flexibility and adaptability to meet various application requirements.

Subnet Creation

On-Demand Horizontal Scalability

One of the key features of IPC is the ability to create subnets on demand, allowing for horizontal scalability of networks. Within our project, we showcase the process of dynamically creating subnets to accommodate varying workload demands.

Hierarchical Organization

Subnets are organized in a hierarchical structure, with parent subnets capable of spawning infinite child subnets. This hierarchical organization enables efficient communication and resource management within the IPC framework.

Subnet Demonstration

Seamless Transaction Execution

Transactions within IPC subnets occur seamlessly, thanks to the robust consensus mechanisms and efficient communication protocols. Our project demonstrates the sub-second transaction capabilities enabled by IPC, showcasing the speed and reliability of transaction execution.

Inter-Subnet Communication

IPC facilitates native communication between subnets, eliminating the need for custom bridges or protocols. Through our demonstration, we highlight the seamless interaction between different layers of subnets, showcasing IPC's capability to manage cross-subnet communication efficiently.

Scalability Showcase

Dynamic Throughput Adjustment

IPC-powered networks can dynamically adjust their throughput by spawning and closing temporary subnets as needed. In our demonstration, we simulate varying workload scenarios to showcase how IPC efficiently manages network resources and adapts to changing demands.

Performance Metrics

We provide performance metrics and benchmarks to quantify the scalability and efficiency of IPC subnets. Through these metrics, we aim to demonstrate the superior performance and reliability offered by IPC for decentralized applications.

Conclusion

The creation and demonstration of IPC subnets within our project exemplify the power and versatility of IPC as a scalable network framework. By showcasing the seamless creation, efficient communication, and dynamic scalability of subnets, we aim to highlight the transformative potential of IPC for decentralized applications.

Usecases

Distributed Computation

IPC enables the creation of ephemeral subnets for distributed computation jobs. This use case is ideal for scenarios requiring extensive computational power, such as AI model training, data analysis, and scientific simulations.

Coordination

IPC subnets offer decentralized orchestration with high throughput and low fees. This use case is suitable for applications requiring coordination among multiple parties, such as supply chain management, decentralized autonomous organizations (DAOs), and real-time collaboration platforms.

Localization

IPC allows for the deployment of subnets in geographically constrained settings, enabling low-latency operation and improved performance. This use case is beneficial for applications requiring real-time interaction or localized services, such as gaming platforms, IoT networks, and location-based services.

Partition Tolerance

IPC subnets can be deployed in environments with limited connectivity, such as mobile settings or remote areas. This use case ensures uninterrupted operation and data availability in challenging network conditions.

Why to Use IPC & How to Use IPC

Why Use IPC?

  • Scalability: IPC offers on-demand horizontal scalability, allowing applications to reach planetary scale.

  • Sub-Second Transactions: IPC enables fast and reliable transaction execution, facilitating high-frequency trading and real-time interactions.

  • Decentralization: IPC promotes decentralization by allowing seamless communication between subnets and ensuring network resilience.

  • Flexibility: IPC's modular architecture and customizable consensus algorithms provide developers with flexibility to tailor networks according to application requirements.

How to Use IPC

  1. Deploy Subnets: Create subnets based on scalability requirements and application needs.

  2. Interact with Subnets: Perform transactions, execute smart contracts, and communicate between subnets using IPC's native protocols.

  3. Optimize Performance: Dynamically adjust network throughput by spawning and closing temporary subnets as needed.

  4. Monitor and Manage: Monitor network performance, manage resources, and optimize parameters to ensure optimal operation.

Why There's a Need to Use Subnet

Scalability

Subnets enable on-demand horizontal scalability, allowing networks to accommodate increasing user demand and transaction volume without sacrificing performance.

Modularity

Subnets provide a modular approach to network organization, allowing developers to segment applications or services based on specific requirements and functionalities.

Resource Management

By creating separate subnets, developers can efficiently manage network resources, allocate compute power, and optimize performance for different use cases.

Fault Isolation

Subnets offer fault isolation, ensuring that issues or failures within one subnet do not affect the overall network operation. This enhances network resilience and reliability.


How to use in cli:

I have worked in cli, follow below doc: https://github.com/Amarnath-Rao/deh-ipc-proto/blob/main/ipc-cli-usage.md

Advanced Subnet Customization:

Advanced subnet customization within IPC empowers developers with unparalleled flexibility to tailor network configurations according to specific requirements. With custom consensus algorithms, dynamic resource allocation, and smart contract customization, developers can optimize performance, enhance security, and implement complex functionalities tailored to diverse use cases. Interoperability features enable seamless integration with external systems, while governance models ensure transparent decision-making and community participation. By leveraging these advanced customization options, developers can create robust and scalable decentralized applications that meet the evolving needs of users and stakeholders, setting new standards for innovation in the blockchain space.

Transactions:

  • refer subnet creation part, where metamask i used to make transactions

Architecture

image image image

Future Improvements

While our project demonstrates the core features of IPC, there are several areas for future enhancement:

  • Enhanced User Interface: Improving the UI for better user experience and accessibility.

  • Advanced Transaction Scenarios: Incorporating more complex transaction scenarios to showcase IPC's versatility.

  • Integration with Other Chains: Exploring interoperability with other blockchain networks to expand the project's scope.

  • Optimization and Performance Tuning: Fine-tuning the project for optimal performance and efficiency.

Development

Running locally

First, clone the repository and cd into its directory:

Now, simply run the following commands to install all required packages and run a development server:

npm install
npm run dev

The application is running at http://localhost:5000.

Connecting to a local subnet RPC

You can only connect to a local subnet RPC from a locally running application due to same-origin policy. You also need a workaround because Fendermint Ethereum API Facade doesn't set CORS headers that would allow such connection from your browser.

The suggested workaround is to run a reverse proxy that sets required CORS headers. In the following instruction, it's assumed that you're already running a subnet with Ethereum API Facade listening on http://localhost:8545. This should be the case if you followed the official instruction about deploying a subnet.

  1. Install mitmproxy.
  2. Run it with a custom cors.py module:
mitmdump --mode reverse:http://localhost:8545 --listen-host localhost --listen-port 9545 -s mitmproxy/cors.py

Now you should be able to connect to subnet RPC from the locally running application. Note the non-standard provider URL (which is our reverse proxy) that you must enter after you click on the "Connect" button in the application:

http://localhost:9545

Manual testing using ipc-cli

The following is a simplified and limited version of the official documentation about deploying a subnet. If you need a fully operational subnet follow the official instructions instead.

  1. First, you need to build a Docker image for ipc-cli:
make build-ipc-cli-docker
  1. Initialize your ipc-cli config:
mkdir .ipc

cat << EOF > .ipc/config.toml
keystore_path = "~/.ipc-keystore"

[[subnets]]
id = "/r314159"

[subnets.config]
network_type = "fevm"
provider_http = "https://api.calibration.node.glif.io/rpc/v1"
gateway_addr = "`curl -s https://raw.githubusercontent.com/consensus-shipyard/ipc/cd/contracts/deployments/r314159.json | jq -r '.gateway_addr'`"
registry_addr = "`curl -s https://raw.githubusercontent.com/consensus-shipyard/ipc/cd/contracts/deployments/r314159.json | jq -r '.registry_addr'`"
EOF

Note the non-default keystore_path. This is the path where a Docker volume will be mounted to persist wallet keys for the ipc-cli container.

  1. Set up a new wallet.
make ipc-cli-new-wallet

Make note of the address of the wallet you created. And set it as your default wallet:

wallet=NEW_WALLET_ADDRESS make ipc-cli-set-default-wallet
  1. Go to the Calibration faucet and get some funds sent to this new wallet.

Create a child subnet

make ipc-cli-create-subnet

Make a note of the address of the subnet you created.

Join the subnet from your validator (i.e., the wallet you created earlier)

First, get the public key of your wallet and note it down:

wallet=NEW_WALLET_ADDRESS make ipc-cli-wallet-pub-key

Now, join the subnet:

subnet=NEW_SUBNET_ID pubkey=NEW_WALLET_PUBKEY make ipc-cli-join-subnet

Deposit funds

subnet=NEW_SUBNET_ID amount=0.01 make ipc-cli-fund

Withdraw funds

Withdrawing funds requires a running subnet.

Acknowledgements

We would like to express our gratitude to the IPC community and the organizers of the hackathon for providing this opportunity to showcase our project.

Conclusion:

In real-life scenarios and project implementations, the advanced subnet customization offered by IPC serves as a cornerstone for building scalable, efficient, and adaptable decentralized applications (dApps). By tailoring network configurations to specific requirements, developers can address diverse use cases across various industries, including finance, supply chain, gaming, and more. With custom consensus algorithms, dynamic resource allocation, and interoperability features, IPC enables the creation of decentralized solutions that offer enhanced performance, security, and usability. Ultimately, by harnessing the power of advanced subnet customization, projects can revolutionize the way we interact with technology, unlocking new possibilities for innovation and collaboration in the decentralized ecosystem.

1.0.2

2 months ago

1.0.1

2 months ago