Skip to content

Commit

Permalink
Merge branch 'master' into nitro-testnode-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed Feb 9, 2024
2 parents 8335e04 + 6dd7c82 commit 6c1acc4
Show file tree
Hide file tree
Showing 12 changed files with 2,635 additions and 129 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,24 @@ For help and further scripts, see:
./test-node.bash script --help
```

## Named accounts

```bash
./test-node.bash script print-address --account sequencer
```
```
sequencer: 0xe2148eE53c0755215Df69b2616E552154EdC584f
validator: 0x6A568afe0f82d34759347bb36F14A6bB171d2CBe
l2owner: 0x5E1497dD1f08C87b2d8FE23e9AAB6c1De833D927
l3owner: 0x863c904166E801527125D8672442D736194A3362
l3sequencer: 0x3E6134aAD4C4d422FF2A4391Dc315c4DDf98D1a5
user_l1user: 0x058E6C774025ade66153C65672219191c72c7095
user_token_bridge_deployer: 0x3EaCb30f025630857aDffac9B2366F953eFE4F98
user_fee_token_deployer: 0x2AC5278D230f88B481bBE4A94751d7188ef48Ca2
```

While not a named account, 0x3f1eae7d46d88f08fc2f8ed27fcb2ab183eb2d0e is funded on all test chains.

## Contact

Discord - [Arbitrum](https://discord.com/invite/5KE54JwyTs)
Expand Down
11 changes: 5 additions & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ services:
- "127.0.0.1:9642:9642"
volumes:
- "seqdata:/home/user/.arbitrum/local/nitro"
- "l1keystore:/home/user/l1keystore"
- "config:/config"
- "tokenbridge-data:/tokenbridge-data"
command: --conf.file /config/sequencer_config.json --node.feed.output.enable --node.feed.output.port 9642 --http.api net,web3,eth,txpool,debug --node.seq-coordinator.my-url ws://sequencer:8548 --graphql.enable --graphql.vhosts * --graphql.corsdomain *
depends_on:
- geth
- redis


sequencer_b:
pid: host # allow debugging
Expand Down Expand Up @@ -313,8 +313,7 @@ services:
volumes:
- "l1keystore:/home/user/l1keystore"
- "config:/config"
depends_on:
- redis
- "tokenbridge-data:/tokenbridge-data"

relay:
pid: host
Expand All @@ -334,7 +333,7 @@ services:
- ARB_URL=http://sequencer:8547
- ETH_URL=http://geth:8545
volumes:
- "sdk-data:/workspace"
- "tokenbridge-data:/workspace"
- /var/run/docker.sock:/var/run/docker.sock

volumes:
Expand All @@ -352,4 +351,4 @@ volumes:
poster-data-c:
config:
postgres-data:
sdk-data:
tokenbridge-data:
33 changes: 28 additions & 5 deletions scripts/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as crypto from "crypto";
import { runStress } from "./stress";
const path = require("path");

const specialAccounts = 5;
const specialAccounts = 6;

async function writeAccounts() {
for (let i = 0; i < specialAccounts; i++) {
Expand Down Expand Up @@ -44,6 +44,9 @@ export function namedAccount(
if (name == "l3sequencer") {
return specialAccount(4);
}
if (name == "l2owner") {
return specialAccount(5);
}
if (name.startsWith("user_")) {
return new ethers.Wallet(
ethers.utils.sha256(ethers.utils.toUtf8Bytes(name))
Expand Down Expand Up @@ -82,10 +85,11 @@ export function namedAddress(

export const namedAccountHelpString =
"Valid account names:\n" +
" funnel | sequencer | validator - known keys\n" +
" user_[Alphanumeric] - key will be generated from username\n" +
" threaduser_[Alphanumeric] - same as user_[Alphanumeric]_thread_[thread-id]\n" +
" key_0x[full private key] - user with specified private key\n" +
" funnel | sequencer | validator | l2owner - known keys used by l2\n" +
" l3owner | l3sequencer - known keys used by l3\n" +
" user_[Alphanumeric] - key will be generated from username\n" +
" threaduser_[Alphanumeric] - same as user_[Alphanumeric]_thread_[thread-id]\n" +
" key_0x[full private key] - user with specified private key\n" +
"\n" +
"Valid addresses: any account name, or\n" +
" address_0x[full eth address]\n" +
Expand All @@ -95,6 +99,10 @@ async function handlePrintAddress(argv: any, threadId: number) {
console.log(namedAddress(argv.account, threadId));
}

async function handlePrintPrivateKey(argv: any, threadId: number) {
console.log(namedAccount(argv.account, threadId).privateKey);
}

export const printAddressCommand = {
command: "print-address",
describe: "prints the requested address",
Expand All @@ -110,6 +118,21 @@ export const printAddressCommand = {
},
};

export const printPrivateKeyCommand = {
command: "print-private-key",
describe: "prints the requested private key",
builder: {
account: {
string: true,
describe: "account (see general help)",
default: "funnel",
},
},
handler: async (argv: any) => {
await runStress(argv, handlePrintPrivateKey);
},
}

export const writeAccountsCommand = {
command: "write-accounts",
describe: "writes wallet files",
Expand Down
83 changes: 56 additions & 27 deletions scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as consts from './consts'
import { namedAccount } from './accounts'
import { namedAccount, namedAddress } from './accounts'

const path = require("path");

Expand Down Expand Up @@ -158,11 +158,6 @@ function writeConfigs(argv: any) {
"connection": {
"url": argv.l1url,
},
"wallet": {
"account": "",
"password": consts.l1passphrase,
"pathname": consts.l1keystore,
},
},
"chain": {
"id": 412346,
Expand All @@ -173,6 +168,11 @@ function writeConfigs(argv: any) {
"dangerous": {
"without-block-validator": false
},
"parent-chain-wallet" : {
"account": namedAddress("validator"),
"password": consts.l1passphrase,
"pathname": consts.l1keystore,
},
"disable-challenge": false,
"enable": false,
"staker-interval": "10s",
Expand Down Expand Up @@ -200,6 +200,12 @@ function writeConfigs(argv: any) {
"enable": false,
"redis-url": argv.redisUrl,
"max-delay": "30s",
"l1-block-bound": "ignore",
"parent-chain-wallet" : {
"account": namedAddress("sequencer"),
"password": consts.l1passphrase,
"pathname": consts.l1keystore,
},
"data-poster": {
"redis-signer": {
"signing-key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
Expand All @@ -218,6 +224,7 @@ function writeConfigs(argv: any) {
"sequencer": {
"enable": false,
},
"forwarding-target": "null",
},
"persistent": {
"chain": "local"
Expand All @@ -235,33 +242,46 @@ function writeConfigs(argv: any) {

const baseConfJSON = JSON.stringify(baseConfig)

let validatorConfig = JSON.parse(baseConfJSON)
validatorConfig["parent-chain"].wallet.account = namedAccount("validator").address
validatorConfig.node.staker.enable = true
validatorConfig.node.staker["use-smart-contract-wallet"] = true
let validconfJSON = JSON.stringify(validatorConfig)
fs.writeFileSync(path.join(consts.configpath, "validator_config.json"), validconfJSON)
if (argv.simple) {
let simpleConfig = JSON.parse(baseConfJSON)
simpleConfig.node.staker.enable = true
simpleConfig.node.staker["use-smart-contract-wallet"] = true
simpleConfig.node.staker.dangerous["without-block-validator"] = true
simpleConfig.node.sequencer = true
simpleConfig.node.dangerous["no-sequencer-coordinator"] = true
simpleConfig.node["delayed-sequencer"].enable = true
simpleConfig.node["batch-poster"].enable = true
simpleConfig.node["batch-poster"]["redis-url"] = ""
simpleConfig.execution["sequencer"].enable = true
fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(simpleConfig))
} else {
let validatorConfig = JSON.parse(baseConfJSON)
validatorConfig.node.staker.enable = true
validatorConfig.node.staker["use-smart-contract-wallet"] = true
let validconfJSON = JSON.stringify(validatorConfig)
fs.writeFileSync(path.join(consts.configpath, "validator_config.json"), validconfJSON)

let unsafeStakerConfig = JSON.parse(validconfJSON)
unsafeStakerConfig.node.staker.dangerous["without-block-validator"] = true
fs.writeFileSync(path.join(consts.configpath, "unsafe_staker_config.json"), JSON.stringify(unsafeStakerConfig))
let unsafeStakerConfig = JSON.parse(validconfJSON)
unsafeStakerConfig.node.staker.dangerous["without-block-validator"] = true
fs.writeFileSync(path.join(consts.configpath, "unsafe_staker_config.json"), JSON.stringify(unsafeStakerConfig))

let sequencerConfig = JSON.parse(baseConfJSON)
sequencerConfig.node.sequencer = true
sequencerConfig.node["seq-coordinator"].enable = true
sequencerConfig.execution["sequencer"].enable = true
sequencerConfig.node["delayed-sequencer"].enable = true
fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig))
let sequencerConfig = JSON.parse(baseConfJSON)
sequencerConfig.node.sequencer = true
sequencerConfig.node["seq-coordinator"].enable = true
sequencerConfig.execution["sequencer"].enable = true
sequencerConfig.node["delayed-sequencer"].enable = true
fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig))

let posterConfig = JSON.parse(baseConfJSON)
posterConfig["parent-chain"].wallet.account = namedAccount("sequencer").address
posterConfig.node["seq-coordinator"].enable = true
posterConfig.node["batch-poster"].enable = true
fs.writeFileSync(path.join(consts.configpath, "poster_config.json"), JSON.stringify(posterConfig))
let posterConfig = JSON.parse(baseConfJSON)
posterConfig.node["seq-coordinator"].enable = true
posterConfig.node["batch-poster"].enable = true
fs.writeFileSync(path.join(consts.configpath, "poster_config.json"), JSON.stringify(posterConfig))
}

let l3Config = JSON.parse(baseConfJSON)
l3Config["parent-chain"].connection.url = argv.l2url
l3Config["parent-chain"].wallet.account = namedAccount("l3sequencer").address
l3Config.node.staker["parent-chain-wallet"].account = namedAddress("l3owner")
l3Config.node["batch-poster"]["parent-chain-wallet"].account = namedAddress("l3sequencer")
l3Config.chain.id = 333333
const l3ChainInfoFile = path.join(consts.configpath, "l3_chain_info.json")
l3Config.chain["info-files"] = [l3ChainInfoFile]
Expand All @@ -271,6 +291,8 @@ function writeConfigs(argv: any) {
l3Config.execution["sequencer"].enable = true
l3Config.node["dangerous"]["no-sequencer-coordinator"] = true
l3Config.node["delayed-sequencer"].enable = true
l3Config.node["delayed-sequencer"]["finalize-distance"] = 0
l3Config.node["delayed-sequencer"]["use-merge-finality"] = false
l3Config.node["batch-poster"].enable = true
l3Config.node["batch-poster"]["redis-url"] = ""
fs.writeFileSync(path.join(consts.configpath, "l3node_config.json"), JSON.stringify(l3Config))
Expand Down Expand Up @@ -366,6 +388,13 @@ function writeL3ChainConfig(argv: any) {
export const writeConfigCommand = {
command: "write-config",
describe: "writes config files",
builder: {
simple: {
boolean: true,
describe: "simple config (sequencer is also poster, validator)",
default: false,
},
},
handler: (argv: any) => {
writeConfigs(argv)
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const l1keystore = "/home/user/l1keystore";
export const l1passphrase = "passphrase";
export const configpath = "/config";
// Not secure. Do not sure for production purposes
export const tokenbridgedatapath = "/tokenbridge-data";
// Not secure. Do not use for production purposes
export const l1mnemonic =
"indoor dish desk flag debris potato excuse depart ticket judge file exit";
Loading

0 comments on commit 6c1acc4

Please sign in to comment.