Skip to content

Commit

Permalink
fix: eigenda tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed Sep 4, 2024
1 parent fdf4f09 commit adbc5a5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 61 deletions.
2 changes: 1 addition & 1 deletion arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type BatchPoster struct {
// This deviates from the DA spec but is necessary for the batch poster to work efficiently
// since we need to an extended method on the SequencerInbox contract
eigenDAWriter eigenda.EigenDAWriter
dapReaders []daprovider.Reader
dapReaders []daprovider.Reader
dataPoster *dataposter.DataPoster
redisLock *redislock.Simple
messagesPerBatch *arbmath.MovingAverage[uint64]
Expand Down
2 changes: 1 addition & 1 deletion cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func main() {
if err != nil {
panic(fmt.Sprintf("Error opening state db: %v", err.Error()))
}

batchFetcher := func(batchNum uint64) ([]byte, error) {
currentBatch := wavmio.GetInboxPosition()
if batchNum > currentBatch {
Expand Down
59 changes: 20 additions & 39 deletions system_tests/eigenda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,49 @@ import (

"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/params"

"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/execution/gethexec"
)

const (
proxyURL = "http://127.0.0.1:4242"
)

func TestEigenDAProxyBatchPosting(t *testing.T) {

initTest(t)

ctx, cancel := context.WithCancel(context.Background())
defer func() {
cancel()
}()

// Setup L1 chain and contracts
chainConfig := params.ArbitrumDevTestEigenDAConfig()
l1info, l1client, _, l1stack := createTestL1BlockChain(t, nil)
defer requireClose(t, l1stack)
feedErrChan := make(chan error, 10)
addresses, initMessage := DeployOnTestL1(t, ctx, l1info, l1client, chainConfig)

nodeDir := t.TempDir()
l2info := NewArbTestInfo(t, chainConfig.ChainID)
l1NodeConfigA := arbnode.ConfigDefaultL1Test()
builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
builder.BuildL1(t)
// Setup DAS servers
l1NodeConfigB := arbnode.ConfigDefaultL1NonSequencerTest()
sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx)
sequencerTxOptsPtr := &sequencerTxOpts
parentChainID := big.NewInt(1337)
{

// Setup L2 chain
_, l2stackA, l2chainDb, l2arbDb, l2blockchain := createL2BlockChainWithStackConfig(t, l2info, nodeDir, chainConfig, initMessage, nil, nil)
l2info.GenerateAccount("User2")

// Setup EigenDA config
l1NodeConfigA.EigenDA.Enable = true
l1NodeConfigA.EigenDA.Rpc = proxyURL
{

execA, err := gethexec.CreateExecutionNode(ctx, l2stackA, l2chainDb, l2blockchain, l1client, gethexec.ConfigDefaultTest)
Require(t, err)
// Setup DAS config
builder.nodeConfig.EigenDA.Enable = true
builder.nodeConfig.EigenDA.Rpc = proxyURL

l2Cfg := l2blockchain.Config()
l2Cfg.ArbitrumChainParams.DataAvailabilityCommittee = false
l2Cfg.ArbitrumChainParams.EigenDA = true
nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2Cfg, l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, nil, feedErrChan, parentChainID, nil)
Require(t, err)
Require(t, nodeA.Start(ctx))
l2clientA := ClientForStack(t, l2stackA)
// Setup L2 chain
builder.L2Info.GenerateAccount("User2")
builder.BuildL2OnL1(t)

// Setup second node
l1NodeConfigB.BlockValidator.Enable = false
l1NodeConfigB.EigenDA.Enable = true
l1NodeConfigB.EigenDA.Rpc = proxyURL

l2clientB, nodeB := Create2ndNodeWithConfig(t, ctx, nodeA, l1stack, l1info, &l2info.ArbInitData, l1NodeConfigB, nil, nil)
checkEigenDABatchPosting(t, ctx, l1client, l2clientA, l1info, l2info, big.NewInt(1e12), l2clientB)
nodeA.StopAndWait()
nodeB.StopAndWait()
nodeBParams := SecondNodeParams{
nodeConfig: l1NodeConfigB,
initData: &builder.L2Info.ArbInitData,
}
l2B, cleanupB := builder.Build2ndNode(t, &nodeBParams)
checkEigenDABatchPosting(t, ctx, builder.L1.Client, builder.L2.Client, builder.L1Info, builder.L2Info, big.NewInt(1e12), l2B.Client)

builder.L2.cleanup()
cleanupB()
}
}

Expand Down
17 changes: 1 addition & 16 deletions system_tests/full_challenge_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ import (
"github.com/offchainlabs/nitro/arbcompress"
"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/arbos"
"github.com/offchainlabs/nitro/arbos/arbostypes"
"github.com/offchainlabs/nitro/arbstate"
"github.com/offchainlabs/nitro/arbstate/daprovider"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/cmd/chaininfo"
"github.com/offchainlabs/nitro/eigenda"
"github.com/offchainlabs/nitro/execution/gethexec"
"github.com/offchainlabs/nitro/solgen/go/challengegen"
"github.com/offchainlabs/nitro/solgen/go/mocksgen"
"github.com/offchainlabs/nitro/util/signature"

"github.com/offchainlabs/nitro/solgen/go/ospgen"
"github.com/offchainlabs/nitro/solgen/go/yulgen"
Expand Down Expand Up @@ -338,17 +334,7 @@ func setupSequencerInboxStub(ctx context.Context, t *testing.T, l1Info *Blockcha
return bridgeAddr, seqInbox, seqInboxAddr
}

func createL2Nodes(t *testing.T, ctx context.Context, conf *arbnode.Config, chainConfig *params.ChainConfig, l1Client arbutil.L1Interface, l2info *BlockchainTestInfo, rollupAddresses *chaininfo.RollupAddresses, initMsg *arbostypes.ParsedInitMessage, txOpts *bind.TransactOpts, signer signature.DataSignerFunc, fatalErrChan chan error) (*arbnode.Node, *gethexec.ExecutionNode) {
_, stack, l2ChainDb, l2ArbDb, l2Blockchain := createL2BlockChainWithStackConfig(t, l2info, "", chainConfig, initMsg, nil, nil)
execNode, err := gethexec.CreateExecutionNode(ctx, stack, l2ChainDb, l2Blockchain, l1Client, gethexec.ConfigDefaultTest)
Require(t, err)
consensusNode, err := arbnode.CreateNode(ctx, stack, execNode, l2ArbDb, NewFetcherFromConfig(conf), chainConfig, l1Client, rollupAddresses, txOpts, txOpts, signer, fatalErrChan, big.NewInt(1337), nil)
Require(t, err)

return consensusNode, execNode
}

func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, challengeMsgIdx int64, useEigenDA bool, wasRootDir string) {
func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, challengeMsgIdx int64, useEigenDA bool, wasmRootDir string) {
glogger := log.NewGlogHandler(
log.NewTerminalHandler(io.Writer(os.Stderr), false))
glogger.Verbosity(log.LvlInfo)
Expand Down Expand Up @@ -382,7 +368,6 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall

var valStack *node.Node
var mockSpawn *mockSpawner
builder.valnodeConfig.Wasm.RootPath = wasmRootDir
if useStubs {
mockSpawn, valStack = createMockValidationNode(t, ctx, &builder.valnodeConfig.Arbitrator)
} else {
Expand Down
8 changes: 4 additions & 4 deletions system_tests/full_challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ import (
func TestChallengeManagerFullAsserterIncorrect(t *testing.T) {
t.Parallel()
defaultWasmRootDir := ""
RunChallengeTest(t, false, false, makeBatch_MsgsPerBatch+1, defaultWasmRootDir)
RunChallengeTest(t, false, false, makeBatch_MsgsPerBatch+1, false, defaultWasmRootDir)
}

func TestChallengeManagerFullAsserterIncorrectWithPublishedMachine(t *testing.T) {
t.Parallel()
cr, err := github.LatestConsensusRelease(context.Background())
Require(t, err)
machPath := populateMachineDir(t, cr)
RunChallengeTest(t, false, true, makeBatch_MsgsPerBatch+1, machPath)
RunChallengeTest(t, false, true, makeBatch_MsgsPerBatch+1, false, machPath)
}

func TestChallengeManagerFullAsserterCorrect(t *testing.T) {
t.Parallel()
defaultWasmRootDir := ""
RunChallengeTest(t, true, false, makeBatch_MsgsPerBatch+2, defaultWasmRootDir)
RunChallengeTest(t, true, false, makeBatch_MsgsPerBatch+2, false, defaultWasmRootDir)
}

func TestChallengeManagerFullAsserterCorrectWithPublishedMachine(t *testing.T) {
t.Parallel()
cr, err := github.LatestConsensusRelease(context.Background())
Require(t, err)
machPath := populateMachineDir(t, cr)
RunChallengeTest(t, true, true, makeBatch_MsgsPerBatch+2, machPath)
RunChallengeTest(t, true, true, makeBatch_MsgsPerBatch+2, false, machPath)
}

0 comments on commit adbc5a5

Please sign in to comment.