Skip to content

Commit

Permalink
Merge 'breaking' into deniallugo-zks-603-generate-stucts-for-types-st…
Browse files Browse the repository at this point in the history
…orage-and

Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo committed Apr 13, 2021
1 parent bbcec16 commit e5aea3d
Show file tree
Hide file tree
Showing 99 changed files with 1,853 additions and 508 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ jobs:
run: |
ci_run zk
ci_run zk fmt --check
ci_run zk lint rust --check
ci_run zk lint js --check
ci_run zk lint ts --check
ci_run zk lint md --check
ci_run zk lint --check
unit-tests:
runs-on: [self-hosted, CI-worker]
Expand Down
59 changes: 44 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ members = [
"core/lib/config",
"core/lib/contracts",
"core/lib/api_client",
"core/lib/notifier",
"core/lib/balancer",

# Test infrastructure
Expand Down
18 changes: 18 additions & 0 deletions changelog/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to the contracts will be documented in this file.

## 2021-25-02

**Version 5** is scheduled for upgrade.

### Added

- `tokenGovernance` address is added to the `Governance` contract. `tokenGovernance` can list new tokens.
- `TokenGovernance` contract is added to allow anybody to pay fee and list new tokens.

### Changed

- Maximum amount of tokens that can be used to pay tx fee is increased to 512.
- Circuit now enforces that `ForcedExit` target account pubkey hash is empty.

## 2021-09-02

**Version 4** is released.

## 2021-14-01

**Version 4** is scheduled for upgrade.
Expand Down
4 changes: 4 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to the core components will be documented in this file.
### Changed

- (`loadtest`): `zksync_fee` has been moved to `[main_wallet]` section from the `[network]` section.
- (`EthWatcher`): added processing of events about adding new tokens to the contract.
- A special balancer for FeeTicker was replaced with a generic balancer.
- (`eth_client`): `web3` field was made private in `ETHDirectClient`. `testkit` and `loadtest` don't use it directly
now.
Expand All @@ -20,6 +21,9 @@ All notable changes to the core components will be documented in this file.
- (`loadtest`): Added `zksync_fee` option into the `[scenario]` section to set fee for each scenario individually, added
`fee_token` option into the `[main_wallet]` section to set token that is used to pay fees for the main wallet
operations.
- (`TokenHandler`): Module for automatically adding a token to the database based on the received Ethereum event
(`NewTokenEvent`).
- (`Notifier`): Module for sending notifications to third-party services.
- (`eth_client`): Added `get_tx`, `create_contract` methods to `EthereumGateway`, `get_web3_transport` method to
ETHDirectClient.
- (`api_server`): Support for accounts that don't have to pay fees (e.g. network service accounts) was added.
Expand Down
2 changes: 2 additions & 0 deletions changelog/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ components, the logs will have the following format:

### Added

- (`token_list_manager`): CLI for updating to new version of a previously saved list of trusted tokens.

### Fixed

## Release 2021-02-19
Expand Down
2 changes: 1 addition & 1 deletion contracts/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"prettier/prettier": "error",
"no-inline-assembly": false
}
}
}
54 changes: 27 additions & 27 deletions contracts/contracts/Bytes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,89 +159,89 @@ library Bytes {
}

/// Reads byte stream
/// @return new_offset - offset + amount of bytes read
/// @return newOffset - offset + amount of bytes read
/// @return data - actually read data
// NOTE: theoretically possible overflow of (_offset + _length)
function read(
bytes memory _data,
uint256 _offset,
uint256 _length
) internal pure returns (uint256 new_offset, bytes memory data) {
) internal pure returns (uint256 newOffset, bytes memory data) {
data = slice(_data, _offset, _length);
new_offset = _offset + _length;
newOffset = _offset + _length;
}

// NOTE: theoretically possible overflow of (_offset + 1)
function readBool(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, bool r) {
new_offset = _offset + 1;
function readBool(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, bool r) {
newOffset = _offset + 1;
r = uint8(_data[_offset]) != 0;
}

// NOTE: theoretically possible overflow of (_offset + 1)
function readUint8(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, uint8 r) {
new_offset = _offset + 1;
function readUint8(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, uint8 r) {
newOffset = _offset + 1;
r = uint8(_data[_offset]);
}

// NOTE: theoretically possible overflow of (_offset + 2)
function readUInt16(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, uint16 r) {
new_offset = _offset + 2;
function readUInt16(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, uint16 r) {
newOffset = _offset + 2;
r = bytesToUInt16(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 3)
function readUInt24(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, uint24 r) {
new_offset = _offset + 3;
function readUInt24(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, uint24 r) {
newOffset = _offset + 3;
r = bytesToUInt24(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 4)
function readUInt32(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, uint32 r) {
new_offset = _offset + 4;
function readUInt32(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, uint32 r) {
newOffset = _offset + 4;
r = bytesToUInt32(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 16)
function readUInt128(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, uint128 r) {
new_offset = _offset + 16;
function readUInt128(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, uint128 r) {
newOffset = _offset + 16;
r = bytesToUInt128(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 20)
function readUInt160(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, uint160 r) {
new_offset = _offset + 20;
function readUInt160(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, uint160 r) {
newOffset = _offset + 20;
r = bytesToUInt160(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 20)
function readAddress(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, address r) {
new_offset = _offset + 20;
function readAddress(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, address r) {
newOffset = _offset + 20;
r = bytesToAddress(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 20)
function readBytes20(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, bytes20 r) {
new_offset = _offset + 20;
function readBytes20(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, bytes20 r) {
newOffset = _offset + 20;
r = bytesToBytes20(_data, _offset);
}

// NOTE: theoretically possible overflow of (_offset + 32)
function readBytes32(bytes memory _data, uint256 _offset) internal pure returns (uint256 new_offset, bytes32 r) {
new_offset = _offset + 32;
function readBytes32(bytes memory _data, uint256 _offset) internal pure returns (uint256 newOffset, bytes32 r) {
newOffset = _offset + 32;
r = bytesToBytes32(_data, _offset);
}

/// Trim bytes into single word
function trim(bytes memory _data, uint256 _new_length) internal pure returns (uint256 r) {
require(_new_length <= 0x20, "10"); // new_length is longer than word
require(_data.length >= _new_length, "11"); // data is to short
function trim(bytes memory _data, uint256 _newLength) internal pure returns (uint256 r) {
require(_newLength <= 0x20, "10"); // new_length is longer than word
require(_data.length >= _newLength, "11"); // data is to short

uint256 a;
assembly {
a := mload(add(_data, 0x20)) // load bytes into uint256
}

return a >> ((0x20 - _new_length) * 8);
return a >> ((0x20 - _newLength) * 8);
}

// Helper function for hex conversion.
Expand Down
Loading

0 comments on commit e5aea3d

Please sign in to comment.