Skip to content

Commit 01d63d4

Browse files
authored
Merge pull request #95 from OffchainLabs/timeboost-mode
Timeboost mode for nitro-testnode
2 parents adf27f7 + 29521d6 commit 01d63d4

File tree

9 files changed

+269
-26
lines changed

9 files changed

+269
-26
lines changed

docker-compose.yaml

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,15 @@ services:
166166
- "l1keystore:/home/user/l1keystore"
167167
- "config:/config"
168168
- "tokenbridge-data:/tokenbridge-data"
169-
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 *
169+
command:
170+
- --conf.file=/config/sequencer_config.json
171+
- --node.feed.output.enable
172+
- --node.feed.output.port=9642
173+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
174+
- --node.seq-coordinator.my-url=http://sequencer:8547
175+
- --graphql.enable
176+
- --graphql.vhosts=*
177+
- --graphql.corsdomain=*
170178
depends_on:
171179
- geth
172180

@@ -180,7 +188,10 @@ services:
180188
volumes:
181189
- "seqdata_b:/home/user/.arbitrum/local/nitro"
182190
- "config:/config"
183-
command: --conf.file /config/sequencer_config.json --node.seq-coordinator.my-url ws://sequencer_b:8548
191+
command:
192+
- --conf.file=/config/sequencer_config.json
193+
- --node.seq-coordinator.my-url=http://sequencer_b:8547
194+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
184195
depends_on:
185196
- geth
186197
- redis
@@ -195,7 +206,10 @@ services:
195206
volumes:
196207
- "seqdata_c:/home/user/.arbitrum/local/nitro"
197208
- "config:/config"
198-
command: --conf.file /config/sequencer_config.json --node.seq-coordinator.my-url ws://sequencer_c:8548
209+
command:
210+
- --conf.file=/config/sequencer_config.json
211+
- --node.seq-coordinator.my-url=http://sequencer_c:8547
212+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
199213
depends_on:
200214
- geth
201215
- redis
@@ -210,7 +224,10 @@ services:
210224
volumes:
211225
- "seqdata_d:/home/user/.arbitrum/local/nitro"
212226
- "config:/config"
213-
command: --conf.file /config/sequencer_config.json --node.seq-coordinator.my-url ws://sequencer_d:8548
227+
command:
228+
- --conf.file=/config/sequencer_config.json
229+
- --node.seq-coordinator.my-url=http://sequencer_d:8547
230+
- --http.api=net,web3,eth,txpool,debug,timeboost,auctioneer
214231
depends_on:
215232
- geth
216233
- redis
@@ -434,6 +451,37 @@ services:
434451
command:
435452
- --conf.file=/config/l2_das_mirror.json
436453

454+
timeboost-auctioneer:
455+
pid: host # allow debugging
456+
image: nitro-node-dev-testnode
457+
entrypoint: /usr/local/bin/autonomous-auctioneer
458+
volumes:
459+
- "config:/config"
460+
- "timeboost-auctioneer-data:/data"
461+
- "l1keystore:/home/user/l1keystore"
462+
command:
463+
- --conf.file=/config/autonomous_auctioneer_config.json
464+
depends_on:
465+
- redis
466+
467+
timeboost-bid-validator:
468+
pid: host # allow debugging
469+
image: nitro-node-dev-testnode
470+
entrypoint: /usr/local/bin/autonomous-auctioneer
471+
ports:
472+
- "127.0.0.1:9372:8547"
473+
volumes:
474+
- "config:/config"
475+
command:
476+
- --conf.file=/config/bid_validator_config.json
477+
- --http.addr=0.0.0.0
478+
- --http.vhosts=*
479+
- --http.corsdomain=*
480+
- --http.api=auctioneer
481+
- --log-level=INFO
482+
depends_on:
483+
- redis
484+
437485
volumes:
438486
l1data:
439487
consensus:
@@ -453,4 +501,5 @@ volumes:
453501
das-committee-a-data:
454502
das-committee-b-data:
455503
das-mirror-data:
504+
timeboost-auctioneer-data:
456505
boldupgrader-data:

scripts/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
FROM node:18-bullseye-slim
1+
# Stage 1: Base build environment
2+
FROM node:18-bullseye-slim AS base
23
WORKDIR /workspace
34
COPY ./package.json ./yarn.lock ./
45
RUN yarn
6+
7+
# Stage 2: Copy files and run build
8+
FROM base AS pre-build
59
COPY ./*.ts ./tsconfig.json ./
10+
RUN echo "Intermediate image created before yarn build"
11+
12+
# Stage 3: Final build
13+
FROM pre-build AS final
614
RUN yarn build
715
ENTRYPOINT ["node", "index.js"]

scripts/accounts.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as crypto from "crypto";
55
import { runStress } from "./stress";
66
const path = require("path");
77

8-
const specialAccounts = 6;
8+
const specialAccounts = 7;
99

1010
async function writeAccounts() {
1111
for (let i = 0; i < specialAccounts; i++) {
@@ -47,6 +47,9 @@ export function namedAccount(
4747
if (name == "l2owner") {
4848
return specialAccount(5);
4949
}
50+
if (name == "auctioneer") {
51+
return specialAccount(6);
52+
}
5053
if (name.startsWith("user_")) {
5154
return new ethers.Wallet(
5255
ethers.utils.sha256(ethers.utils.toUtf8Bytes(name))
@@ -85,7 +88,8 @@ export function namedAddress(
8588

8689
export const namedAccountHelpString =
8790
"Valid account names:\n" +
88-
" funnel | sequencer | validator | l2owner - known keys used by l2\n" +
91+
" funnel | sequencer | validator | l2owner\n" +
92+
" | auctioneer - known keys used by l2\n" +
8993
" l3owner | l3sequencer - known keys used by l3\n" +
9094
" user_[Alphanumeric] - key will be generated from username\n" +
9195
" threaduser_[Alphanumeric] - same as user_[Alphanumeric]_thread_[thread-id]\n" +

scripts/config.ts

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function writeConfigs(argv: any) {
202202
"dangerous": {
203203
"without-block-validator": false
204204
},
205-
"parent-chain-wallet" : {
205+
"parent-chain-wallet": {
206206
"account": namedAddress("validator"),
207207
"password": consts.l1passphrase,
208208
"pathname": consts.l1keystore,
@@ -236,7 +236,7 @@ function writeConfigs(argv: any) {
236236
"redis-url": argv.redisUrl,
237237
"max-delay": "30s",
238238
"l1-block-bound": "ignore",
239-
"parent-chain-wallet" : {
239+
"parent-chain-wallet": {
240240
"account": namedAddress("sequencer"),
241241
"password": consts.l1passphrase,
242242
"pathname": consts.l1keystore,
@@ -268,7 +268,7 @@ function writeConfigs(argv: any) {
268268
},
269269
"execution": {
270270
"sequencer": {
271-
"enable": false,
271+
"enable": false
272272
},
273273
"forwarding-target": "null",
274274
},
@@ -320,6 +320,13 @@ function writeConfigs(argv: any) {
320320
sequencerConfig.node["seq-coordinator"].enable = true
321321
sequencerConfig.execution["sequencer"].enable = true
322322
sequencerConfig.node["delayed-sequencer"].enable = true
323+
if (argv.timeboost) {
324+
sequencerConfig.execution.sequencer.dangerous = {};
325+
sequencerConfig.execution.sequencer.dangerous.timeboost = {
326+
"enable": true,
327+
"redis-url": argv.redisUrl
328+
};
329+
}
323330
fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig))
324331

325332
let posterConfig = JSON.parse(baseConfJSON)
@@ -396,7 +403,7 @@ function writeL2ChainConfig(argv: any) {
396403
"EnableArbOS": true,
397404
"AllowDebugPrecompiles": true,
398405
"DataAvailabilityCommittee": argv.anytrust,
399-
"InitialArbOSVersion": 32,
406+
"InitialArbOSVersion": 32, // TODO For Timeboost, this still needs to be set to 31
400407
"InitialChainOwner": argv.l2owner,
401408
"GenesisBlockNum": 0
402409
}
@@ -525,14 +532,67 @@ function dasBackendsJsonConfig(argv: any) {
525532
return backends
526533
}
527534

535+
export const writeTimeboostConfigsCommand = {
536+
command: "write-timeboost-configs",
537+
describe: "writes configs for the timeboost autonomous auctioneer and bid validator",
538+
builder: {
539+
"auction-contract": {
540+
string: true,
541+
describe: "auction contract address",
542+
demandOption: true
543+
},
544+
},
545+
handler: (argv: any) => {
546+
writeAutonomousAuctioneerConfig(argv)
547+
writeBidValidatorConfig(argv)
548+
}
549+
}
550+
551+
function writeAutonomousAuctioneerConfig(argv: any) {
552+
const autonomousAuctioneerConfig = {
553+
"auctioneer-server": {
554+
"auction-contract-address": argv.auctionContract,
555+
"db-directory": "/data",
556+
"redis-url": "redis://redis:6379",
557+
"use-redis-coordinator": true,
558+
"redis-coordinator-url": "redis://redis:6379",
559+
"wallet": {
560+
"account": namedAddress("auctioneer"),
561+
"password": consts.l1passphrase,
562+
"pathname": consts.l1keystore
563+
},
564+
},
565+
"bid-validator": {
566+
"enable": false
567+
}
568+
}
569+
const autonomousAuctioneerConfigJSON = JSON.stringify(autonomousAuctioneerConfig)
570+
fs.writeFileSync(path.join(consts.configpath, "autonomous_auctioneer_config.json"), autonomousAuctioneerConfigJSON)
571+
}
572+
573+
function writeBidValidatorConfig(argv: any) {
574+
const bidValidatorConfig = {
575+
"auctioneer-server": {
576+
"enable": false
577+
},
578+
"bid-validator": {
579+
"auction-contract-address": argv.auctionContract,
580+
"redis-url": "redis://redis:6379",
581+
"sequencer-endpoint": "http://sequencer:8547"
582+
}
583+
}
584+
const bidValidatorConfigJSON = JSON.stringify(bidValidatorConfig)
585+
fs.writeFileSync(path.join(consts.configpath, "bid_validator_config.json"), bidValidatorConfigJSON)
586+
}
587+
528588
export const writeConfigCommand = {
529589
command: "write-config",
530590
describe: "writes config files",
531591
builder: {
532592
simple: {
533-
boolean: true,
534-
describe: "simple config (sequencer is also poster, validator)",
535-
default: false,
593+
boolean: true,
594+
describe: "simple config (sequencer is also poster, validator)",
595+
default: false,
536596
},
537597
anytrust: {
538598
boolean: true,
@@ -549,8 +609,12 @@ export const writeConfigCommand = {
549609
describe: "DAS committee member B BLS pub key",
550610
default: ""
551611
},
552-
553-
},
612+
timeboost: {
613+
boolean: true,
614+
describe: "run sequencer in timeboost mode",
615+
default: false
616+
},
617+
},
554618
handler: (argv: any) => {
555619
writeConfigs(argv)
556620
}
@@ -626,8 +690,9 @@ export const writeL2DASKeysetConfigCommand = {
626690
describe: "DAS committee member B BLS pub key",
627691
default: ""
628692
},
629-
},
693+
},
630694
handler: (argv: any) => {
631-
writeL2DASKeysetConfig(argv)
695+
writeL2DASKeysetConfig(argv)
632696
}
633697
}
698+

scripts/ethcommands.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import * as ERC20 from "@openzeppelin/contracts/build/contracts/ERC20.json";
88
import * as TestWETH9 from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/test/TestWETH9.sol/TestWETH9.json";
99
import * as fs from "fs";
1010
import { ARB_OWNER } from "./consts";
11+
import * as TransparentUpgradeableProxy from "@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json"
12+
import * as ExpressLaneAuctionContract from "@arbitrum/nitro-contracts/build/contracts/src/express-lane-auction/ExpressLaneAuction.sol/ExpressLaneAuction.json"
1113
const path = require("path");
1214

1315
async function sendTransaction(argv: any, threadId: number) {
@@ -302,7 +304,8 @@ export const createERC20Command = {
302304
builder: {
303305
deployer: {
304306
string: true,
305-
describe: "account (see general help)"
307+
describe: "account (see general help)",
308+
demandOption: true
306309
},
307310
bridgeable: {
308311
boolean: true,
@@ -382,6 +385,62 @@ export const createERC20Command = {
382385
},
383386
};
384387

388+
export const deployExpressLaneAuctionContractCommand = {
389+
command: "deploy-express-lane-auction",
390+
describe: "Deploy the ExpressLaneAuction contract",
391+
builder: {
392+
"bidding-token": {
393+
string: true,
394+
describe: "bidding token address",
395+
demandOption: true
396+
},
397+
"auctioneer": {
398+
string: true,
399+
describe: "account name to set as auctioneer and admin on contract (default auctioneer)",
400+
default: "auctioneer"
401+
}
402+
},
403+
handler: async (argv: any) => {
404+
console.log("deploy ExpressLaneAuction contract");
405+
argv.provider = new ethers.providers.WebSocketProvider(argv.l2url);
406+
const l2OwnerWallet = namedAccount("l2owner").connect(argv.provider)
407+
const contractFactory = new ContractFactory(ExpressLaneAuctionContract.abi, ExpressLaneAuctionContract.bytecode, l2OwnerWallet)
408+
409+
const contract = await contractFactory.deploy();
410+
await contract.deployTransaction.wait();
411+
console.log("ExpressLaneAuction contract deployed at address:", contract.address);
412+
413+
const auctioneerAddr = namedAddress(argv.auctioneer)
414+
const initIface = new ethers.utils.Interface(["function initialize((address,address,address,(int64,uint64,uint64,uint64),uint256,address,address,address,address,address,address,address))"])
415+
const initData = initIface.encodeFunctionData("initialize", [[
416+
auctioneerAddr, //_auctioneer
417+
argv.biddingToken, //_biddingToken
418+
auctioneerAddr, //_beneficiary
419+
[
420+
Math.round(Date.now() / 60000) * 60, // offsetTimestamp - most recent minute
421+
60, // roundDurationSeconds
422+
15, // auctionClosingSeconds
423+
15 // reserveSubmissionSeconds
424+
],// RoundTiminginfo
425+
1, // _minReservePrice
426+
auctioneerAddr, //_auctioneerAdmin
427+
auctioneerAddr, //_minReservePriceSetter,
428+
auctioneerAddr, //_reservePriceSetter,
429+
auctioneerAddr, //_reservePriceSetterAdmin,
430+
auctioneerAddr, //_beneficiarySetter,
431+
auctioneerAddr, //_roundTimingSetter,
432+
auctioneerAddr //_masterAdmin
433+
]]);
434+
435+
const proxyFactory = new ethers.ContractFactory(TransparentUpgradeableProxy.abi, TransparentUpgradeableProxy.bytecode, l2OwnerWallet)
436+
const proxy = await proxyFactory.deploy(contract.address, namedAddress("l2owner"), initData)
437+
await proxy.deployed()
438+
console.log("Proxy(ExpressLaneAuction) contract deployed at address:", proxy.address);
439+
440+
argv.provider.destroy();
441+
}
442+
};
443+
385444
// Will revert if the keyset is already valid.
386445
async function setValidKeyset(argv: any, upgradeExecutorAddr: string, sequencerInboxAddr: string, keyset: string){
387446
const innerIface = new ethers.utils.Interface(["function setValidKeyset(bytes)"])

0 commit comments

Comments
 (0)