You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Heimdall's "Ante handler" is responsible for checking and validating all transactions. After verification, it checks the balance of the sender for enough fees and deduct fees in case of successful transaction inclusion.
1
+
Heimdall's "Ante Handler" plays a crucial role in the integrity and efficiency of transaction processing. It is primarily responsible for the preliminary verification and validation of all transactions, ensuring that they meet the necessary criteria before being included in a block. This includes checking the sender's balance to ensure there are sufficient funds to cover transaction fees and subsequently deducting these fees for successful transactions.
2
2
3
-
## Gas limit
3
+
## Advanced Gas Management in Heimdall
4
4
5
-
Each block and transaction have a limit for gas usage. A block can contain multiple transactions, but gas used by all transactions in a block must be less than block gas limit to avoid larger blocks.
5
+
### Block and Transaction Gas Limits
6
+
7
+
Heimdall employs a gas limit system to regulate the computational and storage resources consumed by transactions and blocks. This system is designed to prevent excessive block sizes and ensure network stability.
8
+
9
+
#### Block Gas Limit
10
+
11
+
Each block in Heimdall has a maximum gas limit, constraining the total gas used by all transactions within the block. The sum of the gas used by each transaction in a block must not exceed this limit:
Note that each state manipulation on transaction costs gas, including signature verification for the transaction.
12
-
13
-
### Block gas limit
14
-
15
-
Max block gas limit and bytes per block is passed while setting up app's consensus params: [https://github.com/maticnetwork/heimdall/blob/develop/app/app.go#L464-L471](https://github.com/maticnetwork/heimdall/blob/develop/app/app.go#L464-L471)
17
+
The maximum block gas limit and block size are specified as part of the consensus parameters during the application setup, as seen in the Heimdall source code at [app.go#L464-L471](https://github.com/maticnetwork/heimdall/blob/develop/app/app.go#L464-L471):
The transaction gas limit is defined in params in `auth` module. It can be changed through the Heimdall`gov` module.
35
+
For individual transactions, the gas limit is determined by parameters in the `auth` module and can be modified through Heimdall's governance (`gov`) module.
34
36
35
-
###Checkpoint transaction gas limit
37
+
#### Special Handling of Checkpoint Transactions
36
38
37
-
Since block contains multiple transactions and verifies this particular transaction on the Ethereum chain, Merkle proof is required. To avoid extra Merkle proof verification for checkpoint transaction, Heimdall only allows one transaction in the block if the transaction type is `MsgCheckpoint`
39
+
Checkpoint transactions, which require Merkle proof verification on the Ethereum chain, are treated distinctly. To streamline processing and avoid the overhead of additional Merkle proof verification, Heimdall restricts blocks containing a `MsgCheckpoint` transaction to just that one transaction:
38
40
39
41
```go
40
-
//fee wanted for checkpoint transaction
42
+
//Gas requirement for checkpoint transaction
41
43
gasWantedPerCheckpoinTx sdk.Gas = 10000000// 10 Million
42
44
43
-
//checkpoint gas limit
45
+
//Special gas limit handling for checkpoint transactions
44
46
if stdTx.Msg.Type() == "checkpoint" && stdTx.Msg.Route() == "checkpoint" {
45
47
gasForTx = gasWantedPerCheckpoinTx
46
48
}
47
49
```
48
50
49
-
## Transaction verification and replay protection
51
+
## Enhanced Transaction Verification and Replay Protection
52
+
53
+
The Ante Handler in Heimdall is instrumental in ensuring the legitimacy and uniqueness of transactions. It performs a thorough verification of incoming transactions, including signature validation, as delineated in the source code at [ante.go#L230-L266](https://github.com/maticnetwork/heimdall/blob/develop/auth/ante.go#L230-L266).
54
+
55
+
### Sequence Number for Replay Protection
50
56
51
-
Ante Handler handles and verifies signature in incoming transaction: [https://github.com/maticnetwork/heimdall/blob/develop/auth/ante.go#L230-L266](https://github.com/maticnetwork/heimdall/blob/develop/auth/ante.go#L230-L266)
57
+
A critical aspect of transaction security in Heimdall is the use of a `sequenceNumber` in each transaction. This feature is a safeguard against replay attacks, where a transaction might be fraudulently or mistakenly repeated. To prevent such scenarios, the Ante Handler increments the sequence number for the sender's account after each successful transaction. This incrementation ensures that each transaction is unique and that previous transactions cannot be replayed.
52
58
53
-
Each transaction must include `sequenceNumber` to avoid replay attacks. After each successful transaction inclusion, Ante handler increases the sequence number for the TX sender account to avoid duplication (replay) of the previous transactions.
59
+
In summary, Heimdall's Ante Handler, along with its sophisticated gas management and transaction verification systems, provides a robust framework for secure and efficient transaction processing. The careful balance of block and transaction gas limits, coupled with advanced replay protection mechanisms, ensures the smooth operation of the Heimdall chain within the Polygon network.
Copy file name to clipboardExpand all lines: docs/pos/get-started/building-on-polygon.md
+25-43Lines changed: 25 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,30 @@ If you are an Ethereum developer, you are already a Polygon developer. Simply sw
2
2
3
3
You can deploy decentralized applications to either Polygon Mumbai Testnet or the Mainnet. The Polygon Mumbai Testnet connects with the Ethereum Goërli Testnet, which acts as its ParentChain. You can find all the network-related details in the [network documentation](https://github.com/0xPolygon/wiki/blob/master/docs/operate/network.md).
4
4
5
-
### Wallets
5
+
## Overview
6
+
7
+
Polygon consists of the three following layers:
8
+
9
+
- Ethereum layer — a set of contracts on the Ethereum mainnet.
10
+
- Heimdall layer — a set of proof-of-stake Heimdall nodes running in parallel to the Ethereum mainnet, monitoring the set of staking contracts deployed on the Ethereum mainnet, and committing the Polygon Network checkpoints to the Ethereum mainnet. Heimdall is based on Tendermint.
11
+
- Bor layer — a set of block-producing Bor nodes shuffled by Heimdall nodes. Bor is based on Go Ethereum.
12
+
13
+
To be a validator on the Polygon Network, you must run:
14
+
15
+
- Sentry node — a separate machine running a Heimdall node and a Bor node. A sentry node is open to all nodes on the Polygon Network.
16
+
- Validator node — a separate machine running a Heimdall node and a Bor node. A validator node is only open to its sentry node and closed to the rest of the network.
17
+
- Stake the MATIC tokens in the staking contracts deployed on the Ethereum mainnet.
18
+
19
+
20
+
## Wallets
6
21
7
22
To interact with the Polygon Network, you need to have an Ethereum-based wallet because Polygon runs on Ethereum Virtual Machine (EVM). You can choose to set up a [Metamask](https://github.com/0xPolygon/wiki/blob/master/docs/tools/wallets/metamask/overview.md) or [Arkane](https://github.com/0xPolygon/wiki/blob/master/docs/develop/wallets/arkane/intro_arkane.md) Wallet. More on wallet-related information and why you need one can be found in our [wallet documentation](https://docs.polygon.technology/docs/develop/wallets/getting-started).
8
23
9
-
###Smart Contracts
24
+
## Smart contracts
10
25
11
26
Polygon supports many services you can use to test, compile, debug, and deploy decentralized applications onto the Polygon Network. These include deployment using [thirdweb](https://github.com/0xPolygon/wiki/blob/master/docs/develop/thirdweb.md), [Alchemy](https://github.com/0xPolygon/wiki/blob/master/docs/develop/alchemy.md), [Chainstack](https://github.com/0xPolygon/wiki/blob/master/docs/develop/chainstack.md), [QuickNode](https://github.com/0xPolygon/wiki/blob/master/docs/develop/quicknode.md), [Remix](https://github.com/0xPolygon/wiki/blob/master/docs/develop/remix.md), [Truffle](https://github.com/0xPolygon/wiki/blob/master/docs/develop/truffle.md), [Hardhat](https://github.com/0xPolygon/wiki/blob/master/docs/develop/hardhat.md), and [Replit](https://github.com/0xPolygon/wiki/blob/master/docs/develop/replit.md).
12
27
13
-
###Connecting to Polygon
28
+
## Connecting to Polygon
14
29
15
30
You can add Polygon to MetaMask or directly use Arkane, which allows you to connect to Polygon using [RPC](https://docs.polygon.technology/docs/tools/wallets/metamask/config-polygon-on-metamask/).
16
31
@@ -36,6 +51,13 @@ async function main() {
36
51
main();
37
52
```
38
53
54
+
!!! note "Take it easy!"
55
+
56
+
If this is overwhelming, that’s alright! You can jump right into the action and start hacking. Here are some notes before you start diving into resources, repositories, and docs:
57
+
58
+
1. **Beware the cost of being on the bleeding edge**: Like typical niche programming, dApps and blockchain development moves very quickly. While researching, you may find complex code repositories, 404s on a documentation site, or even no documentation. Use that opportunity to reach out to us via any social media channel.
59
+
2. **The learning curve may be daunting, but the barrier to entry is low**: The community is very open and welcoming! Projects welcome pull requests from outsiders and resolve any blockers actively. We’re working on creating a better world and contribution in any form is appreciated. We’ll be grateful to onboard you into this amazing Web3 ecosystem.
60
+
39
61
## Building a new dApp on Polygon?
40
62
41
63
Decentralized applications (dApps) act as the bridge between users and their data privacy on the blockchain. The increasing number of dApps validates their usefulness within the blockchain ecosystem, solving challenges like executing transactions between two participants without the need for central authority via smart contracts.
@@ -59,43 +81,3 @@ If you already have a decentralized application (dApp) and are looking for a pla
59
81
1.**Easily migrate from Ethereum Virtual Machine (EVM) based chain**: Polygon prides itself in being the ultimate Layer-2 scaling solution for Ethereum. You don't have to worry about the underlying architecture while moving or deploying your dApps to the Polygon Network as long as it is EVM-compatible.
60
82
2.**Use Polygon as a faster transaction layer**: Deploying your dApp to the Polygon Mainnet allows you to leverage Polygon as a faster transaction layer for your dApp. Additionally, you can get your tokens mapped by us. You can join our [technical discussions group](http://bit.ly/matic-technical-group) on Telegram to learn more.
61
83
62
-
## Side Note
63
-
64
-
If this is overwhelming, that’s alright! You can jump right into the action and start hacking. Here are some notes before you start diving into resources, repositories, and docs:
65
-
66
-
1.**Beware the cost of being on the bleeding edge**: Like typical niche programming, dApps and blockchain development moves very quickly. While researching, you may find complex code repositories, 404s on a documentation site, or even no documentation. Use that opportunity to reach out to us via any social media channel.
67
-
2.**The learning curve may be daunting, but the barrier to entry is low**: The community is very open and welcoming! Projects welcome pull requests from outsiders and resolve any blockers actively. We’re working on creating a better world and contribution in any form is appreciated. We’ll be grateful to onboard you into this amazing Web3 ecosystem.
68
-
69
-
## Overview
70
-
71
-
Polygon consists of the three following layers:
72
-
73
-
- Ethereum layer — a set of contracts on the Ethereum mainnet.
74
-
- Heimdall layer — a set of proof-of-stake Heimdall nodes running in parallel to the Ethereum mainnet, monitoring the set of staking contracts deployed on the Ethereum mainnet, and committing the Polygon Network checkpoints to the Ethereum mainnet. Heimdall is based on Tendermint.
75
-
- Bor layer — a set of block-producing Bor nodes shuffled by Heimdall nodes. Bor is based on Go Ethereum.
76
-
77
-
To be a validator on the Polygon Network, you must run:
78
-
79
-
- Sentry node — a separate machine running a Heimdall node and a Bor node. A sentry node is open to all nodes on the Polygon Network.
80
-
- Validator node — a separate machine running a Heimdall node and a Bor node. A validator node is only open to its sentry node and closed to the rest of the network.
81
-
- Stake the MATIC tokens in the staking contracts deployed on the Ethereum mainnet.
82
-
83
-
## Components
84
-
85
-
### Heimdall
86
-
87
-
Heimdall does the following:
88
-
89
-
- Monitors the staking contracts on the Ethereum mainnet.
90
-
- Verifies all state transitions on the Bor chain.
91
-
- Commits the Bor chain state checkpoints to the Ethereum mainnet.
92
-
93
-
Heimdall is based on Tendermint.
94
-
95
-
### Bor
96
-
97
-
Bor does the following:
98
-
99
-
- Produces blocks on the Polygon Network.
100
-
101
-
Bor is the Block producer node and layer for the Polygon Network. It is based on Go Ethereum. Blocks produced on Bor are validated by Heimdall nodes.
This introductory page is currently being written. In the meantime, please review documentation existing under this section, which, in all likelihood, is also in a relatively early editorial state.
1
+
Welcome to the Polygon PoS how-to section! There's a bunch of how-tos here to help you get started with common technical tasks. We hope you find them useful.
This introductory page is currently being written. In the meantime, please review documentation existing under this section, which, in all likelihood, is also in a relatively early editorial state.
1
+
Welcome to the Polygon PoS how-to section! There's a bunch of how-tos here to help you get started with common technical tasks. We hope you find them useful.
This introductory page is currently being written. In the meantime, please review documentation existing under this section, which, in all likelihood, is also in a relatively early editorial state.
1
+
This introductory page is currently being written.
0 commit comments