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 Update #158

Merged
merged 41 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ab4cd8f
start
0x0aa0 Nov 22, 2023
c94e852
temp comment scripts
0x0aa0 Nov 28, 2023
0f1a5ca
sm interface
0x0aa0 Jan 5, 2024
e150030
batch confirmer permission
0x0aa0 Jan 5, 2024
69a8ae3
mock rollup reorg
0x0aa0 Jan 8, 2024
3ce4a72
optimistic confirmation
0x0aa0 Jan 10, 2024
6bb3fa7
use ServiceManagerBase
0x0aa0 Jan 10, 2024
c933aa9
update DASM interface
0x0aa0 Jan 10, 2024
f64bf6f
nit
0x0aa0 Jan 10, 2024
e45bb7c
optimistic confirmation
0x0aa0 Jan 10, 2024
6f2788e
Merge branch 'nitro' of https://github.com/Layr-Labs/eigenda into nitro
0x0aa0 Jan 10, 2024
63d0351
nsss calldata
0x0aa0 Jan 12, 2024
5a3c1e8
Merge branch 'master' into m2-mainnet-contracts
0x0aa0 Jan 12, 2024
b105c4a
rm fee
0x0aa0 Jan 12, 2024
41c0064
Updated assignments commitments rebase (#176)
mooselumph Jan 13, 2024
112c739
fix rollup
0x0aa0 Jan 14, 2024
44de9d8
rm op
0x0aa0 Jan 14, 2024
aa8620b
fix scripts
0x0aa0 Jan 14, 2024
7e8d345
fin
0x0aa0 Jan 14, 2024
3c38f51
Update transactor for M2 mainnet contracts (#194)
mooselumph Jan 25, 2024
8ccb524
Update deployment code for M2 mainnet contracts (#193)
mooselumph Jan 25, 2024
ca28ca1
Update indexer M2 mainnet contracts (#195)
mooselumph Jan 25, 2024
aa7b912
Component updates for M2 mainnet contracts (#196)
mooselumph Jan 25, 2024
165e760
Plumb the kickparams for register operator with churn call (#212)
jianoaix Jan 26, 2024
d06dec1
fix(breaking): add storage gap to da service manager storage (#215)
stevennevins Jan 29, 2024
0f83d13
Update subgraphs for m2 contract changes (#192)
mooselumph Jan 29, 2024
5e911e0
Make Churner work on v2 smart contracts (#213)
jianoaix Jan 30, 2024
8bea4a7
Update contract submodules (#224)
0x0aa0 Jan 31, 2024
d104c9d
Update eigenda batch metadata subgraph (#221)
mooselumph Jan 31, 2024
0efdbf0
Merge master into m2 mainnet contracts (#220)
mooselumph Jan 31, 2024
6916ee0
Merge master
mooselumph Jan 31, 2024
48edabb
Update bindings and protoc
mooselumph Jan 31, 2024
f47fbd0
Merge master again
mooselumph Feb 1, 2024
d703d8f
update eigenlayer-contracts submodule (#229)
0x0aa0 Feb 1, 2024
a31bc9e
update eigenlayer-middleware submodule
0x0aa0 Feb 1, 2024
f534540
Add AVS directory (#227)
mooselumph Feb 1, 2024
d950176
Churner fixes for m2 mainnet contracts (#231)
mooselumph Feb 1, 2024
5966e34
Goerli deploy script (#214)
0x0aa0 Feb 2, 2024
c91f47b
Fix unit tests and lint (#234)
mooselumph Feb 2, 2024
8c7be10
fix: integration script (#235)
0x0aa0 Feb 2, 2024
723c9bb
M2 mainnet contracts fix integ tests (#237)
mooselumph Feb 2, 2024
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

- name: Save logs
if: always()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ inabox/resources/kzg/SRSTables/*

**/bin/*
coverage.*

contracts/broadcast
81 changes: 46 additions & 35 deletions api/grpc/churner/churner.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions api/grpc/disperser/disperser.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions api/grpc/disperser/disperser_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/proto/churner/churner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ message ChurnRequest {
// - If any of the quorum fails to register, this entire request will fail.
// The IDs must be in range [0, 255].
repeated uint32 quorum_ids = 5;
// The Ethereum address (in hex like "0x123abcdef...") of the operator.
string operator_address = 6;
}

message ChurnReply {
Expand Down
26 changes: 10 additions & 16 deletions churner/churner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
var (
bipMultiplier = big.NewInt(10000)
secondsTillExpiry = 90 * time.Second
zeroAddressString = "0x0000000000000000000000000000000000000000"
)

type ChurnRequest struct {
OperatorAddress gethcommon.Address
OperatorToRegisterPubkeyG1 *core.G1Point
OperatorToRegisterPubkeyG2 *core.G2Point
OperatorRequestSignature *core.Signature
Expand All @@ -47,7 +47,7 @@ type churner struct {
mu sync.Mutex
Indexer thegraph.IndexedChainState
Transactor core.Transactor
QuorumCount uint16
QuorumCount uint8

privateKey *ecdsa.PrivateKey
logger common.Logger
Expand Down Expand Up @@ -78,14 +78,7 @@ func NewChurner(
}

func (c *churner) VerifyRequestSignature(ctx context.Context, churnRequest *ChurnRequest) (gethcommon.Address, error) {
operatorToRegisterAddress, err := c.Transactor.OperatorIDToAddress(ctx, churnRequest.OperatorToRegisterPubkeyG1.GetOperatorID())
if err != nil {
return gethcommon.Address{}, err
}
if operatorToRegisterAddress == gethcommon.HexToAddress(zeroAddressString) {
return gethcommon.Address{}, errors.New("operatorToRegisterPubkey is not registered with bls pubkey compendium")
}

operatorToRegisterAddress := churnRequest.OperatorAddress
isEqual, err := churnRequest.OperatorToRegisterPubkeyG1.VerifyEquivalence(churnRequest.OperatorToRegisterPubkeyG2)
if err != nil {
return gethcommon.Address{}, err
Expand Down Expand Up @@ -121,7 +114,7 @@ func (c *churner) ProcessChurnRequest(ctx context.Context, operatorToRegisterAdd
}
}

return c.createChurnResponse(ctx, operatorToRegisterId, operatorToRegisterAddress, churnRequest.QuorumIDs)
return c.createChurnResponse(ctx, operatorToRegisterAddress, operatorToRegisterId, churnRequest.QuorumIDs)
}

func (c *churner) UpdateQuorumCount(ctx context.Context) error {
Expand All @@ -142,8 +135,8 @@ func (c *churner) UpdateQuorumCount(ctx context.Context) error {

func (c *churner) createChurnResponse(
ctx context.Context,
operatorToRegisterId core.OperatorID,
operatorToRegisterAddress gethcommon.Address,
operatorToRegisterId core.OperatorID,
quorumIDs []core.QuorumID,
) (*ChurnResponse, error) {
currentBlockNumber, err := c.Transactor.GetCurrentBlockNumber(ctx)
Expand All @@ -163,7 +156,7 @@ func (c *churner) createChurnResponse(
return nil, err
}

signatureWithSaltAndExpiry, err := c.sign(ctx, operatorToRegisterId, operatorsToChurn)
signatureWithSaltAndExpiry, err := c.sign(ctx, operatorToRegisterAddress, operatorToRegisterId, operatorsToChurn)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -210,7 +203,7 @@ func (c *churner) getOperatorsToChurn(ctx context.Context, quorumIDs []uint8, op
churnBIPsOfOperatorStake := big.NewInt(int64(operatorSetParams.ChurnBIPsOfOperatorStake))
churnBIPsOfTotalStake := big.NewInt(int64(operatorSetParams.ChurnBIPsOfTotalStake))

c.logger.Info("lowestStake", "lowestStake", lowestStake.String(), "operatorToRegisterStake", operatorToRegisterStake.String(), "totalStake", totalStake.String())
c.logger.Info("lowestStake", "lowestStake", lowestStake.String(), "operatorToRegisterStake", operatorToRegisterStake.String(), "totalStake", totalStake.String(), "operatorToRegisterAddress", operatorToRegisterAddress.Hex())

// verify the lowest stake against the registering operator's stake
// make sure that: lowestStake * churnBIPsOfOperatorStake < operatorToRegisterStake * bipMultiplier
Expand Down Expand Up @@ -256,7 +249,7 @@ func (c *churner) getOperatorsToChurn(ctx context.Context, quorumIDs []uint8, op
return operatorsToChurn, nil
}

func (c *churner) sign(ctx context.Context, operatorToRegisterId core.OperatorID, operatorsToChurn []core.OperatorToChurn) (*SignatureWithSaltAndExpiry, error) {
func (c *churner) sign(ctx context.Context, operatorToRegisterAddress gethcommon.Address, operatorToRegisterId core.OperatorID, operatorsToChurn []core.OperatorToChurn) (*SignatureWithSaltAndExpiry, error) {
now := time.Now()
privateKeyBytes := crypto.FromECDSA(c.privateKey)
saltKeccak256 := crypto.Keccak256([]byte("churn"), []byte(now.String()), operatorToRegisterId[:], privateKeyBytes)
Expand All @@ -268,7 +261,7 @@ func (c *churner) sign(ctx context.Context, operatorToRegisterId core.OperatorID
expiry := big.NewInt(now.Add(secondsTillExpiry).Unix())

// sign and return signature
hashToSign, err := c.Transactor.CalculateOperatorChurnApprovalDigestHash(ctx, operatorToRegisterId, operatorsToChurn, salt, expiry)
hashToSign, err := c.Transactor.CalculateOperatorChurnApprovalDigestHash(ctx, operatorToRegisterAddress, operatorToRegisterId, operatorsToChurn, salt, expiry)
if err != nil {
return nil, err
}
Expand All @@ -290,6 +283,7 @@ func CalculateRequestHash(churnRequest *ChurnRequest) [32]byte {
var requestHash [32]byte
requestHashBytes := crypto.Keccak256(
[]byte("ChurnRequest"),
[]byte(churnRequest.OperatorAddress.Hex()),
churnRequest.OperatorToRegisterPubkeyG1.Serialize(),
churnRequest.OperatorToRegisterPubkeyG2.Serialize(),
churnRequest.Salt[:],
Expand Down
4 changes: 4 additions & 0 deletions churner/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
pb "github.com/Layr-Labs/eigenda/api/grpc/churner"
"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/core"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down Expand Up @@ -161,6 +162,8 @@ func (s *Server) validateChurnRequest(ctx context.Context, req *pb.ChurnRequest)
func createChurnRequest(req *pb.ChurnRequest) *ChurnRequest {
signature := &core.Signature{G1Point: new(core.G1Point).Deserialize(req.GetOperatorRequestSignature())}

address := gethcommon.HexToAddress(req.GetOperatorAddress())

salt := [32]byte{}
copy(salt[:], req.GetSalt())

Expand All @@ -170,6 +173,7 @@ func createChurnRequest(req *pb.ChurnRequest) *ChurnRequest {
}

return &ChurnRequest{
OperatorAddress: address,
OperatorToRegisterPubkeyG1: new(core.G1Point).Deserialize(req.GetOperatorToRegisterPubkeyG1()),
OperatorToRegisterPubkeyG2: new(core.G2Point).Deserialize(req.GetOperatorToRegisterPubkeyG2()),
OperatorRequestSignature: signature,
Expand Down
Loading
Loading