Skip to content

Commit

Permalink
Merge branch 'master' into v3.2.0-source
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower authored Sep 24, 2024
2 parents 4fa04c0 + cac11e9 commit b0c8cf9
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 199 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/shellcheck-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ShellCheck CI
run-name: ShellCheck CI triggered from @${{ github.actor }} of ${{ github.head_ref }}

on:
workflow_dispatch:
merge_group:
pull_request:
push:
branches:
- master

jobs:
shellcheck:
name: Run ShellCheck
runs-on: ubuntu-8
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
ignore_paths: >-
./fastcache/**
./contracts/**
./safe-smart-account/**
./go-ethereum/**
./nitro-testnode/**
./brotli/**
./arbitrator/**
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
13 changes: 8 additions & 5 deletions scripts/build-brotli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

mydir=`dirname $0`
mydir=$(dirname "$0")
cd "$mydir"

BUILD_WASM=false
Expand Down Expand Up @@ -35,7 +35,7 @@ usage(){
echo "all relative paths are relative to script location"
}

while getopts "s:t:c:D:wldhf" option; do
while getopts "n:s:t:c:D:wldhf" option; do
case $option in
h)
usage
Expand All @@ -62,6 +62,9 @@ while getopts "s:t:c:D:wldhf" option; do
s)
SOURCE_DIR="$OPTARG"
;;
*)
usage
;;
esac
done

Expand All @@ -74,7 +77,7 @@ if [ ! -d "$TARGET_DIR" ]; then
mkdir -p "${TARGET_DIR}lib"
ln -s "lib" "${TARGET_DIR}lib64" # Fedora build
fi
TARGET_DIR_ABS=`cd -P "$TARGET_DIR"; pwd`
TARGET_DIR_ABS=$(cd -P "$TARGET_DIR"; pwd)


if $USE_DOCKER; then
Expand All @@ -94,9 +97,9 @@ cd "$SOURCE_DIR"
if $BUILD_WASM; then
mkdir -p buildfiles/build-wasm
mkdir -p buildfiles/install-wasm
TEMP_INSTALL_DIR_ABS=`cd -P buildfiles/install-wasm; pwd`
TEMP_INSTALL_DIR_ABS=$(cd -P buildfiles/install-wasm; pwd)
cd buildfiles/build-wasm
cmake ../../ -DCMAKE_C_COMPILER=emcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fPIC -DCMAKE_INSTALL_PREFIX="$TEMP_INSTALL_DIR_ABS" -DCMAKE_AR=`which emar` -DCMAKE_RANLIB=`which touch`
cmake ../../ -DCMAKE_C_COMPILER=emcc -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fPIC -DCMAKE_INSTALL_PREFIX="$TEMP_INSTALL_DIR_ABS" -DCMAKE_AR="$(which emar)" -DCMAKE_RANLIB="$(which touch)"
make -j
make install
cp -rv "$TEMP_INSTALL_DIR_ABS/lib" "$TARGET_DIR_ABS/lib-wasm"
Expand Down
Loading

0 comments on commit b0c8cf9

Please sign in to comment.