Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moonbeam vs Ethereum reorg #888

Merged
merged 23 commits into from May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ad107e8
move the moonbeam vs ethereum section
eshaben Feb 16, 2024
56ce4d6
grammar
eshaben Feb 17, 2024
9a2dd94
reorganize the core concepts content
eshaben Mar 13, 2024
8ac5ebf
update ethereum compatibility-related docs
eshaben Mar 15, 2024
4e1b908
remove rpc support from the core concepts section
eshaben Mar 15, 2024
68bbf07
reorganize the builders section
eshaben Mar 15, 2024
bc333a1
update names and description
eshaben Mar 15, 2024
e6f3d6c
rpc supp link
themacexpert Mar 22, 2024
7343dcb
update unified accounts links and images
eshaben Mar 25, 2024
a51b7c7
update description of Development Toolkit dropdown
eshaben Mar 25, 2024
281a631
Merge remote-tracking branch 'origin' into eshaben/moonbeam-vs-eth
eshaben Mar 25, 2024
cc2ae93
add the json rpc section and update the pages for consistency
eshaben Apr 17, 2024
ff4020a
update snippets and images
eshaben Apr 17, 2024
0c397db
Merge remote-tracking branch 'origin' into eshaben/reorg-builders
eshaben Apr 17, 2024
561b435
Merge remote-tracking branch 'origin' into eshaben/moonbeam-vs-eth
eshaben Apr 17, 2024
d0f9e6e
Merge branch 'eshaben/moonbeam-vs-eth' into eshaben/reorg-builders
eshaben Apr 17, 2024
b6cfef5
Merge remote-tracking branch 'origin' into eshaben/reorg-builders
eshaben Apr 29, 2024
4541002
update terminal snippets to v0.37.2
eshaben Apr 29, 2024
165c506
apply feedback
eshaben Apr 30, 2024
aa237e0
Merge pull request #889 from moonbeam-foundation/eshaben/reorg-builders
eshaben Apr 30, 2024
70e066e
Merge remote-tracking branch 'origin' into eshaben/moonbeam-vs-eth
eshaben Apr 30, 2024
6e6ead9
update a few links
eshaben Apr 30, 2024
777ed3d
remove subwallet
eshaben May 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,2 +1,2 @@
!!! note
There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/builders/get-started/eth-compare/security){target=\_blank} page for more information.
There can be some unintended consequences when using the precompiled contracts on Moonbeam. Please refer to the [Security Considerations](/learn/core-concepts/security){target=\_blank} page for more information.
@@ -1,6 +1,6 @@
#### Use a SQL Backend for Frontier {: #use-sql }

The default [Frontier](/learn/features/eth-compatibility/#frontier){target=\_blank} database, which comes standard with Moonbeam nodes and contains all of the Ethereum-related elements, such as transactions, blocks, and logs, can be modified to use a SQL backend. Since `eth_getLogs` is a very resource-intensive method, the SQL backend aims to provide a more performant alternative for indexing and querying Ethereum logs in comparison to the default RocksDB database.
The default [Frontier](/learn/platform/technology/#frontier){target=\_blank} database, which comes standard with Moonbeam nodes and contains all of the Ethereum-related elements, such as transactions, blocks, and logs, can be modified to use a SQL backend. Since `eth_getLogs` is a very resource-intensive method, the SQL backend aims to provide a more performant alternative for indexing and querying Ethereum logs in comparison to the default RocksDB database.

To spin up a node with a Frontier SQL backend, you'll need to add the `--frontier-backend-type sql` flag to your start-up command.

Expand Down
2 changes: 1 addition & 1 deletion builders/build/eth-api/dev-env/hardhat.md
Expand Up @@ -392,7 +392,7 @@ The script should return `2` as the value.

## Hardhat Forking {: #hardhat-forking }

You can [fork](https://hardhat.org/hardhat-network/docs/guides/forking-other-networks){target=\_blank} any EVM-compatible chain using Hardhat, including Moonbeam. Forking simulates the live Moonbeam network locally, enabling you to interact with deployed contracts on Moonbeam in a local test environment. Since Hardhat forking is based on an EVM implementation, you can interact with the fork using standard Ethereum JSON-RPC methods supported by [Moonbeam](/builders/get-started/eth-compare/rpc-support/){target=\_blank} and [Hardhat](https://hardhat.org/hardhat-network/docs/reference#json-rpc-methods-support){target=\_blank}.
You can [fork](https://hardhat.org/hardhat-network/docs/guides/forking-other-networks){target=\_blank} any EVM-compatible chain using Hardhat, including Moonbeam. Forking simulates the live Moonbeam network locally, enabling you to interact with deployed contracts on Moonbeam in a local test environment. Since Hardhat forking is based on an EVM implementation, you can interact with the fork using standard [Ethereum JSON-RPC methods supported by Moonbeam](/learn/core-concepts/rpc-support/){target=\_blank} and [Hardhat](https://hardhat.org/hardhat-network/docs/reference#json-rpc-methods-support){target=\_blank}.

There are some limitations to be aware of when using Hardhat forking. You cannot interact with any of the Moonbeam precompiled contracts or their functions. Precompiles are a part of the Substrate implementation and therefore cannot be replicated in the simulated EVM environment. This prohibits you from interacting with cross-chain assets on Moonbeam and Substrate-based functionality such as staking and governance.

Expand Down
4 changes: 2 additions & 2 deletions builders/build/substrate-api/polkadot-js-api.md
Expand Up @@ -351,7 +351,7 @@ Any transaction will emit events, as a bare minimum this will always be either a

Depending on the transaction sent, some other events may however be emitted, for instance for a balance transfer event, this could include one or more `balance.Transfer` events.

The Transfer API page includes an [example code snippet](/builders/get-started/eth-compare/transfers-api/#monitor-all-balance-transfers-with-the-substrate-api){target=\_blank} for subscribing to new finalized block headers, and retrieving all `balance.Transfer` events.
The Transfer API page includes an [example code snippet](/learn/core-concepts/transfers-api/#monitor-all-balance-transfers-with-the-substrate-api){target=\_blank} for subscribing to new finalized block headers, and retrieving all `balance.Transfer` events.

### Batch Transactions {: #batching-transactions }

Expand Down Expand Up @@ -447,7 +447,7 @@ Some of the methods availabe through the Polkadot.js API interface are also avai
}'
```

The [Consensus and Finality page](/builders/get-started/eth-compare/consensus-finality/#){target=\_blank} has sample code for using the exposed custom and Substrate RPC calls to check the finality of a given transaction.
The [Consensus and Finality page](/learn/core-concepts/consensus-finality/#){target=\_blank} has sample code for using the exposed custom and Substrate RPC calls to check the finality of a given transaction.

## Polkadot.js API Utility Functions {: #utilities }

Expand Down
4 changes: 2 additions & 2 deletions builders/build/substrate-api/py-substrate-interface.md
Expand Up @@ -392,8 +392,8 @@ You can sign transaction payloads or any arbitrary data using a keypair object t

You can also make custom RPC requests with the [`rpc_request`](https://polkascan.github.io/py-substrate-interface/#substrateinterface.SubstrateInterface.rpc_request){target=\_blank} method.

This is particularly useful for interacting with Moonbeam's [ETH JSON-RPC](/builders/get-started/eth-compare/rpc-support/){target=\_blank} endpoints or Moonbeam's [custom RPC](/builders/build/moonbeam-custom-api/){target=\_blank} endpoints.
This is particularly useful for interacting with Moonbeam's [Ethereum JSON-RPC](/learn/core-concepts/rpc-support/){target=\_blank} endpoints or Moonbeam's [custom RPC](/builders/build/moonbeam-custom-api/){target=\_blank} endpoints.

The [Consensus and Finality page](/builders/get-started/eth-compare/consensus-finality/#checking-tx-finality-with-substrate-libraries) has examples for using the custom RPC calls through Python Substrate Interface to check the finality of a transaction given its tx hash.
The [Consensus and Finality page](/learn/core-concepts/consensus-finality/#checking-tx-finality-with-substrate-libraries){target=\_blank} has examples for using the custom RPC calls through Python Substrate Interface to check the finality of a transaction given its transaction hash.

--8<-- 'text/_disclaimers/third-party-content.md'
4 changes: 2 additions & 2 deletions builders/build/substrate-api/sidecar.md
Expand Up @@ -308,10 +308,10 @@ Other events emitted by EVM smart contracts can be decoded in a similar fashion,

## Sample Code for Monitoring Native Token Transfers { #sample-code-for-monitoring-native-token-transfers }

The [Transfers API page](/builders/get-started/eth-compare/transfers-api/#using-substrate-api-sidecar){target=\_blank} has a code snippet demonstrating how to use Substrate API Sidecar to retrieve and decode native token transfers sent with both Substrate and Ethereum APIs on Moonbeam networks. You can reference that as a starting point to build out backends that utilize Sidecar to listen to transfers on Moonbeam networks.
The [Transfers API page](/learn/core-concepts/transfers-api/#using-substrate-api-sidecar){target=\_blank} has a code snippet demonstrating how to use Substrate API Sidecar to retrieve and decode native token transfers sent with both Substrate and Ethereum APIs on Moonbeam networks. You can reference that as a starting point to build out backends that utilize Sidecar to listen to transfers on Moonbeam networks.

## Calculating Transaction Fees {: #calculating-transaction-fees }

For more detailed information and sample code on how to calculate the transaction fees of Moonbeam transactions using Substrate Sidecar API, please check the [Calculating Transaction Fees on Moonbeam](/builders/get-started/eth-compare/tx-fees/){target=\_blank} page.
For more detailed information and sample code on how to calculate the transaction fees of Moonbeam transactions using Substrate Sidecar API, please check the [Calculating Transaction Fees on Moonbeam](/learn/core-concepts/tx-fees/){target=\_blank} page.

--8<-- 'text/_disclaimers/third-party-content.md'
1 change: 0 additions & 1 deletion builders/get-started/.pages
Expand Up @@ -3,6 +3,5 @@ nav:
- index.md
- 'Quick Start': 'quick-start.md'
- networks
- eth-compare
- 'Network Endpoints': 'endpoints.md'
- 'Block Explorers': 'explorers.md'
8 changes: 0 additions & 8 deletions builders/get-started/eth-compare/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion builders/pallets-precompiles/precompiles/batch.md
Expand Up @@ -12,7 +12,7 @@ The batch precompiled contract on Moonbeam allows developers to combine multiple

Currently, having users interact with multiple contracts would require multiple transaction confirmations in the user's wallet. An example would be approving a smart contract's access to a token, then transferring it. With the batch precompile, developers can enhance user experience with batched transactions as it minimizes the number of transactions a user is required to confirm to one. Additionally, gas fees can be reduced since batching avoids multiple base gas fees (the initial 21000 units of gas spent to begin a transaction).

The precompile interacts directly with [Substrate's EVM pallet](/learn/features/eth-compatibility#evm-pallet){target=\_blank}. The caller of the batch function will have their address act as the `msg.sender` for all subtransactions, but unlike [delegate calls](https://docs.soliditylang.org/en/v0.8.15/introduction-to-smart-contracts.html#delegatecall-callcode-and-libraries){target=\_blank}, the target contract will still affect its own storage. It is effectively the same as if the user signed multiple transactions, but with only one confirmation.
The precompile interacts directly with [Substrate's EVM pallet](/learn/platform/technology#evm-pallet){target=\_blank}. The caller of the batch function will have their address act as the `msg.sender` for all subtransactions, but unlike [delegate calls](https://docs.soliditylang.org/en/v0.8.15/introduction-to-smart-contracts.html#delegatecall-callcode-and-libraries){target=\_blank}, the target contract will still affect its own storage. It is effectively the same as if the user signed multiple transactions, but with only one confirmation.

The precompile is located at the following address:

Expand Down
2 changes: 1 addition & 1 deletion builders/pallets-precompiles/precompiles/erc20.md
Expand Up @@ -12,7 +12,7 @@ The native token ERC-20 precompiled contract on Moonbeam allows developers to in

One of the main benefits of this precompile is that it removes the necessity of having a wrapped representation of the protocol token as an ERC-20 smart contract, such as WETH on Ethereum. Furthermore, it prevents having multiple wrapped representations of the same protocol token. Consequently, DApps that need to interact with the protocol token via an ERC-20 interface can do so without needing a separate smart contract.

Under the hood, the [ERC-20 precompile](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/src/lib.rs){target=\_blank} executes specific Substrate actions related to the Substrate balances pallet, which is coded in Rust. The balances pallet provides functionality for handling the [various types of balances on Moonbeam](/builders/get-started/eth-compare/balances/#moonbeam-account-balances){target=\_blank}, setting the free balance, transferring balances, and more.
Under the hood, the [ERC-20 precompile](https://github.com/moonbeam-foundation/moonbeam/blob/master/precompiles/balances-erc20/src/lib.rs){target=\_blank} executes specific Substrate actions related to the Substrate balances pallet, which is coded in Rust. The balances pallet provides functionality for handling the [various types of balances on Moonbeam](/learn/core-concepts/balances/#moonbeam-account-balances){target=\_blank}, setting the free balance, transferring balances, and more.

This guide will show you how to interact with DEV tokens, the native protocol tokens for the Moonbase Alpha TestNet, via the ERC-20 precompile. You can also follow and adapt this guide to learn how to use GLMR or MOVR as an ERC-20 token.

Expand Down
2 changes: 1 addition & 1 deletion builders/pallets-precompiles/precompiles/overview.md
Expand Up @@ -9,7 +9,7 @@ description: An overview of the available Solidity precompiles on Moonbeam. Prec

On Moonbeam, a precompiled contract is native Substrate code that has an Ethereum-style address and can be called using the Ethereum API, like any other smart contract. The precompiles allow you to call the Substrate runtime directly which is not normally accessible from the Ethereum side of Moonbeam.

The Substrate code responsible for implementing precompiles can be found in the [EVM pallet](/learn/features/eth-compatibility/#evm-pallet){target=\_blank}. The EVM pallet includes the [standard precompiles found on Ethereum and some additional precompiles that are not specific to Ethereum](https://github.com/polkadot-evm/frontier/tree/master/frame/evm/precompile){target=\_blank}. It also provides the ability to create and execute custom precompiles through the generic [`Precompiles` trait](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm/trait.Precompile.html){target=\_blank}. There are several custom Moonbeam-specific precompiles that have been created, all of which can be found in the [Moonbeam codebase](https://github.com/moonbeam-foundation/moonbeam/tree/master/precompiles){target=\_blank}.
The Substrate code responsible for implementing precompiles can be found in the [EVM pallet](/learn/platform/technology/#evm-pallet){target=\_blank}. The EVM pallet includes the [standard precompiles found on Ethereum and some additional precompiles that are not specific to Ethereum](https://github.com/polkadot-evm/frontier/tree/master/frame/evm/precompile){target=\_blank}. It also provides the ability to create and execute custom precompiles through the generic [`Precompiles` trait](https://polkadot-evm.github.io/frontier/rustdocs/pallet_evm/trait.Precompile.html){target=\_blank}. There are several custom Moonbeam-specific precompiles that have been created, all of which can be found in the [Moonbeam codebase](https://github.com/moonbeam-foundation/moonbeam/tree/master/precompiles){target=\_blank}.

The Ethereum precompiled contracts contain complex functionality that is computationally intensive, such as hashing and encryption. The custom precompiled contracts on Moonbeam provide access to Substrate-based functionality such as staking, governance, XCM-related functions, and more.

Expand Down
Binary file modified images/learn/platform/technology-diagram.webp
Binary file not shown.
1 change: 1 addition & 0 deletions learn/.pages
Expand Up @@ -3,5 +3,6 @@ hide: false
nav:
- index.md
- platform
- core-concepts
- features
- dapps-list
@@ -1,9 +1,9 @@
title: Moonbeam vs Ethereum
title: Core Concepts
nav:
- index.md
- 'Account Balances': 'balances.md'
- 'Transfers API': 'transfers-api.md'
- 'Transaction Fees': 'tx-fees.md'
- 'Balance Transfers': 'transfers-api.md'
- 'Consensus & Finality': 'consensus-finality.md'
- 'RPC Support': 'rpc-support.md'
- 'Transaction Fees': 'tx-fees.md'
- 'Unified Accounts': 'unified-accounts.md'
- 'Security Considerations': 'security.md'
Expand Up @@ -21,7 +21,7 @@ An account on Ethereum is an entity with a token balance (Ether or ETH in this c

Therefore, Ethereum has two main types of accounts: user-owned and contract-owned. No matter the type, an Ethereum account has a single balance field that represents the number of Wei owned by this address, where Wei is a denomination of ETH (1 x 10^18 Wei per ETH).

![Ethereum balances diagram](/images/builders/get-started/eth-compare/balances/balances-1.webp)
![Ethereum balances diagram](/images/learn/core-concepts/balances/balances-1.webp)

## Moonbeam Account Balances {: #moonbeam-account-balances }

Expand All @@ -35,7 +35,7 @@ As with Ethereum, there are two main types of accounts: user-owned and contract
- **Misc frozen** — represents a balance that the `free` balance may not drop below when withdrawing funds, except for transaction fee payment. For example, funds being used to vote on a governance proposal are shown as `misc frozen`. These funds are **not** accessible via the Ethereum API until they are freed
- **Fee frozen** — represents a balance that the `free` balance may not drop below when specifically paying for transaction fees. These funds are **not** accessible via the Ethereum API until they are freed

![Moonbeam balances diagram](/images/builders/get-started/eth-compare/balances/balances-2.webp)
![Moonbeam balances diagram](/images/learn/core-concepts/balances/balances-2.webp)

### Retrieve Your Balance {: #retrieve-your-balance }

Expand All @@ -45,13 +45,13 @@ You can check on your balances, including your free (or transferrable) and reser
--8<-- 'text/_common/endpoint-examples.md'

```js
--8<-- 'code/builders/get-started/eth-compare/balances/balance.js'
--8<-- 'code/learn/core-concepts/balances/balance.js'
```

You can also retrieve your balance locks using the Polkadot.js API.

```js
--8<-- 'code/builders/get-started/eth-compare/balances/locks.js'
--8<-- 'code/learn/core-concepts/balances/locks.js'
```

## Main Differences {: #main-differences }
Expand Down
Expand Up @@ -58,19 +58,19 @@ The snippets below follow this strategy to check transaction finality. It uses t
=== "Ethers.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/ethers.js'
--8<-- 'code/learn/core-concepts/consensus-finality/ethers.js'
```

=== "Web3.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/web3.js'
--8<-- 'code/learn/core-concepts/consensus-finality/web3.js'
```

=== "Web3.py"

```py
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/web3.py'
--8<-- 'code/learn/core-concepts/consensus-finality/web3.py'
```

## Check Transaction Finality with Moonbeam RPC Endpoints {: #check-tx-finality-with-moonbeam-rpc-endpoints }
Expand All @@ -86,39 +86,39 @@ You can modify the scripts from the Ethereum RPC section above to use `moon_isBl
=== "Ethers.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/custom-rpc/block/ethers.js'
--8<-- 'code/learn/core-concepts/consensus-finality/custom-rpc/block/ethers.js'
```

=== "Web3.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/custom-rpc/block/web3.js'
--8<-- 'code/learn/core-concepts/consensus-finality/custom-rpc/block/web3.js'
```

=== "Web3.py"

```py
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/custom-rpc/block/web3.py'
--8<-- 'code/learn/core-concepts/consensus-finality/custom-rpc/block/web3.py'
```

??? code "moon_isTxFinalized"

=== "Ethers.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/custom-rpc/tx/ethers.js'
--8<-- 'code/learn/core-concepts/consensus-finality/custom-rpc/tx/ethers.js'
```

=== "Web3.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/custom-rpc/tx/web3.js'
--8<-- 'code/learn/core-concepts/consensus-finality/custom-rpc/tx/web3.js'
```

=== "Web3.py"

```py
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/custom-rpc/tx/web3.py'
--8<-- 'code/learn/core-concepts/consensus-finality/custom-rpc/tx/web3.py'
```

## Check Transaction Finality with Substrate RPC Endpoints {: #check-tx-finality-with-substrate-rpc-endpoints }
Expand All @@ -136,13 +136,13 @@ You can find more information about Polkadot.js and the Substrate JSON-RPC in th
=== "Polkadot.js"

```js
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/polkadotjs.js'
--8<-- 'code/learn/core-concepts/consensus-finality/polkadotjs.js'
```

=== "py-substrate-interface"

```py
--8<-- 'code/builders/get-started/eth-compare/consensus-finality/pysubstrateinterface.py'
--8<-- 'code/learn/core-concepts/consensus-finality/pysubstrateinterface.py'
```

--8<-- 'text/_disclaimers/third-party-content.md'
9 changes: 9 additions & 0 deletions learn/core-concepts/index.md
@@ -0,0 +1,9 @@
---
title: Core Concepts
description: Dive into some of the core concepts and their key differences between Moonbeam, an Ethereum-compatible blockchain, and Ethereum itself.
dropdown_description: Learn about the fundamentals of Moonbeam
template: subsection-index-page.html
hide:
- toc
- feedback
---