Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M2 mainnet contracts fix integ tests #237

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
run: make build && go test -v ./core/thegraph

- name: Inabox E2E
run: make build && cd inabox && make run-e2e-nochurner
run: make build && cd inabox && make run-e2e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯


- name: Save logs
if: always()
Expand Down
34 changes: 5 additions & 29 deletions churner/tests/churner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package test

import (
"context"
"crypto/rand"
"flag"
"fmt"
"log"
"math/big"
"os"
"testing"

Expand Down Expand Up @@ -39,7 +37,7 @@ var (
logger = &commock.Logger{}
mockIndexer = &indexermock.MockIndexedChainState{}
rpcURL = "http://localhost:8545"
quorumIds = []uint32{0}
quorumIds = []uint32{0, 1}
operatorAddr = gethcommon.HexToAddress("0x0000000000000000000000000000000000000001")
churnerPrivateKeyHex = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
operatorToChurnInPrivateKeyHex = "0000000000000000000000000000000000000000000000000000000000000020"
Expand Down Expand Up @@ -91,39 +89,14 @@ func teardown() {
func TestChurner(t *testing.T) {
ctx := context.Background()

// get the operator to churn in's transactor and bls public key registered
op := testConfig.Operators[0]
operatorTransactor, err := createTransactorFromScratch(
op.NODE_PRIVATE_KEY,
testConfig.EigenDA.OperatorStateRetreiver,
testConfig.EigenDA.ServiceManager,
logger,
)
assert.NoError(t, err)

keyPair, err := dacore.GenRandomBlsKeys()
assert.NoError(t, err)

quorumIds_ := make([]uint8, len(quorumIds))
for i, q := range quorumIds {
quorumIds_[i] = uint8(q)
}

operatorSalt := [32]byte{}
_, err = rand.Read(operatorSalt[:])
assert.NoError(t, err)

expiry := big.NewInt(1000)
privKey, err := crypto.GenerateKey()
assert.NoError(t, err)

err = operatorTransactor.RegisterOperator(ctx, keyPair, "socket", quorumIds_, privKey, operatorSalt, expiry)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be registering the public key but this isn't a part of the flow anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks v2 contracts are yielding benefits

assert.NoError(t, err)

server := newTestServer(t)

salt := crypto.Keccak256([]byte(operatorToChurnInPrivateKeyHex), []byte("ChurnRequest"))
request := &pb.ChurnRequest{
OperatorAddress: operatorAddr.Hex(),
OperatorToRegisterPubkeyG1: keyPair.PubKey.Serialize(),
OperatorToRegisterPubkeyG2: keyPair.GetPubKeyG2().Serialize(),
Salt: salt,
Expand All @@ -133,6 +106,7 @@ func TestChurner(t *testing.T) {
var requestHash [32]byte
requestHashBytes := crypto.Keccak256(
[]byte("ChurnRequest"),
[]byte(request.OperatorAddress),
request.OperatorToRegisterPubkeyG1,
request.OperatorToRegisterPubkeyG2,
request.Salt,
Expand All @@ -147,6 +121,7 @@ func TestChurner(t *testing.T) {
}, nil)

reply, err := server.Churn(ctx, request)

assert.NoError(t, err)
assert.NotNil(t, reply)
assert.NotNil(t, reply.SignatureWithSaltAndExpiry.GetSalt())
Expand All @@ -159,6 +134,7 @@ func TestChurner(t *testing.T) {
assert.Equal(t, operatorAddr.Bytes(), param.GetOperator())
assert.Equal(t, keyPair.PubKey.Serialize(), param.GetPubkey())
}

}

func createTransactorFromScratch(privateKey, operatorStateRetriever, serviceManager string, logger common.Logger) (*eth.Transactor, error) {
Expand Down
4 changes: 2 additions & 2 deletions core/indexer/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func mustRegisterOperators(env *deploy.Config, logger common.Logger) {
_, err = rand.Read(salt[:])
Expect(err).To(BeNil())

expiry := big.NewInt(1000)
privKey, err := crypto.GenerateKey()
expiry := big.NewInt((time.Now().Add(10 * time.Minute)).Unix())
privKey, err := crypto.HexToECDSA(op.NODE_PRIVATE_KEY)
Expect(err).To(BeNil())

err = tx.RegisterOperator(context.Background(), keyPair, socket, quorums, privKey, salt, expiry)
Expand Down
Loading