Skip to content

Commit

Permalink
Merge pull request OffchainLabs#2638 from OffchainLabs/l3_feed_test
Browse files Browse the repository at this point in the history
L3 Test
  • Loading branch information
diegoximenes authored Sep 23, 2024
2 parents 23a16bb + 467ec77 commit cac11e9
Show file tree
Hide file tree
Showing 4 changed files with 447 additions and 158 deletions.
3 changes: 2 additions & 1 deletion cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func main() {
defer l1Reader.StopAndWait()

nativeToken := common.HexToAddress(*nativeTokenAddressString)
deployedAddresses, err := deploycode.DeployOnL1(
deployedAddresses, err := deploycode.DeployOnParentChain(
ctx,
l1Reader,
l1TransactionOpts,
Expand All @@ -189,6 +189,7 @@ func main() {
arbnode.GenerateRollupConfig(*prod, moduleRoot, ownerAddress, &chainConfig, chainConfigJson, loserEscrowAddress),
nativeToken,
maxDataSize,
true,
)
if err != nil {
flag.Usage()
Expand Down
97 changes: 50 additions & 47 deletions deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,60 @@ import (
"github.com/offchainlabs/nitro/util/headerreader"
)

func andTxSucceeded(ctx context.Context, l1Reader *headerreader.HeaderReader, tx *types.Transaction, err error) error {
func andTxSucceeded(ctx context.Context, parentChainReader *headerreader.HeaderReader, tx *types.Transaction, err error) error {
if err != nil {
return fmt.Errorf("error submitting tx: %w", err)
}
_, err = l1Reader.WaitForTxApproval(ctx, tx)
_, err = parentChainReader.WaitForTxApproval(ctx, tx)
if err != nil {
return fmt.Errorf("error executing tx: %w", err)
}
return nil
}

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

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

reader4844, tx, _, err := yulgen.DeployReader4844(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("blob basefee reader deploy error: %w", err)
var reader4844 common.Address
if chainSupportsBlobs {
reader4844, tx, _, err = yulgen.DeployReader4844(auth, client)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("blob basefee reader deploy error: %w", err)
}
}
seqInboxTemplateEthBased, tx, _, err := bridgegen.DeploySequencerInbox(auth, client, maxDataSize, reader4844, false)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("sequencer inbox eth based deploy error: %w", err)
}
seqInboxTemplateERC20Based, tx, _, err := bridgegen.DeploySequencerInbox(auth, client, maxDataSize, reader4844, true)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("sequencer inbox erc20 based deploy error: %w", err)
}

inboxTemplate, tx, _, err := bridgegen.DeployInbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, 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)
err = andTxSucceeded(ctx, parentChainReader, 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)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("outbox deploy error: %w", err)
}
Expand All @@ -85,25 +88,25 @@ func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReade

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

erc20InboxTemplate, tx, _, err := bridgegen.DeployERC20Inbox(auth, client, maxDataSize)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, 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)
err = andTxSucceeded(ctx, parentChainReader, 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)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, fmt.Errorf("outbox deploy error: %w", err)
}
Expand All @@ -117,104 +120,104 @@ func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReade
}

bridgeCreatorAddr, tx, _, err := rollupgen.DeployBridgeCreator(auth, client, ethBasedTemplates, erc20BasedTemplates)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, 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()
func deployChallengeFactory(ctx context.Context, parentChainReader *headerreader.HeaderReader, auth *bind.TransactOpts) (common.Address, common.Address, error) {
client := parentChainReader.Client()
osp0, tx, _, err := ospgen.DeployOneStepProver0(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("osp0 deploy error: %w", err)
}

ospMem, tx, _, err := ospgen.DeployOneStepProverMemory(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospMemory deploy error: %w", err)
}

ospMath, tx, _, err := ospgen.DeployOneStepProverMath(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospMath deploy error: %w", err)
}

ospHostIo, tx, _, err := ospgen.DeployOneStepProverHostIo(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospHostIo deploy error: %w", err)
}

challengeManagerAddr, tx, _, err := challengegen.DeployChallengeManager(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("challenge manager deploy error: %w", err)
}

ospEntryAddr, tx, _, err := ospgen.DeployOneStepProofEntry(auth, client, osp0, ospMem, ospMath, ospHostIo)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospEntry deploy error: %w", err)
}

return ospEntryAddr, challengeManagerAddr, nil
}

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)
func deployRollupCreator(ctx context.Context, parentChainReader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int, chainSupportsBlobs bool) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
bridgeCreator, err := deployBridgeCreator(ctx, parentChainReader, auth, maxDataSize, chainSupportsBlobs)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err)
}

ospEntryAddr, challengeManagerAddr, err := deployChallengeFactory(ctx, l1Reader, auth)
ospEntryAddr, challengeManagerAddr, err := deployChallengeFactory(ctx, parentChainReader, auth)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, err
}

rollupAdminLogic, tx, _, err := rollupgen.DeployRollupAdminLogic(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
rollupAdminLogic, tx, _, err := rollupgen.DeployRollupAdminLogic(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup admin logic deploy error: %w", err)
}

rollupUserLogic, tx, _, err := rollupgen.DeployRollupUserLogic(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
rollupUserLogic, tx, _, err := rollupgen.DeployRollupUserLogic(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup user logic deploy error: %w", err)
}

rollupCreatorAddress, tx, rollupCreator, err := rollupgen.DeployRollupCreator(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
rollupCreatorAddress, tx, rollupCreator, err := rollupgen.DeployRollupCreator(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup creator deploy error: %w", err)
}

upgradeExecutor, tx, _, err := upgrade_executorgen.DeployUpgradeExecutor(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
upgradeExecutor, tx, _, err := upgrade_executorgen.DeployUpgradeExecutor(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("upgrade executor deploy error: %w", err)
}

validatorUtils, tx, _, err := rollupgen.DeployValidatorUtils(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
validatorUtils, tx, _, err := rollupgen.DeployValidatorUtils(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("validator utils deploy error: %w", err)
}

validatorWalletCreator, tx, _, err := rollupgen.DeployValidatorWalletCreator(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
validatorWalletCreator, tx, _, err := rollupgen.DeployValidatorWalletCreator(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("validator wallet creator deploy error: %w", err)
}

l2FactoriesDeployHelper, tx, _, err := rollupgen.DeployDeployHelper(auth, l1Reader.Client())
err = andTxSucceeded(ctx, l1Reader, tx, err)
l2FactoriesDeployHelper, tx, _, err := rollupgen.DeployDeployHelper(auth, parentChainReader.Client())
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("deploy helper creator deploy error: %w", err)
}
Expand All @@ -231,20 +234,20 @@ func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReade
validatorWalletCreator,
l2FactoriesDeployHelper,
)
err = andTxSucceeded(ctx, l1Reader, tx, err)
err = andTxSucceeded(ctx, parentChainReader, tx, err)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("rollup set template error: %w", err)
}

return rollupCreator, rollupCreatorAddress, validatorUtils, validatorWalletCreator, nil
}

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

rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize)
rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize, chainSupportsBlobs)
if err != nil {
return nil, fmt.Errorf("error deploying rollup creator: %w", err)
}
Expand Down
Loading

0 comments on commit cac11e9

Please sign in to comment.