-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interop: SuperSystem for E2E Tests (#11850)
* op-e2e: interop test setup (work in progress) * op-e2e: interop test setup * organization and comment updates * refactor creation code into WIP system2 * save secrets per L2 * Add SuperSystem Interface ; Add Users and Transactions * Further Refactoring ; Fix Test * Add Supervisor * Add Supervisor Client * Comment out Proposer * Add AddL2RPC to Supervisor Client * Fully link Supervisor and OP Node in E2E Test * correct RPC call supervisor_checkBlock * Make EOF acceptable for backend check * final structure names * Change unused functions to _ for linter * fix import order * Add Github Issue Numbers to TODOs * tynes comments: add World Resource as configurable --------- Co-authored-by: protolambda <[email protected]>
- Loading branch information
1 parent
f70248a
commit 5e14a61
Showing
10 changed files
with
784 additions
and
32 deletions.
There are no files selected for viewing
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,31 @@ | ||
package setuputils | ||
|
||
import ( | ||
"crypto/ecdsa" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
|
||
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" | ||
"github.com/ethereum-optimism/optimism/op-service/endpoint" | ||
"github.com/ethereum-optimism/optimism/op-service/txmgr" | ||
) | ||
|
||
func hexPriv(in *ecdsa.PrivateKey) string { | ||
b := e2eutils.EncodePrivKey(in) | ||
return hexutil.Encode(b) | ||
} | ||
|
||
func NewTxMgrConfig(l1Addr endpoint.RPC, privKey *ecdsa.PrivateKey) txmgr.CLIConfig { | ||
return txmgr.CLIConfig{ | ||
L1RPCURL: l1Addr.RPC(), | ||
PrivateKey: hexPriv(privKey), | ||
NumConfirmations: 1, | ||
SafeAbortNonceTooLowCount: 3, | ||
FeeLimitMultiplier: 5, | ||
ResubmissionTimeout: 3 * time.Second, | ||
ReceiptQueryInterval: 50 * time.Millisecond, | ||
NetworkTimeout: 2 * time.Second, | ||
TxNotInMempoolTimeout: 2 * time.Minute, | ||
} | ||
} |
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,85 @@ | ||
package interop | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ethereum-optimism/optimism/op-chain-ops/interopgen" | ||
op_e2e "github.com/ethereum-optimism/optimism/op-e2e" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestInteropTrivial tests a simple interop scenario | ||
// Chains A and B exist, but no messages are sent between them | ||
// and in fact no event-logs are emitted by either chain at all. | ||
// A transaction is sent from Alice to Bob on Chain A. | ||
// The balance of Bob on Chain A is checked before and after the tx. | ||
// The balance of Bob on Chain B is checked after the tx. | ||
func TestInteropTrivial(t *testing.T) { | ||
recipe := interopgen.InteropDevRecipe{ | ||
L1ChainID: 900100, | ||
L2ChainIDs: []uint64{900200, 900201}, | ||
GenesisTimestamp: uint64(time.Now().Unix() + 3), // start chain 3 seconds from now | ||
} | ||
worldResources := worldResourcePaths{ | ||
foundryArtifacts: "../../packages/contracts-bedrock/forge-artifacts", | ||
sourceMap: "../../packages/contracts-bedrock", | ||
} | ||
|
||
// create a super system from the recipe | ||
// and get the L2 IDs for use in the test | ||
s2 := NewSuperSystem(t, &recipe, worldResources) | ||
ids := s2.L2IDs() | ||
|
||
// chainA is the first L2 chain | ||
chainA := ids[0] | ||
// chainB is the second L2 chain | ||
chainB := ids[1] | ||
|
||
// create two users on all L2 chains | ||
s2.AddUser("Alice") | ||
s2.AddUser("Bob") | ||
|
||
bobAddr := s2.Address(chainA, "Bob") | ||
|
||
// check the balance of Bob | ||
clientA := s2.L2GethClient(chainA) | ||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) | ||
defer cancel() | ||
bobBalance, err := clientA.BalanceAt(ctx, bobAddr, nil) | ||
require.NoError(t, err) | ||
expectedBalance, _ := big.NewInt(0).SetString("10000000000000000000000000", 10) | ||
require.Equal(t, expectedBalance, bobBalance) | ||
|
||
// send a tx from Alice to Bob | ||
s2.SendL2Tx( | ||
chainA, | ||
"Alice", | ||
func(l2Opts *op_e2e.TxOpts) { | ||
l2Opts.ToAddr = &bobAddr | ||
l2Opts.Value = big.NewInt(1000000) | ||
l2Opts.GasFeeCap = big.NewInt(1_000_000_000) | ||
l2Opts.GasTipCap = big.NewInt(1_000_000_000) | ||
}, | ||
) | ||
|
||
// check the balance of Bob after the tx | ||
ctx, cancel = context.WithTimeout(context.Background(), 1*time.Second) | ||
defer cancel() | ||
bobBalance, err = clientA.BalanceAt(ctx, bobAddr, nil) | ||
require.NoError(t, err) | ||
expectedBalance, _ = big.NewInt(0).SetString("10000000000000000001000000", 10) | ||
require.Equal(t, expectedBalance, bobBalance) | ||
|
||
// check that the balance of Bob on ChainB hasn't changed | ||
bobAddrB := s2.Address(chainB, "Bob") | ||
clientB := s2.L2GethClient(chainB) | ||
ctx, cancel = context.WithTimeout(context.Background(), 1*time.Second) | ||
defer cancel() | ||
bobBalance, err = clientB.BalanceAt(ctx, bobAddrB, nil) | ||
require.NoError(t, err) | ||
expectedBalance, _ = big.NewInt(0).SetString("10000000000000000000000000", 10) | ||
require.Equal(t, expectedBalance, bobBalance) | ||
} |
Oops, something went wrong.