Skip to content

Commit 4bd0962

Browse files
committed
patches regex for snippet replacement, updates llms
1 parent 9ed505f commit 4bd0962

13 files changed

+1036
-1102
lines changed

llms-files/llms-basics.txt

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7042,14 +7042,14 @@ categories: Basics, Polkadot Protocol
70427042

70437043
## Introduction
70447044

7045-
Asset Hub natively uses Polkadot's 32-byte account system but provides interoperability with Ethereum's 20-byte addresses through an automatic conversion system. When interacting with smart contracts:
7045+
Asset Hub natively utilizes Polkadot's 32-byte account system while providing interoperability with Ethereum's 20-byte addresses through an automatic conversion system. When interacting with smart contracts:
70467046

7047-
- Ethereum-compatible wallets (like MetaMask) can use their familiar 20-byte addresses
7048-
- Polkadot accounts continue using their native 32-byte format
7047+
- Ethereum-compatible wallets (like MetaMask) can use their familiar 20-byte addresses.
7048+
- Polkadot accounts continue using their native 32-byte format.
70497049
- The Asset Hub chain automatically handles conversion between the two formats behind the scenes:
70507050

7051-
- 20-byte Ethereum addresses are padded with `0xEE` bytes to create valid 32-byte Polkadot accounts
7052-
- 32-byte Polkadot accounts can optionally register a mapping to a 20-byte address for Ethereum compatibility
7051+
- 20-byte Ethereum addresses are padded with `0xEE` bytes to create valid 32-byte Polkadot accounts.
7052+
- 32-byte Polkadot accounts can optionally register a mapping to a 20-byte address for Ethereum compatibility.
70537053

70547054
This dual-format approach enables Asset Hub to maintain compatibility with Ethereum tooling while fully integrating with the Polkadot ecosystem.
70557055

@@ -7064,58 +7064,65 @@ The platform handles two distinct address formats:
70647064

70657065
The [`AccountId32Mapper`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/struct.AccountId32Mapper.html){target=\_blank} implementation in [`pallet_revive`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/index.html){target=\_blank} handles the core address conversion logic. For converting a 20-byte Ethereum address to a 32-byte Polkadot address, the pallet uses a simple concatenation approach:
70667066

7067-
- [**Core mechanism**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} - takes a 20-byte Ethereum address and extends it to 32 bytes by adding twelve `0xEE` bytes at the end. The key benefits of this approach are:
7068-
- Able to fully revert, allowing a smooth transition back to the Ethereum format
7069-
- Provides clear identification of Ethereum-controlled accounts through the `0xEE` suffix pattern
7070-
- Maintains cryptographic security with a `2^96` difficulty for pattern reproduction
7067+
- [**Core mechanism**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} : takes a 20-byte Ethereum address and extends it to 32 bytes by adding twelve `0xEE` bytes at the end. The key benefits of this approach are:
7068+
- Able to fully revert, allowing a smooth transition back to the Ethereum format.
7069+
- Provides clear identification of Ethereum-controlled accounts through the `0xEE` suffix pattern.
7070+
- Maintains cryptographic security with a `2^96` difficulty for pattern reproduction.
70717071

70727072
### Polkadot to Ethereum Mapping
70737073

7074-
The conversion from 32-byte to 20-byte addresses is handled through a stateful mapping system implemented in the [`AddressMapper`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html){target=\_blank} trait. The core functionality includes:
7074+
The conversion from 32-byte Polkadot accounts to 20-byte Ethereum addresses is more complex than the reverse direction due to the lossy nature of the conversion. The [`AccountId32Mapper`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/struct.AccountId32Mapper.html){target=\_blank} handles this through two distinct approaches:
70757075

7076-
- Address conversion in both directions
7077-
- Account registration and management
7078-
- Mapping status verification
7076+
- **For Ethereum-derived accounts** : The system uses the [`is_eth_derived`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/fn.is_eth_derived.html){target=\_blank} function to detect accounts that were originally Ethereum addresses (identified by the `0xEE` suffix pattern). For these accounts, the conversion strips the last 12 bytes to recover the original 20-byte Ethereum address.
7077+
7078+
- **For native Polkadot accounts** : Since these accounts utilize the whole 32-byte space and weren't derived from Ethereum addresses, direct truncation would result in lost information. Instead, the system:
7079+
1. Hashes the entire 32-byte account using Keccak-256.
7080+
2. Takes the last 20 bytes of the hash to create the Ethereum address.
7081+
3. This ensures a deterministic mapping while avoiding simple truncation.
7082+
7083+
The conversion process is implemented through the [`to_address`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_address){target=\_blank} function, which automatically detects the account type and applies the appropriate conversion method.
7084+
7085+
**Stateful Mapping for Reversibility** : Since the conversion from 32-byte to 20-byte addresses is inherently lossy, the system provides an optional stateful mapping through the [`OriginalAccount`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/type.OriginalAccount.html){target=\_blank} storage. When a Polkadot account registers a mapping (via the [`map`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.map){target=\_blank} function), the system stores the original 32-byte account ID, enabling the [`to_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_account_id){target=\_blank} function to recover the exact original account rather than falling back to a default conversion.
70797086

70807087
## Account Registration
70817088

70827089
The registration process is implemented through the [`map`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.map){target=\_blank} function. This process involves:
70837090

7084-
- Checking if the account is already mapped
7085-
- Calculating and collecting required deposits based on data size
7086-
- Storing the address suffix for future reference
7087-
- Managing the currency holds for security
7091+
- Checking if the account is already mapped.
7092+
- Calculating and collecting required deposits based on data size.
7093+
- Storing the address suffix for future reference.
7094+
- Managing the currency holds for security.
70887095

70897096
## Fallback Accounts
70907097

70917098
The fallback mechanism is integrated into the [`to_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_account_id){target=\_blank} function. It provides a safety net for address conversion by:
70927099

7093-
- First, attempting to retrieve stored mapping data
7094-
- Falling back to the default conversion method if no mapping exists
7095-
- Maintaining consistency in address representation
7100+
- First, attempting to retrieve stored mapping data.
7101+
- Falling back to the default conversion method if no mapping exists.
7102+
- Maintaining consistency in address representation.
70967103

70977104
## Contract Address Generation
70987105

70997106
The system supports two methods for generating contract addresses:
71007107

71017108
- [**CREATE1 method**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/fn.create1.html){target=\_blank}:
71027109

7103-
- Uses the deployer address and nonce
7104-
- Generates deterministic addresses for standard contract deployment
7110+
- Uses the deployer address and nonce.
7111+
- Generates deterministic addresses for standard contract deployment.
71057112

71067113
- [**CREATE2 method**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/fn.create2.html){target=\_blank}:
71077114

7108-
- Uses the deployer address, initialization code, input data, and salt
7109-
- Enables predictable address generation for advanced use cases
7115+
- Uses the deployer address, initialization code, input data, and salt.
7116+
- Enables predictable address generation for advanced use cases.
71107117

71117118
## Security Considerations
71127119

71137120
The address mapping system maintains security through several design choices evident in the implementation:
71147121

7115-
- The stateless mapping requires no privileged operations, as shown in the [`to_fallback_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} implementation
7116-
- The stateful mapping requires a deposit managed through the [`Currency`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/pallet/trait.Config.html#associatedtype.Currency){target=\_blank} trait
7117-
- Mapping operations are protected against common errors through explicit checks
7118-
- The system prevents double-mapping through the [`ensure!(!Self::is_mapped(account_id))`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs#L125){target=\_blank} check
7122+
- The stateless mapping requires no privileged operations, as shown in the [`to_fallback_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} implementation.
7123+
- The stateful mapping requires a deposit managed through the [`Currency`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/pallet/trait.Config.html#associatedtype.Currency){target=\_blank} trait.
7124+
- Mapping operations are protected against common errors through explicit checks.
7125+
- The system prevents double-mapping through the [`ensure!(!Self::is_mapped(account_id))`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs#L125){target=\_blank} check.
71197126

71207127
All source code references are from the [`address.rs`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs){target=\_blank} file in the Revive pallet of the Polkadot SDK repository.
71217128
--- END CONTENT ---

llms-files/llms-dapps.txt

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11624,14 +11624,14 @@ categories: Basics, Polkadot Protocol
1162411624

1162511625
## Introduction
1162611626

11627-
Asset Hub natively uses Polkadot's 32-byte account system but provides interoperability with Ethereum's 20-byte addresses through an automatic conversion system. When interacting with smart contracts:
11627+
Asset Hub natively utilizes Polkadot's 32-byte account system while providing interoperability with Ethereum's 20-byte addresses through an automatic conversion system. When interacting with smart contracts:
1162811628

11629-
- Ethereum-compatible wallets (like MetaMask) can use their familiar 20-byte addresses
11630-
- Polkadot accounts continue using their native 32-byte format
11629+
- Ethereum-compatible wallets (like MetaMask) can use their familiar 20-byte addresses.
11630+
- Polkadot accounts continue using their native 32-byte format.
1163111631
- The Asset Hub chain automatically handles conversion between the two formats behind the scenes:
1163211632

11633-
- 20-byte Ethereum addresses are padded with `0xEE` bytes to create valid 32-byte Polkadot accounts
11634-
- 32-byte Polkadot accounts can optionally register a mapping to a 20-byte address for Ethereum compatibility
11633+
- 20-byte Ethereum addresses are padded with `0xEE` bytes to create valid 32-byte Polkadot accounts.
11634+
- 32-byte Polkadot accounts can optionally register a mapping to a 20-byte address for Ethereum compatibility.
1163511635

1163611636
This dual-format approach enables Asset Hub to maintain compatibility with Ethereum tooling while fully integrating with the Polkadot ecosystem.
1163711637

@@ -11646,58 +11646,65 @@ The platform handles two distinct address formats:
1164611646

1164711647
The [`AccountId32Mapper`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/struct.AccountId32Mapper.html){target=\_blank} implementation in [`pallet_revive`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/index.html){target=\_blank} handles the core address conversion logic. For converting a 20-byte Ethereum address to a 32-byte Polkadot address, the pallet uses a simple concatenation approach:
1164811648

11649-
- [**Core mechanism**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} - takes a 20-byte Ethereum address and extends it to 32 bytes by adding twelve `0xEE` bytes at the end. The key benefits of this approach are:
11650-
- Able to fully revert, allowing a smooth transition back to the Ethereum format
11651-
- Provides clear identification of Ethereum-controlled accounts through the `0xEE` suffix pattern
11652-
- Maintains cryptographic security with a `2^96` difficulty for pattern reproduction
11649+
- [**Core mechanism**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} : takes a 20-byte Ethereum address and extends it to 32 bytes by adding twelve `0xEE` bytes at the end. The key benefits of this approach are:
11650+
- Able to fully revert, allowing a smooth transition back to the Ethereum format.
11651+
- Provides clear identification of Ethereum-controlled accounts through the `0xEE` suffix pattern.
11652+
- Maintains cryptographic security with a `2^96` difficulty for pattern reproduction.
1165311653

1165411654
### Polkadot to Ethereum Mapping
1165511655

11656-
The conversion from 32-byte to 20-byte addresses is handled through a stateful mapping system implemented in the [`AddressMapper`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html){target=\_blank} trait. The core functionality includes:
11656+
The conversion from 32-byte Polkadot accounts to 20-byte Ethereum addresses is more complex than the reverse direction due to the lossy nature of the conversion. The [`AccountId32Mapper`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/struct.AccountId32Mapper.html){target=\_blank} handles this through two distinct approaches:
1165711657

11658-
- Address conversion in both directions
11659-
- Account registration and management
11660-
- Mapping status verification
11658+
- **For Ethereum-derived accounts** : The system uses the [`is_eth_derived`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/fn.is_eth_derived.html){target=\_blank} function to detect accounts that were originally Ethereum addresses (identified by the `0xEE` suffix pattern). For these accounts, the conversion strips the last 12 bytes to recover the original 20-byte Ethereum address.
11659+
11660+
- **For native Polkadot accounts** : Since these accounts utilize the whole 32-byte space and weren't derived from Ethereum addresses, direct truncation would result in lost information. Instead, the system:
11661+
1. Hashes the entire 32-byte account using Keccak-256.
11662+
2. Takes the last 20 bytes of the hash to create the Ethereum address.
11663+
3. This ensures a deterministic mapping while avoiding simple truncation.
11664+
11665+
The conversion process is implemented through the [`to_address`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_address){target=\_blank} function, which automatically detects the account type and applies the appropriate conversion method.
11666+
11667+
**Stateful Mapping for Reversibility** : Since the conversion from 32-byte to 20-byte addresses is inherently lossy, the system provides an optional stateful mapping through the [`OriginalAccount`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/type.OriginalAccount.html){target=\_blank} storage. When a Polkadot account registers a mapping (via the [`map`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.map){target=\_blank} function), the system stores the original 32-byte account ID, enabling the [`to_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_account_id){target=\_blank} function to recover the exact original account rather than falling back to a default conversion.
1166111668

1166211669
## Account Registration
1166311670

1166411671
The registration process is implemented through the [`map`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.map){target=\_blank} function. This process involves:
1166511672

11666-
- Checking if the account is already mapped
11667-
- Calculating and collecting required deposits based on data size
11668-
- Storing the address suffix for future reference
11669-
- Managing the currency holds for security
11673+
- Checking if the account is already mapped.
11674+
- Calculating and collecting required deposits based on data size.
11675+
- Storing the address suffix for future reference.
11676+
- Managing the currency holds for security.
1167011677

1167111678
## Fallback Accounts
1167211679

1167311680
The fallback mechanism is integrated into the [`to_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_account_id){target=\_blank} function. It provides a safety net for address conversion by:
1167411681

11675-
- First, attempting to retrieve stored mapping data
11676-
- Falling back to the default conversion method if no mapping exists
11677-
- Maintaining consistency in address representation
11682+
- First, attempting to retrieve stored mapping data.
11683+
- Falling back to the default conversion method if no mapping exists.
11684+
- Maintaining consistency in address representation.
1167811685

1167911686
## Contract Address Generation
1168011687

1168111688
The system supports two methods for generating contract addresses:
1168211689

1168311690
- [**CREATE1 method**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/fn.create1.html){target=\_blank}:
1168411691

11685-
- Uses the deployer address and nonce
11686-
- Generates deterministic addresses for standard contract deployment
11692+
- Uses the deployer address and nonce.
11693+
- Generates deterministic addresses for standard contract deployment.
1168711694

1168811695
- [**CREATE2 method**](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/fn.create2.html){target=\_blank}:
1168911696

11690-
- Uses the deployer address, initialization code, input data, and salt
11691-
- Enables predictable address generation for advanced use cases
11697+
- Uses the deployer address, initialization code, input data, and salt.
11698+
- Enables predictable address generation for advanced use cases.
1169211699

1169311700
## Security Considerations
1169411701

1169511702
The address mapping system maintains security through several design choices evident in the implementation:
1169611703

11697-
- The stateless mapping requires no privileged operations, as shown in the [`to_fallback_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} implementation
11698-
- The stateful mapping requires a deposit managed through the [`Currency`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/pallet/trait.Config.html#associatedtype.Currency){target=\_blank} trait
11699-
- Mapping operations are protected against common errors through explicit checks
11700-
- The system prevents double-mapping through the [`ensure!(!Self::is_mapped(account_id))`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs#L125){target=\_blank} check
11704+
- The stateless mapping requires no privileged operations, as shown in the [`to_fallback_account_id`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/trait.AddressMapper.html#tymethod.to_fallback_account_id){target=\_blank} implementation.
11705+
- The stateful mapping requires a deposit managed through the [`Currency`](https://paritytech.github.io/polkadot-sdk/master/pallet_revive/pallet/trait.Config.html#associatedtype.Currency){target=\_blank} trait.
11706+
- Mapping operations are protected against common errors through explicit checks.
11707+
- The system prevents double-mapping through the [`ensure!(!Self::is_mapped(account_id))`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs#L125){target=\_blank} check.
1170111708

1170211709
All source code references are from the [`address.rs`](https://github.com/paritytech/polkadot-sdk/blob/stable2412/substrate/frame/revive/src/address.rs){target=\_blank} file in the Revive pallet of the Polkadot SDK repository.
1170311710
--- END CONTENT ---

0 commit comments

Comments
 (0)