aelf 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 41쪽 중 5쪽

chainId : 'AELF' , contractAddress : '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc' , contractName : 'token' , description : 'token contract' , github : '' } , { chainId : 'AELF TEST' , contractAddress : '2Xg2HKh8vusnFMQsHCXW1q3vys5JxG5ZnjiGwNDLrrpb9Mb' , contractName : 'TEST contractName' , description : 'contract description' , github : '' } ] } } , ( error , result ) => { console . log ( 'Login Result:' , result ) ; } ) ; // keychain = { // keypairs: [{ // name: 'your keypairs name', // address: 'your keypairs address', // mnemonic: 'your keypairs mnemonic', // privateKey: 'your keypairs privateKey', // publicKey: { // x: 'f79c25eb......', // y: '7fa959ed......' // } // }], // permissions: [{ // appName: 'hzzTest', // address: 'your keyparis address', // contracts: [{ // chainId: 'AELF', // contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', // contractName: 'token', // description: 'token contract', // github: '' // }], // domain: 'Dapp domain' // }] // } INIT_AELF_CONTRACT ​ Example of initializing a contract: // In aelf-sdk.js wallet is the realy wallet. // But in extension sdk, we just need the address of the wallet. const tokenContract ; const wallet = { address : '2JqnxvDiMNzbSgme2oxpqUFpUYfMjTpNBGCLP2CsWjpbHdu' } ; // It is different from the wallet created by Aelf.wallet.getWalletByPrivateKey(); // There is only one value named address; aelf . chain . contractAtAsync ( '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc' , wallet , ( error , result ) => { console . log ( '>>>>>>>>>>>>> contractAtAsync >>>>>>>>>>>>>' ) ; console . log ( error , result ) ; tokenContract = result ; } ) ; Expected Result : ​ result = { Approve : ƒ ( ) , Burn : ƒ ( ) , ChargeTransactionFees : ƒ ( ) , ClaimTransactionFees : ƒ ( ) , ... . } CALL_AELF_CONTRACT / CALL_AELF_CONTRACT_READONLY ​ Example contract method calls: tokenContract . GetBalance . call ( { symbol : 'AELF' , owner : '65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9' } , ( err , result ) => { console . log ( 'Get Balance Result:' , result ) ; } ) ; tokenContract . Approve ( { symbol : 'AELF' , spender : '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc' , amount : '100' } , ( err , result ) => { console . log ( 'Approve Result:' , result ) ; } ) ; // If you use tokenContract.GetBalance.call this method is only applicable to queries that do not require extended authorization validation.(CALL_AELF_CONTRACT_READONLY) // If you use tokenContract.Approve this requires extended authorization validation (CALL_AELF_CONTRACT) // tokenContract.GetBalance.call(payload, (error, result) => {}) // result = { // symbol: "AELF", // owner: "65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9", // balance: 0 // } CHECK_PERMISSION ​ Example permission check: aelf . checkPermission ( { appName : 'hzzTest' , type : 'address' , address : '4WBgSL2fSem9ABD4LLZBpwP8eEymVSS1AyTBCqXjt5cfxXK' } , ( error , result ) => { console . log ( 'Check Permission Result:' , result ) ; } ) ; Expected Result : ​ result = { ... , permissions : [ { address : '...' , appName : 'hzzTest' , contracts : [ { chainId : 'AELF' , contractAddress : '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc' , contractName : 'token' , description : 'token contract' , github : '' } , { chainId : 'AELF TEST' , contractAddress : 'TEST contractAddress' , contractName : 'TEST contractName' , description : 'contract description' , github : '' } ] , domian : 'Dapp domain' } ] } SET_CONTRACT_PERMISSION ​ Example of removing methods whitelist: aelf . removeContractPermission ( { appName : 'hzzTest' , chainId : 'AELF' , payload : { contractAddress : '2Xg2HKh8vusnFMQsHCXW1q3vys5JxG5ZnjiGwNDLrrpb9Mb' } } , ( error , result ) => { console . log ( 'removeContractPermission>>>>>>>>>>>>>>>>>>>' , result ) ; } ) ; Expected Result ​ keychain = { keypairs : { ... } , permissions : [ { appName : 'hzzTest' , address : 'your keyparis address' , contracts : [ { chainId : 'AELF' , contractAddress : '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc' , contractName : 'token' , description : 'token contract' , github : '' } ] , domain : 'Dapp domain' } ] } REMOVE_METHODS_WHITELIST ​ Example of removing contract permission: aelf . removeContractPermission ( { appName : 'hzzTest' , chainId : 'AELF' , payload : { contractAddress : '2Xg2HKh8vusnFMQsHCXW1q3vys5JxG5ZnjiGwNDLrrpb9Mb' } } , ( error , result ) => { console . log ( 'Remove Contract Permission Result:' , result ) ; } ) ; Expected Result ​ keychain = { keypairs : { ... } , permissions : [ { appName : 'hzzTest' , address : 'your keyparis address' , contracts : [ { chainId : 'AELF' , contractAddress : '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc' , contractName : 'token' , description : 'token contract' , github : '' , whitelist : { } } ] , domain : 'Dapp domain' } ] } For Extension Developers ​ Download the code: git clone https://github.com/hzz780/aelf-web-extension.git Install dependencies: npm install Run webpack: webpack -w Add to the browser: open development mode, add the webpack output app/public. Project Information ​ We use ECDH ` to use public key to encryt data and private key to decrypt data. aelf-web-extension Introduction For Users For DApp Developers How to Use Data Format Demo of Checking the Extension GET_CHAIN_STATUS CALL_AELF_CHAIN LOGIN INIT_AELF_CONTRACT CALL_AELF_CONTRACT / CALL_AELF_CONTRACT_READONLY CHECK_PERMISSION SET_CONTRACT_PERMISSION REMOVE_METHODS_WHITELIST For Extension Developers Project Information ## /resources/devops On this page DevOps Open Source Development ​ At aelf, we prioritize openness and transparency in our development process. Our project is fully open source, and we share our code and current issues online. This approach helps keep our project accessible to everyone. Collaborative Standard ​ We value collaboration and welcome contributions and feedback. However, to maintain high standards, we ask all collaborators to follow these guidelines: Understand aelf : Before contributing, read our white paper and documentation to understand the core concepts and architecture. Reviewing our code and existing functionalities is also recommended. Ask Questions : If you have any questions, open an issue on GitHub. Clearly state what you need to clarify. Submit Pull Requests : When you're ready to contribute, submit a pull request on GitHub. Our core team will review and discuss your submission. If approved, it will be merged into the project. For more details, please refer to our Code of Conduct . Deployment ​ We use the semantic versioning system (SemVer) for version control. For more information, visit SemVer . Daily Builds ​ We have a cron job integrated with GitHub that publishes the latest version of our development packages to MyGet. You can find them here: MyGet: aelf-project-dev Release Branch ​ For stable releases, our packages are available on NuGet: NuGet: AElf Testing ​ Testing is crucial for maintaining and improving software quality. We focus on two main types of testing: unit testing and performance testing. Unit Testing ​ Unit tests ensure the functionality and protocol integrity of our blockchain system. We use the xUnit framework and follow best practices to cover as much functionality as possible. For any new feature, we ensure it is covered by unit tests to prevent regressions and allow safe modifications. Performance Testing ​ Performance testing is vital for aelf, as speed is one of our system's key strengths. These tests help ensure that changes do not negatively impact the transaction and block processing speed of our nodes. Monitoring ​ Server Monitoring ​ We use Zabbix to monitor server metrics such as CPU usage and database performance. Chain Monitoring ​ Our GitHub project includes a Grafana dashboard powered by InfluxDB for chain monitoring. Akka Monitoring ​ We monitor actors in our system using Akka. Open Source Development Collaborative Standard Deployment Daily Builds Release Branch Testing Unit Testing Performance Testing Monitoring Server Monitoring Chain Monitoring Akka Monitoring ## /resources/protobuf-extension On this page Protobuf Extension 1. Introduction ​ In the aelf blockchain development environment, the initial step involves defining interfaces using protobuf. This structured approach ensures clarity in communication between different components of the system. To streamline and validate the protobuf syntax during development, users can take advantage of the protobuf extension available for Visual Studio Code (VSCode). The protobuf extension for VSCode offers several benefits. Firstly, it provides syntax highlighting and autocompletion features, significantly reducing the chances of syntax errors. This real-time assistance promotes code accuracy and helps developers catch mistakes early in the development process. Additionally, the extension facilitates the understanding of complex protobuf structures by offering a convenient way to navigate through different message types and their fields. This not only enhances code readability but also accelerates the development workflow. Moreover, the protobuf extension integrates with the overall development environment in VSCode, allowing users to leverage the platform's debugging capabilities for protobuf-related code. This integration contributes to a more seamless and efficient development experience. By incorporating the protobuf extension into their workflow, aelf developers can ensure the correctness of their protobuf definitions, enhance code quality, and ultimately accelerate the development lifecycle. 2. How to Install ​ Open Visual Studio Code. Navigate to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or using the keyboard shortcut Ctrl+Shift+X. In the Extensions view, search for "protobuf support" in the search bar. Look for the extension with the title "protobuf support" and select it from the search results. Click the "Install" button to install the extension. Once the installation is complete, you may need to restart VSCode to activate the extension. Now, you should have "protobuf support" installed and ready to use in your VSCode environment. This extension provides valuable features such as syntax highlighting, autocompletion, and other helpful tools to enhance your protobuf development experience. 1. Introduction 2. How to Install ## /resources/contribution On this page aelf is an open source , community-driven project. This guide aims to assist anyone who wants to contribute. Code Contribution ​ You can send pull requests to the aelf repository . Steps: Clone the repository. Make your changes. Send a pull request. Discuss changes on Github issues before starting to avoid duplicating work. Bug Fixes & Enhancements ​ Refer to the issue list for known bugs and enhancements. Feature Requests ​ For new feature ideas, create an issue or join an existing discussion. Implement features that gain community support. Blog Posts & Tutorials ​ If you create tutorials or blog posts about aelf, inform us via a Github issue so we can link to it in the official documentation and announce it on our X account . Bug Report ​ Report bugs by creating an issue on the Github repository. Thanks ​ Thanks to ABP for their contribution guide, which has inspired this guide. Code Contribution Blog Posts & Tutorials Bug Report Thanks ## /resources/whitepaper-2/ai-integration-points-in-the-aelf-ecosystem/operational-excellence On this page Operational Excellence i) Machine Learning Models for Smart Contract Optimisation ​ Integrating machine learning models into the aelf blockchain can significantly optimise gas usage and execution efficiency. We draw inspiration from existing rollup technologies but enhance them through advanced predictive modelling. Optimising Gas Usage ​ Machine learning models can analyee historical data on smart contract executions to identify patterns and predict the optimal gas prices for future transactions. This approach is similar to the predictive models used in financial markets to forecast asset prices and trading volumes, ensuring that transactions on aelf are both cost-effective and timely. Another practical application for machine learning models is the detection and minimisation of gas-expensive patterns in smart contract code. aelf has adapted tools that use machine learning algorithms to analyse and identify inefficient code patterns that consume excessive gas. For example, replacing arrays with mappings where iteration is not required can significantly reduce gas costs, as mappings are generally less expensive in terms of gas usage. By continuously monitoring and optimising these patterns, aelf can ensure that smart contracts are executed with minimal gas expenditure, similar to optimisation techniques employed by developers on the Ethereum network . Moreover, machine learning can optimise the execution efficiency of smart contracts by dynamically adjusting resource allocation based on the predicted computational requirements. Techniques such as variable packing, which arranges variables to fit into fewer storage slots, can be automatically identified and applied by machine learning algorithms. This reduces the number of storage operations needed, thereby lowering gas consumption. Additionally, employing machine learning on aelf to manage on-chain and off-chain data storage decisions can optimise the use of memory and storage, further enhancing gas efficiency. Enhancing Execution Efficiency ​ Beyond gas optimisation, AI can also streamline the execution efficiency of smart contracts on aelf. By employing predictive modelling, AI can anticipate resource requirements and execution paths for complex smart contracts. This foresight allows the system to allocate computational resources more effectively, ensuring that contracts run smoothly without unnecessary delays. This can be seen today in how Google Cloud’s AI optimises resource allocation for its cloud services . By using machine learning models to predict demand, Google Cloud can dynamically adjust resource allocation to meet user needs efficiently. In the case of aelf, this involves using AI to forecast transaction volumes and adjust computational resources in real-time. During a DeFi surge for instance, AI models can predict increased transaction loads and preemptively allocate more computational power to handle the surge without network slowdowns. Predictive models can evaluate the execution patterns of different smart contracts and suggest optimisations in their code to reduce execution time and resource consumption. This is similar to the optimisation techniques used in compiler design, where code is analysed and restructured to improve performance. Another real-life example of this concept is the work done by the Ethereum Foundation to optimise the EVM. Researchers have used AI to analyse smart contract bytecode, detect inefficient loops or redundant calculations and suggest optimisations that reduce gas usage and execution time. By applying similar techniques, aelf can enhance the efficiency of its smart contracts. ii) AI Oracle on aelf ​ aelf's AI oracle positions itself as the AI layer of Web3, leveraging both oracle and security compute technology to facilitate the development of AI-powered dApps. It plays a crucial role in aelf's architecture, which comprises the aelf chains, the AI oracle network, and AI applications, serving as the bridge and hub for integrating AI capabilities into the blockchain. On-chain AI ​ Currently, the AI oracle field primarily focuses on ensuring the integrity of the AI computation process (such as ORA) by incorporating Zero-Knowledge Proofs (ZKP) at each step of the calculation and reasoning process. This approach ensures that the reasoning process is derived from the Large Language Model (LLM) itself, rather than human intervention. However, merely guaranteeing the integrity of the AI reasoning process is insufficient. It is also crucial to ensure that the higher-layer AI Agent application remains tamper-proof. Additionally, widely used large models such as ChatGPT or decentralised computing networks like IO have their own computation and operation mechanisms, making it impractical to embed the ZKP process. Therefore, we believe that ensuring the integrity of the APIs called by the large model and the upper-layer AI Agent application is more critical and valuable than merely focusing on the AI inference process. Implementation on aelf ​ aelf employs the following mechanisms to implement the AI oracle network: TLSNotary Mechanism : This ensures that the API provided by the underlying centralised or decentralised LLM remains untampered from the data source to the local endpoint. SGX and Decentralised Computing Networks: These technologies guarantee the trustworthy operation of AI agents. The aelf oracle architecture is primarily divided into two components: 1. on-chain and 2. off-chain. 1. On-Chain Components The on-chain components (currently on the aelf chain, with potential future deployment on Ethereum or other chains) include node pledge management, a reputation system, fee and income settlement, an AI Agent scheduler, and an AI Agent factory contract. These components form the foundational framework contracts for the AI oracle. Combined with off-chain nodes, they constitute the aelf oracle network. Specifically, the developer-defined AI oracle contract is generated by the AI Agent factory contract based on user-defined logic. Node Pledge Management : Manages the AI Agent Service Nodes. Any node joining the network must pledge a certain amount of ELF. Reputation System : Evaluates node operating status in conjunction with the committee's assessments, such as downgrading offline nodes. Cost and Revenue Settlement : Integrates with the AI Agent scheduler to settle revenue for nodes and charge fees for dApp calls. AI Agent Scheduler : Deploys and schedules AI Agent Service code based on network computing power load. AI Agent Factory : Generates custom contracts for any user-defined AI Agent logic. It acts as the intermediary between the foundational framework contract and the user-defined contract, forwarding the dApp call interface, and interacting with the fee and income settlement contract. Additionally, it mediates between the AI Agent Service and user-defined contracts, processing all calls and inference results of the AI Agent Services uniformly. 2. Off-Chain Components The off-chain components consist of TLS Notary Nodes and Decentralised AI Agent Service Nodes (SGX environment). TLS Notary Nodes TLS Notary is an attestation mechanism that ensures the integrity and security of network communications between untrusted participants using the TLS (Transport Layer Security) protocol. This protocol encrypts communications between clients and servers. The "Notary" refers to a trusted third party or node that verifies the integrity of the TLS session between the client and server, ensuring it has not been tampered with. TLS Notary captures and records key information from the TLS session, such as the encrypted handshake and session keys, enabling even untrusted participants to verify the session's integrity. This mechanism allows the upper-layer AI Agent Service to authenticate data from external servers without fully trusting them. Evidence from TLS Notary can be used in the on-chain verification process to ensure the AI Agent Service processes safe and trustworthy data. aelf currently employs TLS Notary Nodes through two independent nodes: Receiver and Notary. Decentralised AI Agent Service Nodes The Decentrali
프로젝트로 돌아가기