Skip to content

Commit

Permalink
feat: Add ecadd and ecmul to the list of precompiles upon genesis (#669)
Browse files Browse the repository at this point in the history
## What ❔

Add ecadd and ecmul to the list of system contracts to be added upon
genesis

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `cargo spellcheck
--cfg=./spellcheck/era.cfg --code 1`.
  • Loading branch information
StanislavBreadless authored Dec 18, 2023
1 parent 2ef3ec8 commit 0be35b8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 10 additions & 0 deletions core/lib/constants/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ pub const SHA256_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x02,
]);

pub const EC_ADD_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06,
]);

pub const EC_MUL_PRECOMPILE_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07,
]);

pub const ERC20_TRANSFER_TOPIC: H256 = H256([
221, 242, 82, 173, 27, 226, 200, 155, 105, 194, 176, 104, 252, 55, 141, 170, 149, 43, 167, 241,
99, 196, 161, 22, 40, 245, 90, 77, 245, 35, 179, 239,
Expand Down
19 changes: 16 additions & 3 deletions core/lib/types/src/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use zksync_system_constants::{
use crate::{
block::DeployedContract, ACCOUNT_CODE_STORAGE_ADDRESS, BOOTLOADER_ADDRESS,
COMPLEX_UPGRADER_ADDRESS, CONTRACT_DEPLOYER_ADDRESS, ECRECOVER_PRECOMPILE_ADDRESS,
IMMUTABLE_SIMULATOR_STORAGE_ADDRESS, KECCAK256_PRECOMPILE_ADDRESS, KNOWN_CODES_STORAGE_ADDRESS,
L1_MESSENGER_ADDRESS, L2_ETH_TOKEN_ADDRESS, MSG_VALUE_SIMULATOR_ADDRESS, NONCE_HOLDER_ADDRESS,
EC_ADD_PRECOMPILE_ADDRESS, EC_MUL_PRECOMPILE_ADDRESS, IMMUTABLE_SIMULATOR_STORAGE_ADDRESS,
KECCAK256_PRECOMPILE_ADDRESS, KNOWN_CODES_STORAGE_ADDRESS, L1_MESSENGER_ADDRESS,
L2_ETH_TOKEN_ADDRESS, MSG_VALUE_SIMULATOR_ADDRESS, NONCE_HOLDER_ADDRESS,
SHA256_PRECOMPILE_ADDRESS, SYSTEM_CONTEXT_ADDRESS,
};

Expand All @@ -23,7 +24,7 @@ use crate::{
pub const TX_NONCE_INCREMENT: U256 = U256([1, 0, 0, 0]); // 1
pub const DEPLOYMENT_NONCE_INCREMENT: U256 = U256([0, 0, 1, 0]); // 2^128

static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 18] = [
static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 20] = [
(
"",
"AccountCodeStorage",
Expand Down Expand Up @@ -90,6 +91,18 @@ static SYSTEM_CONTRACT_LIST: [(&str, &str, Address, ContractLanguage); 18] = [
ECRECOVER_PRECOMPILE_ADDRESS,
ContractLanguage::Yul,
),
(
"precompiles/",
"EcAdd",
EC_ADD_PRECOMPILE_ADDRESS,
ContractLanguage::Yul,
),
(
"precompiles/",
"EcMul",
EC_MUL_PRECOMPILE_ADDRESS,
ContractLanguage::Yul,
),
(
"",
"SystemContext",
Expand Down

0 comments on commit 0be35b8

Please sign in to comment.