forked from OffchainLabs/nitro
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for new GetArbOSConfigAtHeight() method in ExecutionNode
This commit adds an integration test for the GetArbOSConfigAtHeight() method on the Execution node that grabs the initial config, and validates it, then updates the config and ensures that the new method will fetch the updated config.
- Loading branch information
Showing
2 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
Submodule nitro-testnode
updated
33 files
+2 −6 | .env | |
+7 −0 | .envrc | |
+91 −0 | .github/workflows/smoke-test.yml | |
+2 −0 | .gitignore | |
+4 −0 | .gitmodules | |
+5 −0 | CODEOWNERS | |
+82 −22 | docker-compose.yaml | |
+23 −0 | espresso-tests/.env | |
+28 −0 | espresso-tests/README.md | |
+23 −0 | espresso-tests/create-espresso-integrated-nitro-node-from-local-tag.bash | |
+27 −0 | espresso-tests/create-espresso-integrated-nitro-node.bash | |
+220 −0 | espresso-tests/migration-test.bash | |
+29 −0 | espresso-tests/test-chain-config.json | |
+90 −0 | flake.lock | |
+44 −0 | flake.nix | |
+10 −0 | node_modules/.yarn-integrity | |
+1 −0 | orbit-actions | |
+3 −2 | rollupcreator/Dockerfile | |
+4 −1 | scripts/Dockerfile | |
+121 −26 | scripts/config.ts | |
+74 −34 | scripts/ethcommands.ts | |
+4 −1 | scripts/index.ts | |
+13 −0 | shell.nix | |
+26 −0 | smoke-test-espresso-finality-node.bash | |
+24 −0 | smoke-test-full-node.bash | |
+31 −0 | smoke-test-l3.bash | |
+21 −0 | smoke-test-nitro-simple.bash | |
+21 −0 | smoke-test.bash | |
+31 −0 | test-helper.bash | |
+102 −29 | test-node.bash | |
+1 −1 | tokenbridge/Dockerfile | |
+14 −0 | transaction-fetcher.bash | |
+17 −0 | transaction-sender.bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package arbtest | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"math/big" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/params" | ||
"github.com/offchainlabs/nitro/arbutil" | ||
"github.com/offchainlabs/nitro/solgen/go/precompilesgen" | ||
) | ||
|
||
func EspressoArbOSTestChainConfig() *params.ChainConfig { | ||
return ¶ms.ChainConfig{ | ||
ChainID: big.NewInt(412346), | ||
HomesteadBlock: big.NewInt(0), | ||
DAOForkBlock: nil, | ||
DAOForkSupport: true, | ||
EIP150Block: big.NewInt(0), | ||
EIP155Block: big.NewInt(0), | ||
EIP158Block: big.NewInt(0), | ||
ByzantiumBlock: big.NewInt(0), | ||
ConstantinopleBlock: big.NewInt(0), | ||
PetersburgBlock: big.NewInt(0), | ||
IstanbulBlock: big.NewInt(0), | ||
MuirGlacierBlock: big.NewInt(0), | ||
BerlinBlock: big.NewInt(0), | ||
LondonBlock: big.NewInt(0), | ||
ArbitrumChainParams: EspressoTestChainParams(), | ||
Clique: ¶ms.CliqueConfig{ | ||
Period: 0, | ||
Epoch: 0, | ||
}, | ||
} | ||
} | ||
func EspressoTestChainParams() params.ArbitrumChainParams { | ||
return params.ArbitrumChainParams{ | ||
EnableArbOS: true, | ||
AllowDebugPrecompiles: true, | ||
DataAvailabilityCommittee: false, | ||
InitialArbOSVersion: 31, | ||
InitialChainOwner: common.Address{}, | ||
EnableEspresso: false, | ||
} | ||
} | ||
|
||
func waitForConfigUpdate(t *testing.T, ctx context.Context, builder *NodeBuilder) error{ | ||
|
||
return waitForWith(t, ctx, 120*time.Second, 1*time.Second, func() bool{ | ||
newArbOSConfig, err := builder.L2.ExecNode.GetArbOSConfigAtHeight(0) | ||
Require(t, err) | ||
|
||
if newArbOSConfig.ArbitrumChainParams.EnableEspresso != false{ | ||
return false | ||
} | ||
Require(t,err) | ||
return true | ||
}) | ||
} | ||
|
||
func TestEspressoArbOSConfig(t *testing.T) { | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
builder, cleanup := createL1AndL2Node(ctx, t) | ||
defer cleanup() | ||
|
||
err := waitForL1Node(t, ctx) | ||
Require(t, err) | ||
|
||
cleanEspresso := runEspresso(t, ctx) | ||
defer cleanEspresso() | ||
|
||
// wait for the builder | ||
err = waitForEspressoNode(t, ctx) | ||
Require(t, err) | ||
|
||
l2Node := builder.L2 | ||
|
||
// Wait for the initial message | ||
expected := arbutil.MessageIndex(1) | ||
err = waitFor(t, ctx, func() bool { | ||
msgCnt, err := l2Node.ConsensusNode.TxStreamer.GetMessageCount() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
validatedCnt := l2Node.ConsensusNode.BlockValidator.Validated(t) | ||
return msgCnt >= expected && validatedCnt >= expected | ||
}) | ||
Require(t, err) | ||
|
||
|
||
initialArbOSConfig, err := builder.L2.ExecNode.GetArbOSConfigAtHeight(0) | ||
Require(t,err) | ||
|
||
//assert that espresso is initially enabled | ||
if initialArbOSConfig.ArbitrumChainParams.EnableEspresso != true{ | ||
err = fmt.Errorf("Initial config should have EnableEspresso == true!") | ||
|
||
} | ||
Require(t,err) | ||
|
||
newArbOwner, err := precompilesgen.NewArbOwner(common.HexToAddress("0x070"), builder.L2.Client) | ||
Require(t, err) | ||
|
||
newArbDebug, err := precompilesgen.NewArbDebug(common.HexToAddress("0xff"), builder.L2.Client) | ||
Require(t, err) | ||
|
||
l2auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) | ||
|
||
_, err = newArbDebug.BecomeChainOwner(&l2auth) | ||
Require(t, err) | ||
chainConfig, err := json.Marshal(EspressoArbOSTestChainConfig()) | ||
Require(t, err) | ||
|
||
chainConfigString := string(chainConfig) | ||
|
||
_, err = newArbOwner.SetChainConfig(&l2auth, chainConfigString) | ||
Require(t, err) | ||
// check if chain config is updated TODO replace this with a wait for with to poll for some time potentially | ||
|
||
waitForConfigUpdate(t, ctx, builder) | ||
} |