Skip to content

Commit

Permalink
Align with latest RollupCretor api
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Oct 10, 2023
1 parent f7e63d5 commit 226bd1c
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN apt-get update && \
apt-get install -y git python3 make g++
WORKDIR /workspace
COPY contracts/package.json contracts/yarn.lock contracts/
RUN cd contracts && yarn install --ignore-optional
RUN cd contracts && yarn install
COPY contracts contracts/
COPY Makefile .
RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity
Expand Down
106 changes: 95 additions & 11 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,91 @@ func andTxSucceeded(ctx context.Context, l1Reader *headerreader.HeaderReader, tx
return nil
}

func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int) (common.Address, error) {
client := l1Reader.Client()

/// deploy eth based templates
bridgeTemplate, tx, _, err := bridgegen.DeployBridge(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("bridge deploy error: %w", err)
}

Check failure on line 76 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to bridgegen.DeploySequencerInbox

Check failure on line 76 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to bridgegen.DeploySequencerInbox

Check failure on line 76 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to bridgegen.DeploySequencerInbox

Check failure on line 76 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to bridgegen.DeploySequencerInbox

Check failure on line 76 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to bridgegen.DeploySequencerInbox

Check failure on line 76 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to bridgegen.DeploySequencerInbox
// maxDataSize := big.NewInt(117964)
seqInboxTemplate, tx, _, err := bridgegen.DeploySequencerInbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("sequencer inbox deploy error: %w", err)
}

Check failure on line 82 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to bridgegen.DeployInbox

Check failure on line 82 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to bridgegen.DeployInbox

Check failure on line 82 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to bridgegen.DeployInbox

Check failure on line 82 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to bridgegen.DeployInbox

Check failure on line 82 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to bridgegen.DeployInbox

Check failure on line 82 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to bridgegen.DeployInbox

inboxTemplate, tx, _, err := bridgegen.DeployInbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("inbox deploy error: %w", err)
}

rollupEventBridgeTemplate, tx, _, err := rollupgen.DeployRollupEventInbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("rollup event bridge deploy error: %w", err)
}

outboxTemplate, tx, _, err := bridgegen.DeployOutbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("outbox deploy error: %w", err)
}

Check failure on line 100 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 100 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 100 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 100 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 100 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 100 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: rollupgen.BridgeCreatorBridgeContracts

ethBasedTemplates := rollupgen.BridgeCreatorBridgeContracts{
Bridge: bridgeTemplate,
SequencerInbox: seqInboxTemplate,
Inbox: inboxTemplate,
RollupEventInbox:rollupEventBridgeTemplate,
Outbox: outboxTemplate,
}

/// deploy ERC20 based templates
erc20BridgeTemplate, tx, _, err := bridgegen.DeployERC20Bridge(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("bridge deploy error: %w", err)
}

Check failure on line 115 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to bridgegen.DeployERC20Inbox

Check failure on line 115 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to bridgegen.DeployERC20Inbox

Check failure on line 115 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to bridgegen.DeployERC20Inbox

Check failure on line 115 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to bridgegen.DeployERC20Inbox

Check failure on line 115 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to bridgegen.DeployERC20Inbox

Check failure on line 115 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to bridgegen.DeployERC20Inbox

erc20InboxTemplate, tx, _, err := bridgegen.DeployERC20Inbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("inbox deploy error: %w", err)
}

erc20RollupEventBridgeTemplate, tx, _, err := rollupgen.DeployERC20RollupEventInbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("rollup event bridge deploy error: %w", err)
}

erc20OutboxTemplate, tx, _, err := bridgegen.DeployERC20Outbox(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("outbox deploy error: %w", err)
}

Check failure on line 133 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 133 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

undefined: rollupgen.BridgeCreatorBridgeContracts

Check failure on line 133 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

undefined: rollupgen.BridgeCreatorBridgeContracts

erc20BasedTemplates := rollupgen.BridgeCreatorBridgeContracts{
Bridge: erc20BridgeTemplate,
SequencerInbox: seqInboxTemplate,
Inbox: erc20InboxTemplate,
RollupEventInbox:erc20RollupEventBridgeTemplate,
Outbox: erc20OutboxTemplate,
}

bridgeCreatorAddr, tx, _, err := rollupgen.DeployBridgeCreator(auth, client, ethBasedTemplates, erc20BasedTemplates)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err)
}

return bridgeCreatorAddr, nil
}

func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts) (common.Address, common.Address, error) {
client := l1Reader.Client()
osp0, tx, _, err := ospgen.DeployOneStepProver0(auth, client)
Expand Down Expand Up @@ -105,11 +190,8 @@ func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderRe
return ospEntryAddr, challengeManagerAddr, nil
}

func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
// deploying bridge creator takes ~14.2 million gas
auth.GasLimit = uint64(15000000)
bridgeCreator, tx, _, err := rollupgen.DeployBridgeCreator(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
bridgeCreator, err := deployBridgeCreator(ctx, l1Reader, auth, maxDataSize)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err)
}
Expand Down Expand Up @@ -161,7 +243,6 @@ func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReade
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("deploy helper creator deploy error: %w", err)
}


tx, err = rollupCreator.SetTemplates(
auth,
bridgeCreator,
Expand Down Expand Up @@ -209,12 +290,12 @@ func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner com
}
}

func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPoster common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address) (*chaininfo.RollupAddresses, error) {
func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPoster common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address, maxDataSize *big.Int) (*chaininfo.RollupAddresses, error) {
if config.WasmModuleRoot == (common.Hash{}) {
return nil, errors.New("no machine specified")
}

rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth)
rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize)
if err != nil {
return nil, fmt.Errorf("error deploying rollup creator: %w", err)
}
Expand All @@ -224,15 +305,16 @@ func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReade
validatorAddrs = append(validatorAddrs, crypto.CreateAddress(validatorWalletCreator, i))
}

// 0.1 gwei
maxFeePerGas := big.NewInt(100000000)
deployUtilityFactories := false
maxFeePerGas := big.NewInt(0) // needed when utility factories are deployed
tx, err := rollupCreator.CreateRollup(
deployAuth,
config,
batchPoster,
validatorAddrs,
maxDataSize,
nativeToken,

Check failure on line 316 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

too many arguments in call to rollupCreator.CreateRollup

Check failure on line 316 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

too many arguments in call to rollupCreator.CreateRollup

Check failure on line 316 in arbnode/node.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

too many arguments in call to rollupCreator.CreateRollup
false,
deployUtilityFactories,
maxFeePerGas,
)
if err != nil {
Expand All @@ -253,6 +335,8 @@ func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReade
SequencerInbox: info.SequencerInbox,
DeployedAt: receipt.BlockNumber.Uint64(),
Rollup: info.RollupAddress,
NativeToken: nativeToken,
UpgradeExecutor: info.UpgradeExecutor,
ValidatorUtils: validatorUtils,
ValidatorWalletCreator: validatorWalletCreator,
}, nil
Expand Down
1 change: 1 addition & 0 deletions cmd/chaininfo/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type RollupAddresses struct {
SequencerInbox common.Address `json:"sequencer-inbox"`
Rollup common.Address `json:"rollup"`
NativeToken common.Address `json:"native-token"`
UpgradeExecutor common.Address `json:"upgrade-executor"`
ValidatorUtils common.Address `json:"validator-utils"`
ValidatorWalletCreator common.Address `json:"validator-wallet-creator"`
DeployedAt uint64 `json:"deployed-at"`
Expand Down
5 changes: 4 additions & 1 deletion cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func main() {
deployAccount := flag.String("l1DeployAccount", "", "l1 seq account to use (default is first account in keystore)")
ownerAddressString := flag.String("ownerAddress", "", "the rollup owner's address")
sequencerAddressString := flag.String("sequencerAddress", "", "the sequencer's address")
nativeTokenAddressString := flag.String("nativeTokenAddress", "", "address of the ERC20 token which is used as native L2 currency")
nativeTokenAddressString := flag.String("nativeTokenAddress", "0x0000000000000000000000000000000000000000", "address of the ERC20 token which is used as native L2 currency")
maxDataSizeUint := flag.Uint64("maxDataSize", 117964, "maximum size of data")
loserEscrowAddressString := flag.String("loserEscrowAddress", "", "the address which half of challenge loser's funds accumulate at")
wasmmoduleroot := flag.String("wasmmoduleroot", "", "WASM module root hash")
wasmrootpath := flag.String("wasmrootpath", "", "path to machine folders")
Expand All @@ -56,6 +57,7 @@ func main() {
prod := flag.Bool("prod", false, "Whether to configure the rollup for production or testing")
flag.Parse()
l1ChainId := new(big.Int).SetUint64(*l1ChainIdUint)
maxDataSize := new(big.Int).SetUint64(*maxDataSizeUint)

if *prod {
if *wasmmoduleroot == "" {
Expand Down Expand Up @@ -147,6 +149,7 @@ func main() {
*authorizevalidators,
arbnode.GenerateRollupConfig(*prod, moduleRoot, ownerAddress, &chainConfig, chainConfigJson, loserEscrowAddress),
nativeToken,
maxDataSize,
)
if err != nil {
flag.Usage()
Expand Down

0 comments on commit 226bd1c

Please sign in to comment.