Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

docs: update the descriptions of contract account #149

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
with:
# github.ref: The branch or tag ref that triggered the workflow run. For branches this is the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name>.
polyjuice_ref: ${{ github.ref }}
gw_prebuild_image_name: ghcr.io/zeroqn/godwoken-prebuilds
gw_prebuild_image_tag: v1.1-feat-change-ckb-decimal-to-18
kicker_ref: refs/pull/239/head # https://github.com/RetricSu/godwoken-kicker/pull/239
tests_ref: develop # https://github.com/nervosnetwork/godwoken-tests/commits/develop
kicker_ref: compatibility-changes # https://github.com/RetricSu/godwoken-kicker/commits/compatibility-changes
# gw_prebuild_image_name: <default value in docker/docker-compose.yml of kicker_ref>
# gw_prebuild_image_tag: <default value in docker/docker-compose.yml of kicker_ref>
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,37 @@ Polyjuice creator account is a Godwoken account for creating Polyjuice contract
code_hash: polyjuice_validator_type_script_hash
hash_type: type
args:
rollup_type_hash : [u8; 32]
creator_account_id : u32 (little endian, also chain id, and for reading 'sudt_id' from creator account script)
info_data_hash : [u8; 20] (The information to be hashed is depend on how the account been created: [normal, create2],
the 20 bytes value is keccak256(info_data)[12..])
rollup_type_hash : [u8; 32] (the rollup type hash of the current Godwoken deployment)
creator_account_id : u32 (little endian, it's the ID of Polyjuice Root Account)
contract_address : [u8; 20] (this 20 bytes value is keccak256(info_data)[12..], and the
`info_data` to be hashed depends on how the account was
created: `CREATE` or `CREATE2`)
```

#### Normal contract account script
The `contract_address` could be calculated through 2 ways:

#### 1. Normal contract account script
The Polyjuice contract account created in Polyjuice by `CREATE` call kind or Opcode.
```
info_content:
sender_address : [u8; 20] (the msg.sender: blake128(sender_script) + account id)
sender_nonce : u32
sender_address : [u8; 20] (the sender's eth_address)
sender_nonce : u32 (the transaction counter of the sender account)

info_data: rlp_encode(sender_address, sender_nonce)
```

#### Create2 contract account script
#### 2. Create2 contract account script
The Polyjuice contract account created in Polyjuice by `CREATE2` Opcode.
```
info_data:
special_byte : u8 (value is '0xff', refer to Ethereum)
sender_address : [u8; 20] (the msg.sender: blake128(sender_script) + account id)
sender_address : [u8; 20] (the sender's eth_address)
create2_salt : [u8; 32] (create2 salt)
init_code_hash : [u8; 32] (keccak256(init_code))
```

### Address used in Polyjuice
In the latest version of Polyjuice, the [EOA](https://ethereum.org/en/glossary/#eoa) address is native `eth_address`, which is the rightmost 160 bits of a Keccak hash of an ECDSA public key. While the address for an Polyjuice contract is deterministically computed from the address of its creator (sender) and how many transactions the creator has sent (nonce). The sender and nonce are RLP encoded and then hashed with Keccak-256.
### EOA Address used in Polyjuice
Polyjuice only provides contract accounts. Godwoken's user account is leveraged to act as externally owned account (EOA). In the latest version of Polyjuice, the EOA address is native `eth_address`, which is the rightmost 160 bits of a Keccak hash of an ECDSA public key.


[rawl2tx-args]: https://github.com/nervosnetwork/godwoken/blob/develop/crates/types/schemas/godwoken.mol#L60
Expand Down
2 changes: 1 addition & 1 deletion c/polyjuice.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ int create_new_account(gw_context_t* ctx,
/* contract account script.args
Include:
- [32 bytes] rollup type hash
- [ 4 bytes] creator account id (chain id)
- [ 4 bytes] little endian creator_account_id, it's Polyjuice Root Account
- [20 bytes] keccak256(data)[12..]
*/
memcpy(script_args, g_rollup_script_hash, 32);
Expand Down
4 changes: 0 additions & 4 deletions docs/EVM-compatible.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ Recall that in Ethereum, the gas of each smart contract is calculated. The trans

Note when sending a transaction to a smart contract for certain behavior, the `value` of the transaction is `pCKB`.

## Account Abstraction

Polyjuice only provides [contract accounts](https://ethereum.org/en/glossary/#contract-account). Godwoken's user accounts are leveraged to act as [EOAs](https://ethereum.org/en/glossary/#eoa).

## All Tokens Are ERC20 Tokens

Ethereum differs in the processing of ERC20 tokens, and native ETH tokens. This is also the reason why wETH is invented. Godwoken conceals this difference:
Expand Down