Skip to content

Commit 2d9c190

Browse files
authored
Add eigen tutorial (0xEigenLabs#79)
* Add eigen tutorial: 'eigenCall' * Now 'eigen_call_sample' is not needed * Reformat the log information * Update arb-ts version, update README.md, etc.
1 parent ea30da5 commit 2d9c190

30 files changed

+765
-291
lines changed

l2/README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ To run Arbitrum locally, you need several things:
2424

2525
```bash
2626
yarn docker:build:geth
27+
28+
# Set DEVNET_PRIVKEY, for example:
29+
export DEVNET_PRIVKEY="0x2323232323232323232323232323232323232323232323232323232323232323"
2730
yarn docker:geth
2831
```
2932

3033
- Configuring your local Arbitrum chain (the L2)
3134

3235
```bash
36+
# If in another terminal, we should set DEVNET_PRIVKEY again with the same value as before
37+
3338
yarn demo:initialize
3439
```
3540

@@ -39,15 +44,15 @@ To run Arbitrum locally, you need several things:
3944
yarn demo:deploy
4045
```
4146

42-
3. Deploy contract by truffle in `eigen_call_sample`
47+
3. Run tutorial `demo-eigencall`
4348

4449
```bash
50+
cd eigen-tutorials
4551
# Install some dependencies
46-
npm install @truffle/hdwallet-provider
52+
yarn
4753

48-
# Deploy the contracts
49-
truffle migrate --reset --network arbitrum
54+
# Run tutorial
55+
cd packages/demo-iegencall
5056

51-
# Test our contracts
52-
truffle console --network arbitrum
57+
yarn run exec
5358
```

l2/eigen-tutorials/.eslintrc.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
env: {
3+
commonjs: true,
4+
es6: true,
5+
node: true,
6+
},
7+
plugins: ['prettier'],
8+
extends: [
9+
'eslint:recommended',
10+
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
11+
],
12+
parserOptions: {
13+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
14+
sourceType: 'module', // Allows for the use of imports
15+
},
16+
rules: {
17+
'prettier/prettier': 'error',
18+
'no-unused-vars': 'warn',
19+
'prefer-const': [2, { destructuring: 'all' }],
20+
'object-curly-spacing': ['error', 'always'],
21+
},
22+
overrides: [
23+
{
24+
files: ['*.ts', '*.tsx'],
25+
parser: '@typescript-eslint/parser',
26+
extends: [
27+
'eslint:recommended',
28+
'plugin:@typescript-eslint/recommended',
29+
'prettier/@typescript-eslint',
30+
'plugin:prettier/recommended',
31+
],
32+
plugins: ['@typescript-eslint', 'prettier'],
33+
rules: {
34+
'no-empty-pattern': 'warn',
35+
'prettier/prettier': ['error', { singleQuote: true }],
36+
'@typescript-eslint/member-delimiter-style': ['off'],
37+
'@typescript-eslint/no-explicit-any': ['warn'],
38+
'@typescript-eslint/no-use-before-define': ['off'],
39+
'@typescript-eslint/no-non-null-assertion': ['off'],
40+
'@typescript-eslint/ban-ts-comment': ['warn'],
41+
},
42+
},
43+
],
44+
}

l2/eigen-tutorials/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
node_modules/
3+
packages/.DS_Store
4+
packages/*/.DS_Store
5+
packages/*/artifacts/
6+
packages/*/cache/
7+
packages/*/build/
8+
packages/*/node_modules/
9+
packages/*/.env
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
exclude: |
2+
(?x)(
3+
^packages/arb-avm-cpp/external/keccak/|
4+
^packages/arb-bridge-eth/installed_contracts/
5+
)
6+
repos:
7+
- repo: https://github.com/psf/black
8+
rev: stable
9+
hooks:
10+
- id: black
11+
language_version: python3
12+
- repo: https://gitlab.com/pycqa/flake8
13+
rev: 3.9.0
14+
hooks:
15+
- id: flake8
16+
- repo: git://github.com/doublify/pre-commit-clang-format
17+
rev: master
18+
hooks:
19+
- id: clang-format
20+
- repo: git://github.com/dnephin/pre-commit-golang
21+
rev: master
22+
hooks:
23+
- id: go-fmt
24+
- repo: https://github.com/pre-commit/mirrors-prettier
25+
rev: "v2.2.1" # Use the sha or tag you want to point at
26+
hooks:
27+
- id: prettier
28+
- repo: https://github.com/pre-commit/mirrors-eslint
29+
rev: "v7.24.0" # Use the sha / tag you want to point at
30+
hooks:
31+
- id: eslint
32+
args: [--fix]
33+
types: [text]
34+
# ignore prettier config
35+
files: \.[jt]sx?$
36+
additional_dependencies:
37+
38+
39+
- "@typescript-eslint/[email protected]"
40+
- "@typescript-eslint/[email protected]"
41+
42+
- repo: https://github.com/syntaqx/git-hooks
43+
rev: v0.0.16
44+
hooks:
45+
- id: circleci-config-validate
46+
- repo: local
47+
hooks:
48+
- id: prettier-soldity
49+
name: prettier-soldity
50+
language: node
51+
entry: ./node_modules/.bin/prettier --write --list-different
52+
files: \.sol$
53+
additional_dependencies:
54+
55+
- "prettier-plugin-solidity@^1.0.0-alpha.54"
56+
- id: go-vet
57+
name: Go Vet
58+
entry: ./scripts/run-go-packages "go list ./... | grep -v 'arb-node-core/ethbridge[^/]*contracts' | xargs go vet"
59+
language: script
60+
files: \.go$

l2/eigen-tutorials/.prettierrc.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
semi: false,
3+
trailingComma: 'es5',
4+
singleQuote: true,
5+
printWidth: 80,
6+
tabWidth: 2,
7+
arrowParens: 'avoid',
8+
bracketSpacing: true,
9+
overrides: [
10+
{
11+
files: '*.sol',
12+
options: {
13+
printWidth: 100,
14+
tabWidth: 4,
15+
useTabs: false,
16+
singleQuote: false,
17+
bracketSpacing: true,
18+
explicitTypes: 'always',
19+
},
20+
},
21+
],
22+
}

l2/eigen-tutorials/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Eigen Quickstart
2+
3+
## Installation
4+
5+
From root directory:
6+
7+
```bash
8+
yarn install
9+
```
10+
11+
## What's included?
12+
13+
#### :white_check_mark: Basics
14+
15+
- [eigenCall Demo](./packages/demo-eigencall/)

l2/eigen-tutorials/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "eigen-quickstart",
3+
"version": "1.0.0",
4+
"description": "The Eigen Quickstart Tutorials",
5+
"author": "Eigen",
6+
"license": "Apache-2.0",
7+
"private": "true",
8+
"engines": {
9+
"node": ">= 8.0.0 < 13.0.0",
10+
"npm": "^6.0.0",
11+
"yarn": "^1.0.0"
12+
},
13+
"workspaces": {
14+
"packages": [
15+
"packages/arb-shared-dependencies",
16+
"packages/demo-eigencall"
17+
]
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
pragma solidity ^0.7.0;
2+
3+
/** @title Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000066.
4+
* Allows registering / retrieving addresses at uint indices, saving calldata.
5+
*/
6+
interface ArbAddressTable {
7+
/**
8+
* @notice Register an address in the address table
9+
* @param addr address to register
10+
* @return index of the address (existing index, or newly created index if not already registered)
11+
*/
12+
function register(address addr) external returns(uint);
13+
14+
/**
15+
* @param addr address to lookup
16+
* @return index of an address in the address table (revert if address isn't in the table)
17+
*/
18+
function lookup(address addr) external view returns(uint);
19+
20+
/**
21+
* @notice Check whether an address exists in the address table
22+
* @param addr address to check for presence in table
23+
* @return true if address is in table
24+
*/
25+
function addressExists(address addr) external view returns(bool);
26+
27+
/**
28+
* @return size of address table (= first unused index)
29+
*/
30+
function size() external view returns(uint);
31+
32+
/**
33+
* @param index index to lookup address
34+
* @return address at a given index in address table (revert if index is beyond end of table)
35+
*/
36+
function lookupIndex(uint index) external view returns(address);
37+
38+
/**
39+
* @notice read a compressed address from a bytes buffer
40+
* @param buf bytes buffer containing an address
41+
* @param offset offset of target address
42+
* @return resulting address and updated offset into the buffer (revert if buffer is too short)
43+
*/
44+
function decompress(bytes calldata buf, uint offset) external pure returns(address, uint);
45+
46+
/**
47+
* @notice compress an address and return the result
48+
* @param addr address to comppress
49+
* @return compressed address bytes
50+
*/
51+
function compress(address addr) external returns(bytes memory);
52+
}
53+

l2/eigen_call_sample/contracts/ArbSys.sol l2/eigen-tutorials/packages/arb-shared-dependencies/contracts/ArbSys.sol

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ interface ArbSys {
77
/**
88
* @notice Get internal version number identifying an ArbOS build
99
* @return version number as int
10-
*/
10+
*/
1111
function arbOSVersion() external pure returns (uint);
1212

1313
/**
14-
* @notice Call eigenCall function with RLP encoding bytes, which is a list must contain 4 strings
15-
* @param RLP encoding bytes of `[operator, arg1, arg2, arg3]`
16-
* @return eigenCall returns bytes which is encoded with RLP
17-
*/
14+
* @notice Call eigenCall function with RLP encoding bytes
15+
* @return eigenCall returns value with RLP encoding bytes
16+
*/
17+
1818
function eigenCall(bytes calldata) external pure returns (bytes memory);
1919

2020
/**
2121
* @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)
2222
* @return block number as int
23-
*/
23+
*/
2424
function arbBlockNumber() external view returns (uint);
2525

2626
/**
@@ -40,7 +40,6 @@ interface ArbSys {
4040
function sendTxToL1(address destination, bytes calldata calldataForL1) external payable returns(uint);
4141

4242

43-
4443
/**
4544
* @notice get the number of transactions issued by the given external account or the account sequence number of the given contract
4645
* @param account target account

0 commit comments

Comments
 (0)