axonweb3 / axon

Axon is a Layer 2 framework of CKB with native cross-chain and interoperability.
https://axonweb3.io
MIT License
65 stars 39 forks source link

refactor!: change many `U256` type to `U64` #1591

Closed KaoImin closed 9 months ago

KaoImin commented 9 months ago

What this PR does / why we need it?

This PR is substitute for #1539

Some mainly changes:

What is the impact of this PR?

Breaking change

PR relation:

CI Settings
### **CI Usage** **Tip**: Check the CI you want to run below, and then comment `/run-ci`. **CI Switch** - [x] Web3 Compatible Tests - [x] OpenZeppelin tests - [x] OCT 1-5 And 12-15 - [x] OCT 6-10 - [x] OCT 11 - [x] OCT 16-19 - [x] v3 Core Tests ### **CI Description** | CI Name | Description | | ----------------------------------------- | ------------------------------------------------------------------------- | | *Web3 Compatible Test* | Test the Web3 compatibility of Axon | | *v3 Core Test* | Run the compatibility tests provided by Uniswap V3 | | *OCT 1-5 \| 6-10 \| 11 \| 12-15 \| 16-19* | Run the compatibility tests provided by OpenZeppelin |
yangby-cryptape commented 9 months ago

References:

KaoImin commented 9 months ago

References:

Ethereum Yellow Paper

4.2. The Transaction

  • nonce: a scalar value
  • gasPrice: a scalar value
  • gasLimit: a scalar value
  • value: a scalar value
  • chainId: unknown

4.3. The Block

  • difficulty: a scalar value
  • number: a scalar value
  • gasLimit: a scalar value
  • gasUsed: a scalar value
  • timestamp: a scalar value
  • nonce: a 64-bit value

Go Etherem:

Difficulty  *big.Int       `json:"difficulty"       gencodec:"required"`
Number      *big.Int       `json:"number"           gencodec:"required"`
GasLimit    uint64         `json:"gasLimit"         gencodec:"required"`
GasUsed     uint64         `json:"gasUsed"          gencodec:"required"`
Time        uint64         `json:"timestamp"        gencodec:"required"`
Extra       []byte         `json:"extraData"        gencodec:"required"`
MixDigest   common.Hash    `json:"mixHash"`
Nonce       BlockNonce     `json:"nonce"`
chainID() *big.Int
gas() uint64
gasPrice() *big.Int
gasTipCap() *big.Int
gasFeeCap() *big.Int
value() *big.Int
nonce() uint64

According to the PR description, some types such as nonce, gasPrice, gasLimit, gasUsed have a specific range limitation, it is a waste of performance to use a variable-length BigUint. The Ethereum timestamp is accurate to the second, so u64 is enough. The only one that using variable-length scalar is chainId. The explanation of using U64 is written in the description.

github-actions[bot] commented 9 months ago

CI tests run on commit:

CI test list:

KaoImin commented 9 months ago

Wait for @sunchengzhu upgrade Web3 Compatible Tests workflow. cc @Flouse

KaoImin commented 9 months ago

/run-ci

github-actions[bot] commented 9 months ago

CI tests run on commit:

CI test list:

Flouse commented 9 months ago

/run-ci

run OpenZeppelin tests as well

github-actions[bot] commented 9 months ago

CI tests run on commit:

CI test list:

sunchengzhu commented 9 months ago

/run-ci

github-actions[bot] commented 9 months ago

CI tests run on commit:

CI test list:

sunchengzhu commented 9 months ago

/run-ci

Flouse commented 9 months ago

/run-ci

github-actions[bot] commented 9 months ago

CI tests run on commit:

CI test list:

github-actions[bot] commented 9 months ago

CI tests run on commit:

CI test list: