From 4e2c444e90678ecc6cae3973e3ff4a114238d94f Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:45:06 +0530 Subject: [PATCH 01/13] Refactor consensus.go as per testcases --- consensus/consensus.go | 407 ++++++++++++++++++++++++++--------------- 1 file changed, 258 insertions(+), 149 deletions(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index 2a25cf3..c56470e 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -6,7 +6,6 @@ package consensus // uses common for datatypes import ( "bytes" - "context" "encoding/hex" "fmt" "log" @@ -21,12 +20,15 @@ import ( "github.com/BlocSoc-iitr/selene/config/checkpoints" "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "github.com/BlocSoc-iitr/selene/consensus/rpc" + "github.com/BlocSoc-iitr/selene/utils" - "github.com/BlocSoc-iitr/selene/utils/bls" + beacon "github.com/ethereum/go-ethereum/beacon/types" geth "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/holiman/uint256" "github.com/pkg/errors" + bls "github.com/protolambda/bls12-381-util" ) // Error definitions @@ -181,48 +183,72 @@ func (con ConsensusClient) Expected_current_slot() uint64 { } func sync_fallback(inner *Inner, fallback *string) error { - cf, err := (&checkpoints.CheckpointFallback{}).FetchLatestCheckpointFromApi(*fallback) - if err != nil { - return errors.Wrap(err, "failed to fetch checkpoint from API") - } - return inner.sync(cf) + // Create a buffered channel to receive any errors from the goroutine + errorChan := make(chan error, 1) + + go func() { + // Attempt to fetch the latest checkpoint from the API + cf, err := (&checkpoints.CheckpointFallback{}).FetchLatestCheckpointFromApi(*fallback) + if err != nil { + + errorChan <- err + return + } + + if err := inner.sync(cf); err != nil { + errorChan <- err + return + } + + errorChan <- nil + }() + + return <-errorChan } + func sync_all_fallback(inner *Inner, chainID uint64) error { var n config.Network network, err := n.ChainID(chainID) if err != nil { return err } + errorChan := make(chan error, 1) - ch := checkpoints.CheckpointFallback{} + go func() { - checkpointFallback, errWhileCheckpoint := ch.Build() - if errWhileCheckpoint != nil { - return err - } + ch := checkpoints.CheckpointFallback{} - chainId := network.Chain.ChainID - var networkName config.Network - if chainId == 1 { - networkName = config.MAINNET - } else if chainId == 5 { - networkName = config.GOERLI - } else if chainId == 11155111 { - networkName = config.SEPOLIA - } else { - return errors.New("chain id not recognized") - } + checkpointFallback, errWhileCheckpoint := ch.Build() + if errWhileCheckpoint != nil { + errorChan <- errWhileCheckpoint + return + } - // Fetch the latest checkpoint from the network - checkpoint := checkpointFallback.FetchLatestCheckpoint(networkName) + chainId := network.Chain.ChainID + var networkName config.Network + if chainId == 1 { + networkName = config.MAINNET + } else if chainId == 5 { + networkName = config.GOERLI + } else if chainId == 11155111 { + networkName = config.SEPOLIA + } else { + errorChan <- errors.New("chain id not recognized") + return + } - // Sync using the inner struct's sync method - if err := inner.sync(checkpoint); err != nil { - return err - } + // Fetch the latest checkpoint from the network + checkpoint := checkpointFallback.FetchLatestCheckpoint(networkName) - return nil + // Sync using the inner struct's sync method + if err := inner.sync(checkpoint); err != nil { + errorChan <- err + } + + errorChan <- nil + }() + return <-errorChan } func (in *Inner) New(rpcURL string, blockSend chan common.Block, finalizedBlockSend chan *common.Block, checkpointSend chan *[]byte, config *config.Config) *Inner { @@ -240,47 +266,60 @@ func (in *Inner) New(rpcURL string, blockSend chan common.Block, finalizedBlockS } func (in *Inner) Check_rpc() error { - chainID, err := in.RPC.ChainId() - if err != nil { - return err - } - if chainID != in.Config.Chain.ChainID { - return ErrIncorrectRpcNetwork - } - return nil + errorChan := make(chan error, 1) + + go func() { + chainID, err := in.RPC.ChainId() + if err != nil { + errorChan <- err + return + } + if chainID != in.Config.Chain.ChainID { + errorChan <- ErrIncorrectRpcNetwork + return + } + errorChan <- nil + }() + return <-errorChan } -func (in *Inner) get_execution_payload(ctx context.Context, slot *uint64) (*consensus_core.ExecutionPayload, error) { - block, err := in.RPC.GetBlock(*slot) - if err != nil { +func (in *Inner) get_execution_payload(slot *uint64) (*consensus_core.ExecutionPayload, error) { + errorChan := make(chan error, 1) + blockChan := make(chan consensus_core.BeaconBlock, 1) + go func() { + var err error + block, err := in.RPC.GetBlock(*slot) + if err != nil { + errorChan <- err + } + errorChan <- nil + blockChan <- block + }() + + if err := <-errorChan; err != nil { return nil, err } - blockHash, err := utils.TreeHashRoot(block.Body.ToBytes()) + block := <-blockChan + Gethblock, err := beacon.BlockFromJSON("capella", block.Body.Hash) if err != nil { return nil, err } + blockHash := Gethblock.Root() latestSlot := in.Store.OptimisticHeader.Slot finalizedSlot := in.Store.FinalizedHeader.Slot - var verifiedBlockHash []byte - var errGettingBlockHash error + var verifiedBlockHash geth.Hash if *slot == latestSlot { - verifiedBlockHash, errGettingBlockHash = utils.TreeHashRoot(in.Store.OptimisticHeader.ToBytes()) - if errGettingBlockHash != nil { - return nil, ErrPayloadNotFound - } + verifiedBlockHash = toGethHeader(&in.Store.OptimisticHeader).Hash() } else if *slot == finalizedSlot { - verifiedBlockHash, errGettingBlockHash = utils.TreeHashRoot(in.Store.FinalizedHeader.ToBytes()) - if errGettingBlockHash != nil { - return nil, ErrPayloadNotFound - } + verifiedBlockHash = toGethHeader(&in.Store.FinalizedHeader).Hash() } else { return nil, ErrPayloadNotFound } // Compare the hashes - if !bytes.Equal(verifiedBlockHash, blockHash) { + if !bytes.Equal(verifiedBlockHash[:], blockHash.Bytes()) { return nil, fmt.Errorf("%w: expected %v but got %v", ErrInvalidHeaderHash, verifiedBlockHash, blockHash) } @@ -288,7 +327,7 @@ func (in *Inner) get_execution_payload(ctx context.Context, slot *uint64) (*cons return &payload, nil } -func (in *Inner) Get_payloads(ctx context.Context, startSlot, endSlot uint64) ([]interface{}, error) { +func (in *Inner) Get_payloads(startSlot, endSlot uint64) ([]interface{}, error) { var payloads []interface{} // Fetch the block at endSlot to get the initial parent hash @@ -345,11 +384,22 @@ func (in *Inner) Get_payloads(ctx context.Context, startSlot, endSlot uint64) ([ } } func (in *Inner) advance() error { - // Fetch and apply finality update - finalityUpdate, err := in.RPC.GetFinalityUpdate() - if err != nil { - return err + ErrorChan := make(chan error, 1) + finalityChan := make(chan consensus_core.FinalityUpdate, 1) + + go func() { + finalityUpdate, err := in.RPC.GetFinalityUpdate() + if err != nil { + ErrorChan <- err + return + } + finalityChan <- finalityUpdate + ErrorChan <- nil + }() + if ErrorChan != nil { + return <-ErrorChan } + finalityUpdate := <-finalityChan if err := in.verify_finality_update(&finalityUpdate); err != nil { return err } @@ -394,60 +444,74 @@ func (in *Inner) sync(checkpoint [32]byte) error { // Perform bootstrap with the given checkpoint in.bootstrap(checkpoint) - // Calculate the current sync period currentPeriod := utils.CalcSyncPeriod(in.Store.FinalizedHeader.Slot) - // Fetch updates - updates, err := in.RPC.GetUpdates(currentPeriod, MAX_REQUEST_LIGHT_CLIENT_UPDATES) - if err != nil { - return err - } + errorChan := make(chan error, 1) + var updates []consensus_core.Update + var err error + go func() { + updates, err = in.RPC.GetUpdates(currentPeriod, MAX_REQUEST_LIGHT_CLIENT_UPDATES) + if err != nil { + errorChan <- err + } - // Apply updates - for _, update := range updates { - if err := in.verify_update(&update); err != nil { - return err + // Apply updates + for _, update := range updates { + if err := in.verify_update(&update); err != nil { + + errorChan <- err + return + } + in.apply_update(&update) } - in.apply_update(&update) - } - // Fetch and apply finality update - finalityUpdate, err := in.RPC.GetFinalityUpdate() - if err != nil { - return err - } - if err := in.verify_finality_update(&finalityUpdate); err != nil { - return err - } - in.apply_finality_update(&finalityUpdate) + finalityUpdate, err := in.RPC.GetFinalityUpdate() + if err != nil { - // Fetch and apply optimistic update + errorChan <- err + return + } - optimisticUpdate, err := in.RPC.GetOptimisticUpdate() - if err != nil { - return err - } - if err := in.verify_optimistic_update(&optimisticUpdate); err != nil { + if err := in.verify_finality_update(&finalityUpdate); err != nil { + errorChan <- err + return + } + in.apply_finality_update(&finalityUpdate) + + // Fetch and apply optimistic update + + optimisticUpdate, err := in.RPC.GetOptimisticUpdate() + if err != nil { + errorChan <- err + return + } + if err := in.verify_optimistic_update(&optimisticUpdate); err != nil { + errorChan <- err + return + } + in.apply_optimistic_update(&optimisticUpdate) + errorChan <- nil + log.Printf("consensus client in sync with checkpoint: 0x%s", hex.EncodeToString(checkpoint[:])) + }() + + if err := <-errorChan; err != nil { return err } - in.apply_optimistic_update(&optimisticUpdate) - // Log the success message - log.Printf("consensus client in sync with checkpoint: 0x%s", hex.EncodeToString(checkpoint[:])) return nil } func (in *Inner) send_blocks() error { // Get slot from the optimistic header slot := in.Store.OptimisticHeader.Slot - payload, err := in.get_execution_payload(context.Background(), &slot) + payload, err := in.get_execution_payload(&slot) if err != nil { return err } // Get finalized slot from the finalized header finalizedSlot := in.Store.FinalizedHeader.Slot - finalizedPayload, err := in.get_execution_payload(context.Background(), &finalizedSlot) + finalizedPayload, err := in.get_execution_payload(&finalizedSlot) if err != nil { return err } @@ -493,18 +557,28 @@ func (in *Inner) duration_until_next_update() time.Duration { return time.Duration(nextUpdate) * time.Second } func (in *Inner) bootstrap(checkpoint [32]byte) { + errorChan := make(chan error, 1) + bootstrapChan := make(chan consensus_core.Bootstrap, 1) + go func() { + bootstrap, errInBootstrap := in.RPC.GetBootstrap(checkpoint) - bootstrap, errInBootstrap := in.RPC.GetBootstrap(checkpoint) - if errInBootstrap != nil { - log.Printf("failed to fetch bootstrap: %v", errInBootstrap) + if errInBootstrap != nil { + log.Printf("failed to fetch bootstrap: %v", errInBootstrap) + errorChan <- errInBootstrap + return + } + bootstrapChan <- bootstrap + errorChan <- nil + }() + if err := <-errorChan; err != nil { return } + bootstrap := <-bootstrapChan isValid := in.is_valid_checkpoint(bootstrap.Header.Slot) if !isValid { if in.Config.StrictCheckpointAge { - log.Printf("checkpoint too old, consider using a more recent checkpoint") - return + panic("checkpoint too old, consider using a more recent checkpoint") } else { log.Printf("checkpoint too old, consider using a more recent checkpoint") } @@ -521,11 +595,8 @@ func verify_bootstrap(checkpoint [32]byte, bootstrap consensus_core.Bootstrap) { return } - headerHash, err := utils.TreeHashRoot(bootstrap.Header.ToBytes()) - if err != nil { - log.Println("failed to hash header") - return - } + headerHash := toGethHeader(&bootstrap.Header).Hash() + HeaderValid := bytes.Equal(headerHash[:], checkpoint[:]) if !HeaderValid { @@ -547,7 +618,7 @@ func apply_bootstrap(store *LightClientStore, bootstrap consensus_core.Bootstrap func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlot uint64, store *LightClientStore, genesisRoots []byte, forks consensus_core.Forks) error { { - bits := getBits(update.SyncAggregate.SyncCommitteeBits) + bits := getBits(update.SyncAggregate.SyncCommitteeBits[:]) if bits == 0 { return ErrInsufficientParticipation } @@ -587,16 +658,15 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo if !isFinalityProofValid(&update.AttestedHeader, &update.FinalizedHeader, update.FinalityBranch) { return ErrInvalidFinalityProof } - } else if update.FinalizedHeader != (consensus_core.Header{}) { + } else if (update.FinalizedHeader != (consensus_core.Header{}) && update.FinalityBranch == nil) || (update.FinalizedHeader == (consensus_core.Header{}) && update.FinalityBranch != nil) { return ErrInvalidFinalityProof } - // Validate next sync committee and its branch if update.NextSyncCommittee != nil && update.NextSyncCommitteeBranch != nil { if !isNextCommitteeProofValid(&update.AttestedHeader, update.NextSyncCommittee, *update.NextSyncCommitteeBranch) { return ErrInvalidNextSyncCommitteeProof } - } else if update.NextSyncCommittee != nil { + } else if (update.NextSyncCommittee != nil && update.NextSyncCommitteeBranch == nil) && (update.NextSyncCommittee == nil && update.NextSyncCommitteeBranch != nil) { return ErrInvalidNextSyncCommitteeProof } @@ -607,7 +677,7 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo } else { syncCommittee = in.Store.NextSyncCommitee } - pks, err := utils.GetParticipatingKeys(syncCommittee, update.SyncAggregate.SyncCommitteeBits) + pks, err := utils.GetParticipatingKeys(syncCommittee, [64]byte(update.SyncAggregate.SyncCommitteeBits)) if err != nil { return fmt.Errorf("failed to get participating keys: %w", err) } @@ -615,7 +685,7 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo forkVersion := utils.CalculateForkVersion(&forks, update.SignatureSlot) forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(in.Config.Chain.GenesisRoot)) - if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate.SyncCommitteeSignature, forkDataRoot) { + if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { return ErrInvalidSignature } @@ -635,6 +705,9 @@ func (in *Inner) verify_update(update *consensus_core.Update) error { return in.verify_generic_update(&genUpdate, in.expected_current_slot(), &in.Store, in.Config.Chain.GenesisRoot, in.Config.Forks) } func (in *Inner) verify_finality_update(update *consensus_core.FinalityUpdate) error { + if update == nil { + return ErrInvalidUpdate + } genUpdate := GenericUpdate{ AttestedHeader: update.AttestedHeader, SyncAggregate: update.SyncAggregate, @@ -653,7 +726,7 @@ func (in *Inner) verify_optimistic_update(update *consensus_core.OptimisticUpdat return in.verify_generic_update(&genUpdate, in.expected_current_slot(), &in.Store, in.Config.Chain.GenesisRoot, in.Config.Forks) } func (in *Inner) apply_generic_update(store *LightClientStore, update *GenericUpdate) *[]byte { - committeeBits := getBits(update.SyncAggregate.SyncCommitteeBits) + committeeBits := getBits(update.SyncAggregate.SyncCommitteeBits[:]) // Update max active participants if committeeBits > store.CurrentMaxActiveParticipants { @@ -715,11 +788,9 @@ func (in *Inner) apply_generic_update(store *LightClientStore, update *GenericUp } if store.FinalizedHeader.Slot%32 == 0 { - checkpoint, err := utils.TreeHashRoot(store.FinalizedHeader.ToBytes()) - if err != nil { - return nil - } - return &checkpoint + checkpoint := toGethHeader(&store.FinalizedHeader).Hash() + checkpointBytes := checkpoint.Bytes() + return &checkpointBytes } } } @@ -766,7 +837,7 @@ func (in *Inner) apply_optimistic_update(update *consensus_core.OptimisticUpdate } } func (in *Inner) Log_finality_update(update *consensus_core.FinalityUpdate) { - participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits)) / 512.0 * 100.0 + participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits[:])) / 512.0 * 100.0 decimals := 2 if participation == 100.0 { decimals = 1 @@ -784,7 +855,7 @@ func (in *Inner) Log_finality_update(update *consensus_core.FinalityUpdate) { ) } func (in *Inner) Log_optimistic_update(update *consensus_core.OptimisticUpdate) { - participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits)) / 512.0 * 100.0 + participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits[:])) / 512.0 * 100.0 decimals := 2 if participation == 100.0 { decimals = 1 @@ -815,38 +886,52 @@ func (in *Inner) safety_threshold() uint64 { func verifySyncCommitteeSignature( pks []consensus_core.BLSPubKey, // Public keys slice attestedHeader *consensus_core.Header, // Attested header - signature *consensus_core.SignatureBytes, // Signature bytes + signature *consensus_core.SyncAggregate, // Signature bytes forkDataRoot consensus_core.Bytes32, // Fork data root ) bool { // Collect public keys as references (or suitable Go struct) - collectedPks := make([]*consensus_core.BLSPubKey, len(pks)) - for i := range pks { - collectedPks[i] = &pks[i] + if len(pks) == 0 { + fmt.Println("no public keys") + return false } - // Compute headerRoot - headerRoot, err := utils.TreeHashRoot(attestedHeader.ToBytes()) - if err != nil { + if signature == nil { + fmt.Println("no signature") return false } - var headerRootBytes consensus_core.Bytes32 - copy(headerRootBytes[:], headerRoot[:]) - // Compute signingRoot - signingRoot := ComputeCommitteeSignRoot(headerRootBytes, forkDataRoot) - var g2Points []*bls.G2Point - for _, pk := range collectedPks { - var g2Point bls.G2Point - errWhileCoonvertingtoG2 := g2Point.Unmarshal(pk[:]) - if errWhileCoonvertingtoG2 != nil { + collectedPks := make([]*bls.Pubkey, len(pks)) + for i := range pks { + var pksinBytes [48]byte + copy(pksinBytes[:], pks[i][:]) // Copy the bytes safely + var dkey bls.Pubkey + err := dkey.Deserialize(&pksinBytes) + if err != nil { return false } + collectedPks[i] = &dkey + } + + // Compute signingRoot + signingRoot := ComputeCommitteeSignRoot(toGethHeader(attestedHeader), forkDataRoot) + + var sig bls.Signature + signatureForUnmarshalling := [96]byte{} + copy(signatureForUnmarshalling[:], signature.SyncCommitteeSignature[:]) + + if err := sig.Deserialize(&signatureForUnmarshalling); err != nil { + return false } - return utils.IsAggregateValid(*signature, signingRoot, g2Points) + err := bls.FastAggregateVerify(collectedPks, signingRoot[:], &sig) + if err { + return false + } + + return true } -func ComputeCommitteeSignRoot(header consensus_core.Bytes32, fork consensus_core.Bytes32) consensus_core.Bytes32 { +func ComputeCommitteeSignRoot(header *beacon.Header, fork consensus_core.Bytes32) consensus_core.Bytes32 { // Domain type for the sync committee domainType := [4]byte{7, 0, 0, 0} @@ -880,27 +965,18 @@ func (in *Inner) is_valid_checkpoint(blockHashSlot uint64) bool { } func isFinalityProofValid(attestedHeader *consensus_core.Header, finalizedHeader *consensus_core.Header, finalityBranch []consensus_core.Bytes32) bool { - finalityBranchForProof, err := utils.BranchToNodes(finalityBranch) - if err != nil { - return false - } - return utils.IsProofValid(attestedHeader, finalizedHeader.ToBytes(), finalityBranchForProof, 6, 41) + + return utils.IsProofValid(attestedHeader, toGethHeader(finalizedHeader).Hash(), finalityBranch, 6, 105) } func isCurrentCommitteeProofValid(attestedHeader *consensus_core.Header, currentCommittee *consensus_core.SyncCommittee, currentCommitteeBranch []consensus_core.Bytes32) bool { - CurrentCommitteeForProof, err := utils.BranchToNodes(currentCommitteeBranch) - if err != nil { - return false - } - return utils.IsProofValid(attestedHeader, currentCommittee.ToBytes(), CurrentCommitteeForProof, 5, 22) + + return utils.IsProofValid(attestedHeader, toGethSyncCommittee(currentCommittee).Root(), currentCommitteeBranch, 5, 54) } -func isNextCommitteeProofValid(attestedHeader *consensus_core.Header, currentCommittee *consensus_core.SyncCommittee, currentCommitteeBranch []consensus_core.Bytes32) bool { - currentCommitteeBranchForProof, err := utils.BranchToNodes(currentCommitteeBranch) - if err != nil { - return false - } - return utils.IsProofValid(attestedHeader, currentCommittee.ToBytes(), currentCommitteeBranchForProof, 5, 23) +func isNextCommitteeProofValid(attestedHeader *consensus_core.Header, nextCommittee *consensus_core.SyncCommittee, nextCommitteeBranch []consensus_core.Bytes32) bool { + + return utils.IsProofValid(attestedHeader, toGethSyncCommittee(nextCommittee).Root(), nextCommitteeBranch, 5, 55) } func PayloadToBlock(value *consensus_core.ExecutionPayload) (*common.Block, error) { @@ -1005,7 +1081,7 @@ func processTransaction(txBytes *[1073741824]byte, blockHash consensus_core.Byte } // getBits counts the number of bits set to 1 in a [64]byte array -func getBits(bitfield [64]byte) uint64 { +func getBits(bitfield []byte) uint64 { var count uint64 for _, b := range bitfield { count += uint64(popCount(b)) @@ -1062,3 +1138,36 @@ func SomeGasPrice(gasFeeCap, gasTipCap *big.Int, baseFeePerGas uint64) *big.Int } return maxGasPrice } + +func toGethHeader(header *consensus_core.Header) *beacon.Header { + return &beacon.Header{ + Slot: header.Slot, + ProposerIndex: header.ProposerIndex, + ParentRoot: [32]byte(header.ParentRoot), + StateRoot: [32]byte(header.StateRoot), + BodyRoot: [32]byte(header.BodyRoot), + } +} + +type jsonSyncCommittee struct { + Pubkeys []hexutil.Bytes + Aggregate hexutil.Bytes +} + +func toGethSyncCommittee(committee *consensus_core.SyncCommittee) *beacon.SerializedSyncCommittee { + jsoncommittee := &jsonSyncCommittee{ + Aggregate: committee.AggregatePubkey[:], + } + + for _, pubkey := range committee.Pubkeys { + jsoncommittee.Pubkeys = append(jsoncommittee.Pubkeys, pubkey[:]) + } + + var s beacon.SerializedSyncCommittee + + for i, key := range jsoncommittee.Pubkeys { + copy(s[i*48:], key[:]) + } + copy(s[512*48:], jsoncommittee.Aggregate[:]) + return &s +} From e9a785ca7cd29fc5fa215149649fa578df5e2e19 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:47:23 +0530 Subject: [PATCH 02/13] Update utils.go according to implementation and logic in go-ethereum --- utils/utils.go | 172 +++++++++++++++++-------------------------------- 1 file changed, 59 insertions(+), 113 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index c44317c..b90f97a 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,23 +2,21 @@ package utils import ( "encoding/hex" - + "net/url" + "strconv" "strings" - "bytes" "crypto/sha256" "encoding/json" "fmt" "log" + "github.com/ethereum/go-ethereum/beacon/merkle" "github.com/ethereum/go-ethereum/common" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - "github.com/BlocSoc-iitr/selene/utils/bls" + consensus_core "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" - "github.com/pkg/errors" - merkletree "github.com/wealdtech/go-merkletree" + beacon "github.com/ethereum/go-ethereum/beacon/types" ) // if we need to export the functions , just make their first letter capitalised @@ -34,6 +32,17 @@ func Hex_str_to_bytes(s string) ([]byte, error) { return bytesArray, nil } +func Hex_str_to_Bytes32(s string) (consensus_core.Bytes32, error) { + bytesArray, err := Hex_str_to_bytes(s) + if err != nil { + return consensus_core.Bytes32{}, err + } + + var bytes32 consensus_core.Bytes32 + copy(bytes32[:], bytesArray) + return bytes32, nil +} + func Address_to_hex_string(addr common.Address) string { bytesArray := addr.Bytes() return fmt.Sprintf("0x%x", hex.EncodeToString(bytesArray)) @@ -60,37 +69,12 @@ func Bytes_serialize(bytes []byte) ([]byte, error) { return json.Marshal(hexString) } -// TreeHashRoot computes the Merkle root from the provided leaves in a flat []byte slice. -// TreeHashRoot calculates the root hash from the input data. -func TreeHashRoot(data []byte) ([]byte, error) { - // Convert the input data into a slice of leaves - leaves, err := bytesToLeaves(data) +func Str_to_uint64(s string) (uint64, error) { + num, err := strconv.ParseUint(s, 10, 64) if err != nil { - return nil, fmt.Errorf("error converting bytes to leaves: %w", err) + return 0, err } - - // Create the Merkle tree using the leaves - tree, errorCreatingMerkleTree := merkletree.New(leaves) - if errorCreatingMerkleTree != nil { - return nil, fmt.Errorf("error creating Merkle tree: %w", err) - } - - // Fetch the root hash of the tree - root := tree.Root() - if root == nil { - return nil, errors.New("failed to calculate the Merkle root: root is nil") - } - - return root, nil -} - -func bytesToLeaves(data []byte) ([][]byte, error) { - var leaves [][]byte - if err := json.Unmarshal(data, &leaves); err != nil { - return nil, err - } - - return leaves, nil + return num, nil } func CalcSyncPeriod(slot uint64) uint64 { @@ -99,72 +83,25 @@ func CalcSyncPeriod(slot uint64) uint64 { } // isAggregateValid checks if the provided signature is valid for the given message and public keys. -func IsAggregateValid(sigBytes consensus_core.SignatureBytes, msg [32]byte, pks []*bls.G2Point) bool { - var sigInBytes [96]byte - copy(sigInBytes[:], sigBytes[:]) - // Deserialize the signature from bytes - var sig bls12381.G1Affine - if err := sig.Unmarshal(sigInBytes[:]); err != nil { - return false - } - - // Map the message to a point on the curve - msgPoint := bls.MapToCurve(msg) - - // Aggregate the public keys - aggPubKey := bls.AggregatePublicKeys(pks) - - // Prepare the pairing check inputs - P := [2]bls12381.G1Affine{*msgPoint, sig} - Q := [2]bls12381.G2Affine{*aggPubKey.G2Affine, *bls.GetG2Generator()} - - // Perform the pairing check - ok, err := bls12381.PairingCheck(P[:], Q[:]) - if err != nil { - return false - } - return ok -} +//NO NEED OF THIS FUNCTION HERE AS IT IS NOW DIRECTLY IMPORTED FROM GETH IN CONSENSUS func IsProofValid( attestedHeader *consensus_core.Header, - leafObject []byte, // Single byte slice of the leaf object - branch [][]byte, // Slice of byte slices for the branch + leafObject common.Hash, // Single byte slice of the leaf object + branch []consensus_core.Bytes32, // Slice of byte slices for the branch depth, index int, // Depth of the Merkle proof and index of the leaf ) bool { - // If the branch length is not equal to the depth, return false - if len(branch) != depth { - return false + var branchInMerkle merkle.Values + for _, node := range branch { + branchInMerkle = append(branchInMerkle, merkle.Value(node)) } - - // Initialize the derived root as the leaf object's hash - derivedRoot, errFetchingTreeHashRoot := TreeHashRoot(leafObject) - - if errFetchingTreeHashRoot != nil { - fmt.Printf("Error fetching tree hash root: %v", errFetchingTreeHashRoot) + fmt.Print(attestedHeader.StateRoot) + err := merkle.VerifyProof(common.Hash(attestedHeader.StateRoot), uint64(index), branchInMerkle, merkle.Value(leafObject)) + if err != nil { + log.Println("Error in verifying Merkle proof:", err) return false } - - // Iterate over the proof's hashes - for i, hash := range branch { - hasher := sha256.New() - - // Use the index to determine how to combine the hashes - if (index>>i)&1 == 1 { - // If index is odd, hash node || derivedRoot - hasher.Write(hash) - hasher.Write(derivedRoot) - } else { - // If index is even, hash derivedRoot || node - hasher.Write(derivedRoot) - hasher.Write(hash) - } - // Update derivedRoot for the next level - derivedRoot = hasher.Sum(nil) - } - - // Compare the final derived root with the attested header's state root - return bytes.Equal(derivedRoot, attestedHeader.StateRoot[:]) + return true } func CalculateForkVersion(forks *consensus_core.Forks, slot uint64) [4]byte { @@ -184,17 +121,19 @@ func CalculateForkVersion(forks *consensus_core.Forks, slot uint64) [4]byte { } } +// computed not as helios but as per go-ethereum/beacon/consensus.go func ComputeForkDataRoot(currentVersion [4]byte, genesisValidatorRoot consensus_core.Bytes32) consensus_core.Bytes32 { - forkData := ForkData{ - CurrentVersion: currentVersion, - GenesisValidatorRoot: genesisValidatorRoot, - } + var ( + hasher = sha256.New() + forkVersion32 merkle.Value + forkDataRoot merkle.Value + ) + copy(forkVersion32[:], currentVersion[:]) + hasher.Write(forkVersion32[:]) + hasher.Write(genesisValidatorRoot[:]) + hasher.Sum(forkDataRoot[:0]) - hash, err := TreeHashRoot(forkData.ToBytes()) - if err != nil { - return consensus_core.Bytes32{} - } - return consensus_core.Bytes32(hash) + return consensus_core.Bytes32(forkDataRoot) } // GetParticipatingKeys retrieves the participating public keys from the committee based on the bitfield represented as a byte array. @@ -222,18 +161,21 @@ func GetParticipatingKeys(committee *consensus_core.SyncCommittee, bitfield [64] return pks, nil } -func ComputeSigningRoot(objectRoot, domain consensus_core.Bytes32) consensus_core.Bytes32 { - signingData := SigningData{ - ObjectRoot: objectRoot, - Domain: domain, - } - hash, err := TreeHashRoot(signingData.ToBytes()) - if err != nil { - return consensus_core.Bytes32{} - } - return consensus_core.Bytes32(hash) +// implemented as per go-ethereum/beacon/types/config.go +func ComputeSigningRoot(header *beacon.Header, domain consensus_core.Bytes32) consensus_core.Bytes32 { + var ( + signingRoot common.Hash + headerHash = header.Hash() + hasher = sha256.New() + ) + hasher.Write(headerHash[:]) + hasher.Write(domain[:]) + hasher.Sum(signingRoot[:0]) + + return consensus_core.Bytes32(signingRoot.Bytes()) } +// implemented as per go-ethereum/beacon/types/config.go func ComputeDomain(domainType [4]byte, forkDataRoot consensus_core.Bytes32) consensus_core.Bytes32 { data := append(domainType[:], forkDataRoot[:28]...) return sha256.Sum256(data) @@ -279,3 +221,7 @@ func BranchToNodes(branch []consensus_core.Bytes32) ([][]byte, error) { } return nodes, nil } +func IsURL(str string) bool { + u, err := url.Parse(str) + return err == nil && u.Scheme != "" && u.Host != "" +} From e8a144dc4e430c67bf6151e6a7cf1027903e0f7c Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Mon, 7 Oct 2024 22:48:25 +0530 Subject: [PATCH 03/13] Implemented consensus_test.go testcases are as per helios --- consensus/consensus_test.go | 312 ++++++++++++++++++++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 consensus/consensus_test.go diff --git a/consensus/consensus_test.go b/consensus/consensus_test.go new file mode 100644 index 0000000..1de1620 --- /dev/null +++ b/consensus/consensus_test.go @@ -0,0 +1,312 @@ +package consensus + +import ( + "encoding/hex" + "log" + "testing" + + "github.com/BlocSoc-iitr/selene/common" + "github.com/BlocSoc-iitr/selene/config" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "github.com/BlocSoc-iitr/selene/utils" +) + +func GetClient(strictCheckpointAge bool, sync bool) (*Inner, error) { + var n config.Network + baseConfig, err := n.BaseConfig("MAINNET") + if err != nil { + return nil, err + } + + config := &config.Config{ + ConsensusRpc: "", + ExecutionRpc: "", + Chain: baseConfig.Chain, + Forks: baseConfig.Forks, + StrictCheckpointAge: strictCheckpointAge, + } + + checkpoint := "5afc212a7924789b2bc86acad3ab3a6ffb1f6e97253ea50bee7f4f51422c9275" + + //Decode the hex string into a byte slice + checkpointBytes, err := hex.DecodeString(checkpoint) + checkpointBytes32 := [32]byte{} + copy(checkpointBytes32[:], checkpointBytes) + if err != nil { + log.Fatalf("failed to decode checkpoint: %v", err) + } + + blockSend := make(chan common.Block, 256) + finalizedBlockSend := make(chan *common.Block) + channelSend := make(chan *[]byte) + + In := Inner{} + client := In.New( + "testdata/", + blockSend, + finalizedBlockSend, + channelSend, + config, + ) + + if sync { + err := client.sync(checkpointBytes32) + if err != nil { + return nil, err + } + } else { + client.bootstrap(checkpointBytes32) + } + + return client, nil +} + +// testVerifyUpdate runs the test and returns its result via a channel (no inputs required). +func TestVerifyUpdate(t *testing.T) { + //Get the client + client, err := GetClient(false, false) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + //Calculate the sync period + period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) + + //Fetch updates + updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) + if err != nil { + t.Fatalf("failed to get updates: %v", err) + } + + //Ensure we have updates to verify + if len(updates) == 0 { + t.Fatalf("no updates fetched") + } + + //Verify the first update + update := updates[0] + err = client.verify_update(&update) + if err != nil { + t.Fatalf("failed to verify update: %v", err) + } + +} + +func TestVerifyUpdateInvalidCommittee(t *testing.T) { + client, err := GetClient(false, false) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) + updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) + if err != nil { + t.Fatalf("failed to get updates: %v", err) + } + + if len(updates) == 0 { + t.Fatalf("no updates fetched") + } + + update := updates[0] + update.NextSyncCommittee.Pubkeys[0] = consensus_core.BLSPubKey{} // Invalid public key + + err = client.verify_update(&update) + if err == nil || err.Error() != "invalid next sync committee proof" { + t.Fatalf("expected 'invalid next sync committee proof', got %v", err) + } +} + +func TestVerifyUpdateInvalidFinality(t *testing.T) { + client, err := GetClient(false, false) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) + updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) + if err != nil { + t.Fatalf("failed to get updates: %v", err) + } + + if len(updates) == 0 { + t.Fatalf("no updates fetched") + } + + update := updates[0] + update.FinalizedHeader = consensus_core.Header{} // Assuming an empty header is invalid + + err = client.verify_update(&update) + if err == nil || err.Error() != "invalid finality proof" { + t.Fatalf("expected 'invalid finality proof', got %v", err) + } +} + +func TestVerifyUpdateInvalidSig(t *testing.T) { + client, err := GetClient(false, false) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) + updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) + if err != nil { + t.Fatalf("failed to get updates: %v", err) + } + + if len(updates) == 0 { + t.Fatalf("no updates fetched") + } + + update := updates[0] + update.SyncAggregate.SyncCommitteeSignature = consensus_core.SignatureBytes{} // Assuming an empty signature is invalid + + err = client.verify_update(&update) + if err == nil || err.Error() != "invalid signature" { + t.Fatalf("expected 'invalid signature', got %v", err) + } +} + +func TestVerifyFinality(t *testing.T) { + //Get the client + client, err := GetClient(false, true) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + //Fetch the finality update + update, err := client.RPC.GetFinalityUpdate() + if err != nil { + t.Fatalf("failed to get finality update: %v", err) + } + + //Verify the finality update + err = client.verify_finality_update(&update) + if err != nil { + t.Fatalf("finality verification failed: %v", err) + } +} + +func TestVerifyFinalityInvalidFinality(t *testing.T) { + //Get the client + client, err := GetClient(false, true) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + //Fetch the finality update + update, err := client.RPC.GetFinalityUpdate() + if err != nil { + t.Fatalf("failed to get finality update: %v", err) + } + + //Modify the finalized header to be invalid + update.FinalizedHeader = consensus_core.Header{} //Assuming an empty header is invalid + + //Verify the finality update and expect an error + err = client.verify_finality_update(&update) + if err == nil { + t.Fatalf("expected error, got nil") + } + + //Check if the error matches the expected error message + expectedErr := "invalid finality proof" + if err.Error() != expectedErr { + t.Errorf("expected %s, got %v", expectedErr, err) + } +} + +func TestVerifyFinalityInvalidSignature(t *testing.T) { + //Get the client + client, err := GetClient(false, true) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + //Fetch the finality update + update, err := client.RPC.GetFinalityUpdate() + if err != nil { + t.Fatalf("failed to get finality update: %v", err) + } + + //Modify the sync aggregate signature to be invalid + update.SyncAggregate.SyncCommitteeSignature = consensus_core.SignatureBytes{} //Assuming an empty signature is invalid + + //Verify the finality update and expect an error + err = client.verify_finality_update(&update) + if err == nil { + t.Fatalf("expected error, got nil") + } + + //Check if the error matches the expected error message + expectedErr := "invalid signature" + if err.Error() != expectedErr { + t.Errorf("expected %s, got %v", expectedErr, err) + } +} + +func TestVerifyOptimistic(t *testing.T) { + //Get the client + client, err := GetClient(false, true) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + //Fetch the optimistic update + update, err := client.RPC.GetOptimisticUpdate() + if err != nil { + t.Fatalf("failed to get optimistic update: %v", err) + } + + //Verify the optimistic update + err = client.verify_optimistic_update(&update) + if err != nil { + t.Fatalf("optimistic verification failed: %v", err) + } +} +func TestVerifyOptimisticInvalidSignature(t *testing.T) { + //Get the client + client, err := GetClient(false, true) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } + + //Fetch the optimistic update + update, err := client.RPC.GetOptimisticUpdate() + if err != nil { + t.Fatalf("failed to get optimistic update: %v", err) + } + + //Modify the sync aggregate signature to be invalid + update.SyncAggregate.SyncCommitteeSignature = consensus_core.SignatureBytes{} //Assuming an empty signature is invalid + + //Verify the optimistic update and expect an error + err = client.verify_optimistic_update(&update) + if err == nil { + t.Fatalf("expected error, got nil") + } + + //Check if the error matches the expected error message + expectedErr := "invalid signature" + if err.Error() != expectedErr { + t.Errorf("expected %s, got %v", expectedErr, err) + } +} +func TestVerifyCheckpointAgeInvalid(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Fatalf("expected panic due to invalid checkpoint age, but no panic occurred") + } else { + expectedPanicMessage := "checkpoint too old, consider using a more recent checkpoint" + if msg, ok := r.(string); ok && msg != expectedPanicMessage { + t.Errorf("expected panic message '%s', got '%s'", expectedPanicMessage, msg) + } + } + }() + + // This should trigger a panic due to the invalid checkpoint age + _, err := GetClient(true, false) + if err != nil { + t.Fatalf("failed to get client: %v", err) + } +} From fa2f219517ca5386071137530e04dcda703fcf75 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Mon, 7 Oct 2024 21:17:03 +0000 Subject: [PATCH 04/13] Implemented_utils_and_made_rpc_work_with_consensus --- consensus/consensus_core/consensus_core.go | 245 ++++++------- consensus/consensus_core/serde_utils.go | 382 +++++++++++++++++++++ consensus/rpc/consensus_rpc.go | 4 + consensus/rpc/mock_rpc.go | 42 ++- consensus/rpc/nimbus_rpc.go | 12 +- 5 files changed, 526 insertions(+), 159 deletions(-) create mode 100644 consensus/consensus_core/serde_utils.go diff --git a/consensus/consensus_core/consensus_core.go b/consensus/consensus_core/consensus_core.go index aab009b..3e8c661 100644 --- a/consensus/consensus_core/consensus_core.go +++ b/consensus/consensus_core/consensus_core.go @@ -1,12 +1,6 @@ package consensus_core -import ( - "bytes" - - "github.com/BlocSoc-iitr/selene/consensus/types" - "github.com/ugorji/go/codec" -) - +type Transaction = [1073741824]byte type Bytes32 [32]byte type BLSPubKey [48]byte type Address [20]byte @@ -14,196 +8,198 @@ type LogsBloom [256]byte type SignatureBytes [96]byte type BeaconBlock struct { - Slot uint64 - ProposerIndex uint64 - ParentRoot Bytes32 - StateRoot Bytes32 - Body BeaconBlockBody + Slot uint64 `json:"slot"` + ProposerIndex uint64 `json:"proposer_index"` + ParentRoot Bytes32 `json:"parent_root"` + StateRoot Bytes32 `json:"state_root"` + Body BeaconBlockBody `json:"body"` } type Eth1Data struct { - DepositRoot Bytes32 - DepositCount uint64 - BlockHash Bytes32 + DepositRoot Bytes32 `json:"deposit_root"` + DepositCount uint64 `json:"deposit_count"` + BlockHash Bytes32 `json:"block_hash"` } type ProposerSlashing struct { - SignedHeader1 SignedBeaconBlockHeader - SignedHeader2 SignedBeaconBlockHeader + SignedHeader1 SignedBeaconBlockHeader `json:"signed_header_1"` + SignedHeader2 SignedBeaconBlockHeader `json:"signed_header_2"` } type SignedBeaconBlockHeader struct { - Message BeaconBlockHeader - Signature SignatureBytes + Message BeaconBlockHeader `json:"message"` + Signature SignatureBytes `json:"signature"` } type BeaconBlockHeader struct { - Slot uint64 - ProposerIndex uint64 - ParentRoot Bytes32 - StateRoot Bytes32 - BodyRoot Bytes32 + Slot uint64 `json:"slot"` + ProposerIndex uint64 `json:"proposer_index"` + ParentRoot Bytes32 `json:"parent_root"` + StateRoot Bytes32 `json:"state_root"` + BodyRoot Bytes32 `json:"body_root"` } type AttesterSlashing struct { - Attestation1 IndexedAttestation - Attestation2 IndexedAttestation + Attestation1 IndexedAttestation `json:"attestation_1"` + Attestation2 IndexedAttestation `json:"attestation_2"` } type IndexedAttestation struct { - AttestingIndices [2048]uint64 - Data AttestationData - Signature SignatureBytes + AttestingIndices [2048]uint64 `json:"attesting_indices"` // Dynamic slice + Data AttestationData `json:"data"` + Signature SignatureBytes `json:"signature"` } type AttestationData struct { - Slot uint64 - Index uint64 - BeaconBlockRoot Bytes32 - Source Checkpoint - Target Checkpoint + Slot uint64 `json:"slot"` + Index uint64 `json:"index"` + BeaconBlockRoot Bytes32 `json:"beacon_block_root"` + Source Checkpoint `json:"source"` + Target Checkpoint `json:"target"` } type Checkpoint struct { - Epoch uint64 - Root Bytes32 + Epoch uint64 `json:"epoch"` + Root Bytes32 `json:"root"` } type Bitlist []bool type Attestation struct { - AggregationBits Bitlist `ssz-max:"2048"` - Data AttestationData - Signature SignatureBytes + AggregationBits Bitlist `json:"aggregation_bits"` + Data AttestationData `json:"data"` + Signature SignatureBytes `json:"signature"` } type Deposit struct { - Proof [33]Bytes32 // fixed size array - Data DepositData + Proof [33]Bytes32 `json:"proof"` // Dynamic slice + Data DepositData `json:"data"` } type DepositData struct { - Pubkey [48]byte - WithdrawalCredentials Bytes32 - Amount uint64 - Signature SignatureBytes + Pubkey BLSPubKey `json:"pubkey"` + WithdrawalCredentials Bytes32 `json:"withdrawal_credentials"` + Amount uint64 `json:"amount"` + Signature SignatureBytes `json:"signature"` } type SignedVoluntaryExit struct { - Message VoluntaryExit - Signature SignatureBytes + Message VoluntaryExit `json:"message"` + Signature SignatureBytes `json:"signature"` } type VoluntaryExit struct { - Epoch uint64 - ValidatorIndex uint64 + Epoch uint64 `json:"epoch"` + ValidatorIndex uint64 `json:"validator_index"` } type SyncAggregate struct { - SyncCommitteeBits [64]byte - SyncCommitteeSignature SignatureBytes + SyncCommitteeBits []byte `json:"sync_committee_bits"` + SyncCommitteeSignature SignatureBytes `json:"sync_committee_signature"` } type Withdrawal struct { - Index uint64 - ValidatorIndex uint64 - Address Address - Amount uint64 + Index uint64 `json:"index"` + ValidatorIndex uint64 `json:"validator_index"` + Address Address `json:"address"` + Amount uint64 `json:"amount"` } type ExecutionPayload struct { - ParentHash Bytes32 - FeeRecipient Address - StateRoot Bytes32 - ReceiptsRoot Bytes32 - LogsBloom LogsBloom - PrevRandao Bytes32 - BlockNumber uint64 - GasLimit uint64 - GasUsed uint64 - Timestamp uint64 - ExtraData [32]byte - BaseFeePerGas uint64 - BlockHash Bytes32 - Transactions []types.Transaction `ssz-max:"1048576"` - Withdrawals []types.Withdrawal `ssz-max:"16"` - BlobGasUsed *uint64 // Deneb-specific field, use pointer for optionality - ExcessBlobGas *uint64 // Deneb-specific field, use pointer for optionality + ParentHash Bytes32 `json:"parent_hash"` + FeeRecipient Address `json:"fee_recipient"` + StateRoot Bytes32 `json:"state_root"` + ReceiptsRoot Bytes32 `json:"receipts_root"` + LogsBloom LogsBloom `json:"logs_bloom"` + PrevRandao Bytes32 `json:"prev_randao"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData []byte `json:"extra_data"` + BaseFeePerGas uint64 `json:"base_fee_per_gas"` + BlockHash Bytes32 `json:"block_hash"` + Transactions []Transaction `json:"transactions"` + Withdrawals *[]Withdrawal `json:"withdrawals"` //Only capella and deneb + BlobGasUsed *uint64 `json:"blob_gas_used"` // Only deneb + ExcessBlobGas *uint64 `json:"excess_blob_gas"` // Only deneb } type SignedBlsToExecutionChange struct { - Message BlsToExecutionChange - Signature SignatureBytes + Message BlsToExecutionChange `json:"message"` + Signature SignatureBytes `json:"signature"` } type BlsToExecutionChange struct { - ValidatorIndex uint64 - FromBlsPubkey [48]byte + ValidatorIndex uint64 `json:"validator_index"` + FromBlsPubkey BLSPubKey `json:"from_bls_pubkey"` } // BeaconBlockBody represents the body of a beacon block. type BeaconBlockBody struct { - RandaoReveal SignatureBytes - Eth1Data Eth1Data - Graffiti Bytes32 - ProposerSlashings []ProposerSlashing `ssz-max:"16"` - AttesterSlashings []AttesterSlashing `ssz-max:"2"` - Attestations []Attestation `ssz-max:"128"` - Deposits []Deposit `ssz-max:"16"` - VoluntaryExits []SignedVoluntaryExit `ssz-max:"16"` - SyncAggregate SyncAggregate - ExecutionPayload ExecutionPayload - BlsToExecutionChanges []SignedBlsToExecutionChange `ssz-max:"16"` - BlobKzgCommitments [][48]byte `ssz-max:"4096"` + RandaoReveal SignatureBytes `json:"randao_reveal"` + Eth1Data Eth1Data `json:"eth1_data"` + Graffiti Bytes32 `json:"graffiti"` + ProposerSlashings []ProposerSlashing `json:"proposer_slashings"` + AttesterSlashings []AttesterSlashing `json:"attester_slashings"` + Attestations []Attestation `json:"attestations"` + Deposits []Deposit `json:"deposits"` + VoluntaryExits []SignedVoluntaryExit `json:"voluntary_exits"` + SyncAggregate SyncAggregate `json:"sync_aggregate"` + ExecutionPayload ExecutionPayload `json:"execution_payload"` + BlsToExecutionChanges *[]SignedBlsToExecutionChange `json:"bls_to_execution_changes"` //Only capella and deneb + BlobKzgCommitments *[][]byte `json:"blob_kzg_commitments"` // Dynamic slice + Hash []byte } type Header struct { - Slot uint64 - ProposerIndex uint64 - ParentRoot Bytes32 - StateRoot Bytes32 - BodyRoot Bytes32 + Slot uint64 `json:"slot"` + ProposerIndex uint64 `json:"proposer_index"` + ParentRoot Bytes32 `json:"parent_root"` + StateRoot Bytes32 `json:"state_root"` + BodyRoot Bytes32 `json:"body_root"` } type SyncCommittee struct { - Pubkeys [512]BLSPubKey - AggregatePubkey BLSPubKey + Pubkeys []BLSPubKey `json:"pubkeys"` + AggregatePubkey BLSPubKey `json:"aggregate_pubkey"` } type Update struct { - AttestedHeader Header - NextSyncCommittee SyncCommittee - NextSyncCommitteeBranch []Bytes32 - FinalizedHeader Header - FinalityBranch []Bytes32 - SyncAggregate SyncAggregate - SignatureSlot uint64 + AttestedHeader Header `json:"attested_header"` + NextSyncCommittee SyncCommittee `json:"next_sync_committee"` + NextSyncCommitteeBranch []Bytes32 `json:"next_sync_committee_branch"` + FinalizedHeader Header `json:"finalized_header"` + FinalityBranch []Bytes32 `json:"finality_branch"` + SyncAggregate SyncAggregate `json:"sync_aggregate"` + SignatureSlot uint64 `json:"signature_slot"` } type FinalityUpdate struct { - AttestedHeader Header - FinalizedHeader Header - FinalityBranch []Bytes32 - SyncAggregate SyncAggregate - SignatureSlot uint64 + AttestedHeader Header `json:"attested_header"` + FinalizedHeader Header `json:"finalized_header"` + FinalityBranch []Bytes32 `json:"finality_branch"` + SyncAggregate SyncAggregate `json:"sync_aggregate"` + SignatureSlot uint64 `json:"signature_slot"` } type OptimisticUpdate struct { - AttestedHeader Header - SyncAggregate SyncAggregate - SignatureSlot uint64 + AttestedHeader Header `json:"attested_header"` + SyncAggregate SyncAggregate `json:"sync_aggregate"` + SignatureSlot uint64 `json:"signature_slot"` } type Bootstrap struct { - Header Header - CurrentSyncCommittee SyncCommittee - CurrentSyncCommitteeBranch []Bytes32 + Header Header `json:"header"` + CurrentSyncCommittee SyncCommittee `json:"current_sync_committee"` + CurrentSyncCommitteeBranch []Bytes32 `json:"current_sync_committee_branch"` } type Fork struct { Epoch uint64 `json:"epoch"` ForkVersion []byte `json:"fork_version"` } + type Forks struct { Genesis Fork `json:"genesis"` Altair Fork `json:"altair"` @@ -211,26 +207,3 @@ type Forks struct { Capella Fork `json:"capella"` Deneb Fork `json:"deneb"` } - -// ToBytes serializes the Header struct to a byte slice. -func (h *Header) ToBytes() []byte { - var buf bytes.Buffer - enc := codec.NewEncoder(&buf, new(codec.JsonHandle)) - _ = enc.Encode(h) // Ignore error - return buf.Bytes() -} - -func (b *BeaconBlockBody) ToBytes() []byte { - var buf bytes.Buffer - enc := codec.NewEncoder(&buf, new(codec.JsonHandle)) - _ = enc.Encode(b) // Ignore error - return buf.Bytes() -} - -// ToBytes serializes the SyncCommittee struct to a byte slice. -func (sc *SyncCommittee) ToBytes() []byte { - var buf bytes.Buffer - enc := codec.NewEncoder(&buf, new(codec.JsonHandle)) - _ = enc.Encode(sc) // Ignore error - return buf.Bytes() -} diff --git a/consensus/consensus_core/serde_utils.go b/consensus/consensus_core/serde_utils.go new file mode 100644 index 0000000..e13907f --- /dev/null +++ b/consensus/consensus_core/serde_utils.go @@ -0,0 +1,382 @@ +package consensus_core + +import ( + "encoding/hex" + "encoding/json" + "fmt" + "reflect" + "strconv" + "strings" + + "github.com/ethereum/go-ethereum/common" +) + +func (f *FinalityUpdate) UnmarshalJSON(data []byte) error { + return unmarshalJSON(data, f) +} + +func (o *OptimisticUpdate) UnmarshalJSON(data []byte) error { + return unmarshalJSON(data, o) +} + +func (b *Bootstrap) UnmarshalJSON(data []byte) error { + return unmarshalJSON(data, b) +} + +// Unmarshal for Fork +func (f *Fork) UnmarshalJSON(data []byte) error { + var serialized map[string]interface{} + if err := json.Unmarshal(data, &serialized); err != nil { + return fmt.Errorf("error unmarshalling into map: %w", err) + } + + v := reflect.ValueOf(f).Elem() + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + fieldType := t.Field(i) + fieldName := fieldType.Tag.Get("json") + if fieldName == "" { + fieldName = snakeCase(fieldType.Name) + } + + if value, ok := serialized[fieldName]; ok { + switch field.Interface().(type) { + case uint64: + val, err := strconv.ParseUint(value.(string), 10, 64) + if err != nil { + return fmt.Errorf("error parsing %s: %w", fieldName, err) + } + field.Set(reflect.ValueOf(val)) + case []byte: + decoded := hexDecode(value.(string)) + field.Set(reflect.ValueOf(decoded)) + } + } + } + + return nil +} + +func (f *Forks) UnmarshalJSON(data []byte) error { + var serialized map[string]interface{} + if err := json.Unmarshal(data, &serialized); err != nil { + return fmt.Errorf("error unmarshalling into map: %w", err) + } + + v := reflect.ValueOf(f).Elem() + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + fieldType := t.Field(i) + fieldName := fieldType.Tag.Get("json") + if fieldName == "" { + fieldName = snakeCase(fieldType.Name) + } + + if forkData, ok := serialized[fieldName]; ok { + forkJSON, err := json.Marshal(forkData) + if err != nil { + return fmt.Errorf("error marshalling %s: %w", fieldName, err) + } + if err := json.Unmarshal(forkJSON, field.Addr().Interface()); err != nil { + return fmt.Errorf("error unmarshalling %s: %w", fieldName, err) + } + } + } + + return nil +} + +func (h *Header) UnmarshalJSON(data []byte) error { + // Define a temporary map to hold JSON data + var serialized map[string]interface{} + if err := json.Unmarshal(data, &serialized); err != nil { + return fmt.Errorf("error unmarshalling into map: %w", err) + } + + // Extract the "beacon" field from the serialized map + beaconData, ok := serialized["beacon"].(map[string]interface{}) + if !ok { + return fmt.Errorf("beacon field missing or invalid") + } + + v := reflect.ValueOf(h).Elem() + t := v.Type() + + // Iterate through each field of the Header struct using reflection + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + fieldType := t.Field(i) + jsonTag := fieldType.Tag.Get("json") + + // Convert the struct field name or its json tag to snake_case for matching + fieldName := jsonTag + if fieldName == "" { + fieldName = snakeCase(fieldType.Name) + } + + if value, ok := beaconData[fieldName]; ok { + switch field.Interface().(type) { + case uint64: + val, err := Str_to_uint64(value.(string)) + if err != nil { + return fmt.Errorf("error parsing %s: %w", fieldName, err) + } + field.Set(reflect.ValueOf(val)) + case Bytes32: + val, err := Hex_str_to_Bytes32(value.(string)) + if err != nil { + return fmt.Errorf("error parsing %s: %w", fieldName, err) + } + field.Set(reflect.ValueOf(val)) + } + } else { + return fmt.Errorf("field %s not found in JSON data", fieldName) + } + } + + return nil +} + +func (b *Bytes32) UnmarshalJSON(data []byte) error { + var hexString string + if err := json.Unmarshal(data, &hexString); err != nil { + return err + } + + copy(b[:], hexDecode(hexString)[:]) + + return nil +} + +func (s *SyncAggregate) UnmarshalJSON(data []byte) error { + // Define a temporary map to hold JSON data + var serialized map[string]string + if err := json.Unmarshal(data, &serialized); err != nil { + return fmt.Errorf("error unmarshalling into map: %w", err) + } + + v := reflect.ValueOf(s).Elem() + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + fieldName := t.Field(i).Name + snakeFieldName := snakeCase(fieldName) + + switch snakeFieldName { + case "sync_committee_bits": + if bits, ok := serialized[snakeFieldName]; ok { + decodedBits := hexDecode(bits) + if decodedBits == nil { + return fmt.Errorf("error decoding sync_committee_bits") + } + field.SetBytes(decodedBits) + } else { + return fmt.Errorf("%s field missing or invalid", snakeFieldName) + } + case "sync_committee_signature": + if signature, ok := serialized[snakeFieldName]; ok { + decodedSignature := hexDecode(signature) + if decodedSignature == nil { + return fmt.Errorf("error decoding sync_committee_signature") + } + if len(decodedSignature) != len(s.SyncCommitteeSignature) { + return fmt.Errorf("decoded sync_committee_signature length mismatch") + } + copy(s.SyncCommitteeSignature[:], decodedSignature) + } else { + return fmt.Errorf("%s field missing or invalid", snakeFieldName) + } + default: + return fmt.Errorf("unsupported field %s", fieldName) + } + } + + return nil +} + +func (s *SyncCommittee) UnmarshalJSON(data []byte) error { + var serialized map[string]interface{} + if err := json.Unmarshal(data, &serialized); err != nil { + return fmt.Errorf("error unmarshalling into map: %w", err) + } + + v := reflect.ValueOf(s).Elem() + t := v.Type() + + for i := 0; i < v.NumField(); i++ { + fieldName := t.Field(i).Name + snakeFieldName := snakeCase(fieldName) + + switch snakeFieldName { + case "pubkeys": + if pubkeys, ok := serialized[snakeFieldName].([]interface{}); ok { + s.Pubkeys = make([]BLSPubKey, len(pubkeys)) + for j, pubkey := range pubkeys { + if pubkeyStr, ok := pubkey.(string); ok { + decoded := hexDecode(pubkeyStr) + if decoded == nil { + return fmt.Errorf("error decoding pubkey at index %d", j) + } + s.Pubkeys[j] = BLSPubKey(decoded) + } else { + return fmt.Errorf("invalid pubkey format at index %d", j) + } + } + } else { + return fmt.Errorf("%s field missing or invalid", snakeFieldName) + } + case "aggregate_pubkey": + if aggPubkey, ok := serialized[snakeFieldName].(string); ok { + decoded := hexDecode(aggPubkey) + if decoded == nil { + return fmt.Errorf("error decoding aggregate pubkey") + } + s.AggregatePubkey = BLSPubKey(decoded) + } else { + return fmt.Errorf("%s field missing or invalid", snakeFieldName) + } + default: + return fmt.Errorf("unsupported field %s", fieldName) + } + } + + return nil +} + +func (u *Update) UnmarshalJSON(data []byte) error { + return unmarshalJSON(data, u) +} + +func unmarshalJSON(data []byte, v interface{}) error { + var serialized map[string]interface{} + if err := json.Unmarshal(data, &serialized); err != nil { + return fmt.Errorf("error unmarshalling into map: %w", err) + } + + // Get the value of the struct using reflection + value := reflect.ValueOf(v).Elem() + typeOfValue := value.Type() + + for i := 0; i < value.NumField(); i++ { + field := value.Field(i) + fieldType := typeOfValue.Field(i) + jsonTag := fieldType.Tag.Get("json") + + // Convert the struct field name or its json tag to snake_case for matching + fieldName := jsonTag + if fieldName == "" { + fieldName = snakeCase(fieldType.Name) + } + + if rawValue, ok := serialized[fieldName]; ok { + if err := setFieldValue(field, rawValue); err != nil { + return fmt.Errorf("error setting field %s: %w", fieldName, err) + } + } + } + return nil +} + +func setFieldValue(field reflect.Value, value interface{}) error { + switch field.Kind() { + case reflect.Struct: + // Marshal and unmarshal for struct types + rawJSON, err := json.Marshal(value) + if err != nil { + return err + } + return json.Unmarshal(rawJSON, field.Addr().Interface()) + + case reflect.Slice: + if field.Type().Elem().Kind() == reflect.Uint8 { + // For Bytes32 conversion + dataSlice := value.([]interface{}) + for _, b := range dataSlice { + field.Set(reflect.Append(field, reflect.ValueOf(Bytes32(hexDecode(b.(string)))))) // Adjust hexDecode as needed + } + return nil + } + // For other slice types, marshal and unmarshal + rawJSON, err := json.Marshal(value) + if err != nil { + return err + } + return json.Unmarshal(rawJSON, field.Addr().Interface()) + + case reflect.String: + field.SetString(value.(string)) + case reflect.Uint64: + val, err := Str_to_uint64(value.(string)) + if err != nil { + return err + } + field.SetUint(val) + default: + return fmt.Errorf("unsupported field type: %s", field.Type()) + } + return nil +} + +// if we need to export the functions , just make their first letter capitalised +func Hex_str_to_bytes(s string) ([]byte, error) { + s = strings.TrimPrefix(s, "0x") + + bytesArray, err := hex.DecodeString(s) + + if err != nil { + return nil, err + } + + return bytesArray, nil +} + +func Hex_str_to_Bytes32(s string) (Bytes32, error) { + bytesArray, err := Hex_str_to_bytes(s) + if err != nil { + return Bytes32{}, err + } + + var bytes32 Bytes32 + copy(bytes32[:], bytesArray) + return bytes32, nil +} + +func Address_to_hex_string(addr common.Address) string { + bytesArray := addr.Bytes() + return fmt.Sprintf("0x%x", hex.EncodeToString(bytesArray)) +} + +func U64_to_hex_string(val uint64) string { + return fmt.Sprintf("0x%x", val) +} + +func Str_to_uint64(s string) (uint64, error) { + num, err := strconv.ParseUint(s, 10, 64) + if err != nil { + return 0, err + } + return num, nil +} + +// snakeCase converts CamelCase strings to snake_case (e.g., "ParentRoot" to "parent_root"). +func snakeCase(input string) string { + var result []rune + for i, r := range input { + if i > 0 && r >= 'A' && r <= 'Z' { + result = append(result, '_') + } + result = append(result, r) + } + return strings.ToLower(string(result)) +} + +// hexDecode is a utility function to decode hex strings to byte slices. +func hexDecode(input string) []byte { + data, _ := Hex_str_to_bytes(input) + return data +} diff --git a/consensus/rpc/consensus_rpc.go b/consensus/rpc/consensus_rpc.go index 22dc00e..9828eae 100644 --- a/consensus/rpc/consensus_rpc.go +++ b/consensus/rpc/consensus_rpc.go @@ -15,5 +15,9 @@ type ConsensusRpc interface { } func NewConsensusRpc(rpc string) ConsensusRpc { + if rpc == "testdata/" { + return NewMockRpc(rpc) + } return NewNimbusRpc(rpc) + } diff --git a/consensus/rpc/mock_rpc.go b/consensus/rpc/mock_rpc.go index 971f381..29230f2 100644 --- a/consensus/rpc/mock_rpc.go +++ b/consensus/rpc/mock_rpc.go @@ -5,87 +5,93 @@ package rpc import ( "encoding/json" "fmt" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "os" "path/filepath" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" ) type MockRpc struct { testdata string } + func NewMockRpc(path string) *MockRpc { return &MockRpc{ testdata: path, } } -func (m *MockRpc) GetBootstrap(block_root []byte) (*consensus_core.Bootstrap, error) { +func (m *MockRpc) GetBootstrap(block_root [32]byte) (consensus_core.Bootstrap, error) { path := filepath.Join(m.testdata, "bootstrap.json") res, err := os.ReadFile(path) if err != nil { - return nil, fmt.Errorf("failed to read file: %w", err) + return consensus_core.Bootstrap{}, fmt.Errorf("failed to read file: %w", err) } var bootstrap BootstrapResponse err = json.Unmarshal(res, &bootstrap) if err != nil { - return &consensus_core.Bootstrap{}, fmt.Errorf("bootstrap error: %w", err) + return consensus_core.Bootstrap{}, fmt.Errorf("bootstrap error: %w", err) } - return &bootstrap.Data, nil + return bootstrap.Data, nil } func (m *MockRpc) GetUpdates(period uint64, count uint8) ([]consensus_core.Update, error) { path := filepath.Join(m.testdata, "updates.json") res, err := os.ReadFile(path) + if err != nil { return nil, fmt.Errorf("failed to read file: %w", err) } var updatesResponse UpdateResponse + err = json.Unmarshal(res, &updatesResponse) if err != nil { return nil, fmt.Errorf("updates error: %w", err) } - updates := make([]consensus_core.Update, len(updatesResponse)) + + var updates = make([]consensus_core.Update, len(updatesResponse)) for i, update := range updatesResponse { updates[i] = update.Data } + + //fmt.Print("Data", updates) return updates, nil } -func (m *MockRpc) GetFinalityUpdate() (*consensus_core.FinalityUpdate, error) { +func (m *MockRpc) GetFinalityUpdate() (consensus_core.FinalityUpdate, error) { path := filepath.Join(m.testdata, "finality.json") res, err := os.ReadFile(path) if err != nil { - return nil, fmt.Errorf("failed to read file: %w", err) + return consensus_core.FinalityUpdate{}, fmt.Errorf("failed to read file: %w", err) } var finality FinalityUpdateResponse err = json.Unmarshal(res, &finality) if err != nil { - return &consensus_core.FinalityUpdate{}, fmt.Errorf("finality update error: %w", err) + return consensus_core.FinalityUpdate{}, fmt.Errorf("finality update error: %w", err) } - return &finality.Data, nil + return finality.Data, nil } -func (m *MockRpc) GetOptimisticUpdate() (*consensus_core.OptimisticUpdate, error) { +func (m *MockRpc) GetOptimisticUpdate() (consensus_core.OptimisticUpdate, error) { path := filepath.Join(m.testdata, "optimistic.json") res, err := os.ReadFile(path) if err != nil { - return nil, fmt.Errorf("failed to read file: %w", err) + return consensus_core.OptimisticUpdate{}, fmt.Errorf("failed to read file: %w", err) } var optimistic OptimisticUpdateResponse err = json.Unmarshal(res, &optimistic) if err != nil { - return &consensus_core.OptimisticUpdate{}, fmt.Errorf("optimistic update error: %w", err) + return consensus_core.OptimisticUpdate{}, fmt.Errorf("optimistic update error: %w", err) } - return &optimistic.Data, nil + return optimistic.Data, nil } -func (m *MockRpc) GetBlock(slot uint64) (*consensus_core.BeaconBlock, error) { +func (m *MockRpc) GetBlock(slot uint64) (consensus_core.BeaconBlock, error) { path := filepath.Join(m.testdata, fmt.Sprintf("blocks/%d.json", slot)) res, err := os.ReadFile(path) if err != nil { - return nil, fmt.Errorf("failed to read file: %w", err) + return consensus_core.BeaconBlock{}, fmt.Errorf("failed to read file: %w", err) } var block BeaconBlockResponse err = json.Unmarshal(res, &block) if err != nil { - return nil, err + return consensus_core.BeaconBlock{}, err } - return &block.Data.Message, nil + return block.Data.Message, nil } func (m *MockRpc) ChainId() (uint64, error) { return 0, fmt.Errorf("not implemented") diff --git a/consensus/rpc/nimbus_rpc.go b/consensus/rpc/nimbus_rpc.go index 49b66fa..9ee4939 100644 --- a/consensus/rpc/nimbus_rpc.go +++ b/consensus/rpc/nimbus_rpc.go @@ -72,6 +72,7 @@ func (n *NimbusRpc) GetUpdates(period uint64, count uint8) ([]consensus_core.Upd if err != nil { return nil, fmt.Errorf("updates error: %w", err) } + updates := make([]consensus_core.Update, len(res)) for i, update := range res { updates[i] = update.Data @@ -116,7 +117,7 @@ func (n *NimbusRpc) ChainId() (uint64, error) { } // BeaconBlock, Update,FinalityUpdate ,OptimisticUpdate,Bootstrap yet to be defined in consensus-core/src/types/mod.go -// For now defined in consensus/consensus_core.go +// For now defined in consensus/ go type BeaconBlockResponse struct { Data BeaconBlockData } @@ -125,13 +126,14 @@ type BeaconBlockData struct { } type UpdateResponse = []UpdateData type UpdateData struct { - Data consensus_core.Update + Data consensus_core.Update `json:"data"` } + type FinalityUpdateResponse struct { - Data consensus_core.FinalityUpdate + Data consensus_core.FinalityUpdate `json:"data"` } type OptimisticUpdateResponse struct { - Data consensus_core.OptimisticUpdate + Data consensus_core.OptimisticUpdate `json:"data"` } type SpecResponse struct { Data Spec @@ -140,5 +142,5 @@ type Spec struct { ChainId uint64 } type BootstrapResponse struct { - Data consensus_core.Bootstrap + Data consensus_core.Bootstrap `json:"data"` } From 786138351fef8cb7e318ee992263eafd77254293 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Mon, 7 Oct 2024 21:19:34 +0000 Subject: [PATCH 05/13] Fixed linter and build --- go.mod | 41 +++++ go.sum | 560 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 601 insertions(+) diff --git a/go.mod b/go.mod index ce01ecf..7df0ec9 100644 --- a/go.mod +++ b/go.mod @@ -10,24 +10,61 @@ require ( ) require ( + github.com/DataDog/zstd v1.4.5 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect github.com/avast/retry-go v3.0.0+incompatible // indirect + github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cockroachdb/errors v1.11.3 // indirect + github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/pebble v1.1.1 // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/getsentry/sentry-go v0.27.0 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect + github.com/gofrs/flock v0.8.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/kilic/bls12-381 v0.1.0 // indirect + github.com/klauspost/compress v1.17.2 // indirect + github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect + github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.12.0 // indirect + github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/protolambda/bls12-381-util v0.1.0 // indirect + github.com/protolambda/zrnt v0.32.2 // indirect + github.com/protolambda/ztyp v0.2.2 // indirect + github.com/rivo/uniseg v0.2.0 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect @@ -36,6 +73,9 @@ require ( github.com/stretchr/testify v1.9.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/supranational/blst v0.3.11 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/wealdtech/go-merkletree v1.0.0 // indirect go.uber.org/atomic v1.9.0 // indirect @@ -45,6 +85,7 @@ require ( golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.14.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 1de4e33..67f6dbd 100644 --- a/go.sum +++ b/go.sum @@ -1,17 +1,90 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= +github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -19,35 +92,217 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.8 h1:NgOWvXS+lauK+zFukEvi85UmmsS/OkV0N23UZ1VTIig= github.com/ethereum/go-ethereum v1.14.8/go.mod h1:TJhyuDq0JDppAkFXgqjwpdlQApywnu/m10kFPxh8vvs= +github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4= +github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= +github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= +github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/protolambda/bls12-381-util v0.1.0 h1:05DU2wJN7DTU7z28+Q+zejXkIsA/MF8JZQGhtBZZiWk= +github.com/protolambda/bls12-381-util v0.1.0/go.mod h1:cdkysJTRpeFeuUVx/TXGDQNMTiRAalk1vQw3TYTHcE4= +github.com/protolambda/zrnt v0.32.2 h1:KZ48T+3UhsPXNdtE/5QEvGc9DGjUaRI17nJaoznoIaM= +github.com/protolambda/zrnt v0.32.2/go.mod h1:A0fezkp9Tt3GBLATSPIbuY4ywYESyAuc/FFmPKg8Lqs= +github.com/protolambda/ztyp v0.2.2 h1:rVcL3vBu9W/aV646zF6caLS/dyn9BN8NYiuJzicLNyY= +github.com/protolambda/ztyp v0.2.2/go.mod h1:9bYgKGqg3wJqT9ac1gI2hnVb0STQq7p/1lapqrqY1dU= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -59,11 +314,14 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -73,35 +331,337 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/wealdtech/go-merkletree v1.0.0 h1:DsF1xMzj5rK3pSQM6mPv8jlyJyHXhFxpnA2bwEjMMBY= github.com/wealdtech/go-merkletree v1.0.0/go.mod h1:cdil512d/8ZC7Kx3bfrDvGMQXB25NTKbsm0rFrmDax4= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= From 70d4a72aa73d4ad1d3c9003a0b51e05c57815ab2 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 10 Oct 2024 08:19:57 +0000 Subject: [PATCH 06/13] Fixed build error n refactored tests --- consensus/rpc/consensus_rpc.go | 8 +-- consensus/rpc/mock_rpc_test.go | 104 ++++++++++++++++++++++++------- consensus/rpc/nimbus_rpc.go | 12 ++-- consensus/rpc/nimbus_rpc_test.go | 74 +++++++++++++++++----- 4 files changed, 146 insertions(+), 52 deletions(-) diff --git a/consensus/rpc/consensus_rpc.go b/consensus/rpc/consensus_rpc.go index 9828eae..da0ffe8 100644 --- a/consensus/rpc/consensus_rpc.go +++ b/consensus/rpc/consensus_rpc.go @@ -15,9 +15,9 @@ type ConsensusRpc interface { } func NewConsensusRpc(rpc string) ConsensusRpc { - if rpc == "testdata/" { - return NewMockRpc(rpc) + if(rpc == "testdata/"){ + return NewMockRpc(rpc) + }else { + return NewNimbusRpc(rpc) } - return NewNimbusRpc(rpc) - } diff --git a/consensus/rpc/mock_rpc_test.go b/consensus/rpc/mock_rpc_test.go index b371a54..06a9241 100644 --- a/consensus/rpc/mock_rpc_test.go +++ b/consensus/rpc/mock_rpc_test.go @@ -1,66 +1,98 @@ package rpc + import ( "encoding/json" "os" "path/filepath" "testing" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" ) -func TestNewMockRpc(t *testing.T) { - path := "/tmp/testdata" - mockRpc := NewMockRpc(path) - if mockRpc.testdata != path { - t.Errorf("Expected testdata path to be %s, got %s", path, mockRpc.testdata) - } -} + func TestGetBootstrap(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - mockBootstrap := BootstrapResponse{ - Data: consensus_core.Bootstrap{ - Header: consensus_core.Header{ - Slot: 1000, + + mockBootstrap := map[string]interface{}{ + "data": map[string]interface{}{ + "header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "1000", + "proposer_index": "12345", + "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", + "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", + }, }, }, } + bootstrapJSON, _ := json.Marshal(mockBootstrap) err = os.WriteFile(filepath.Join(tempDir, "bootstrap.json"), bootstrapJSON, 0644) if err != nil { t.Fatalf("Failed to write mock bootstrap file: %v", err) } + mockRpc := NewMockRpc(tempDir) - bootstrap, err := mockRpc.GetBootstrap([]byte{}) + bootstrap, err := mockRpc.GetBootstrap([32]byte{}) if err != nil { t.Fatalf("GetBootstrap failed: %v", err) } + if bootstrap.Header.Slot != 1000 { t.Errorf("Expected bootstrap slot to be 1000, got %d", bootstrap.Header.Slot) } } + func TestGetUpdates(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - mockUpdates := UpdateResponse{ - {Data: consensus_core.Update{SignatureSlot: 1}}, - {Data: consensus_core.Update{SignatureSlot: 2}}, + + mockUpdates := []map[string]interface{}{ + { + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "1", + "proposer_index": "12345", + "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", + "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", + }, + }, + "signature_slot": "1", + }, + }, + { + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "2", + }, + }, + "signature_slot": "2", + }, + }, } + updatesJSON, _ := json.Marshal(mockUpdates) err = os.WriteFile(filepath.Join(tempDir, "updates.json"), updatesJSON, 0644) if err != nil { t.Fatalf("Failed to write mock updates file: %v", err) } + mockRpc := NewMockRpc(tempDir) updates, err := mockRpc.GetUpdates(1, 2) if err != nil { t.Fatalf("GetUpdates failed: %v", err) } + if len(updates) != 2 { t.Errorf("Expected 2 updates, got %d", len(updates)) } @@ -68,58 +100,81 @@ func TestGetUpdates(t *testing.T) { t.Errorf("Unexpected update signature slots") } } + func TestGetFinalityUpdate(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - mockFinality := FinalityUpdateResponse{ - Data: consensus_core.FinalityUpdate{ - FinalizedHeader: consensus_core.Header{ - Slot: 2000, + + mockFinality := map[string]interface{}{ + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "1000", + }, + }, + "finalized_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "2000", + }, }, }, } + finalityJSON, _ := json.Marshal(mockFinality) err = os.WriteFile(filepath.Join(tempDir, "finality.json"), finalityJSON, 0644) if err != nil { t.Fatalf("Failed to write mock finality file: %v", err) } + mockRpc := NewMockRpc(tempDir) finality, err := mockRpc.GetFinalityUpdate() if err != nil { t.Fatalf("GetFinalityUpdate failed: %v", err) } + if finality.FinalizedHeader.Slot != 2000 { t.Errorf("Expected finality slot to be 2000, got %d", finality.FinalizedHeader.Slot) } } + func TestGetOptimisticUpdate(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - mockOptimistic := OptimisticUpdateResponse{ - Data: consensus_core.OptimisticUpdate{ - SignatureSlot: 3000, + + mockOptimistic := map[string]interface{}{ + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "3000", + }, + }, + "signature_slot": "3000", }, } + optimisticJSON, _ := json.Marshal(mockOptimistic) err = os.WriteFile(filepath.Join(tempDir, "optimistic.json"), optimisticJSON, 0644) if err != nil { t.Fatalf("Failed to write mock optimistic file: %v", err) } + mockRpc := NewMockRpc(tempDir) optimistic, err := mockRpc.GetOptimisticUpdate() if err != nil { t.Fatalf("GetOptimisticUpdate failed: %v", err) } + if optimistic.SignatureSlot != 3000 { t.Errorf("Expected optimistic signature slot to be 3000, got %d", optimistic.SignatureSlot) } } + func TestGetBlock(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { @@ -154,10 +209,11 @@ func TestGetBlock(t *testing.T) { t.Errorf("Expected block slot to be 4000, got %d", block.Slot) } } + func TestChainId(t *testing.T) { mockRpc := NewMockRpc("/tmp/testdata") _, err := mockRpc.ChainId() if err == nil || err.Error() != "not implemented" { t.Errorf("Expected 'not implemented' error, got %v", err) } -} +} \ No newline at end of file diff --git a/consensus/rpc/nimbus_rpc.go b/consensus/rpc/nimbus_rpc.go index 9ee4939..49b66fa 100644 --- a/consensus/rpc/nimbus_rpc.go +++ b/consensus/rpc/nimbus_rpc.go @@ -72,7 +72,6 @@ func (n *NimbusRpc) GetUpdates(period uint64, count uint8) ([]consensus_core.Upd if err != nil { return nil, fmt.Errorf("updates error: %w", err) } - updates := make([]consensus_core.Update, len(res)) for i, update := range res { updates[i] = update.Data @@ -117,7 +116,7 @@ func (n *NimbusRpc) ChainId() (uint64, error) { } // BeaconBlock, Update,FinalityUpdate ,OptimisticUpdate,Bootstrap yet to be defined in consensus-core/src/types/mod.go -// For now defined in consensus/ go +// For now defined in consensus/consensus_core.go type BeaconBlockResponse struct { Data BeaconBlockData } @@ -126,14 +125,13 @@ type BeaconBlockData struct { } type UpdateResponse = []UpdateData type UpdateData struct { - Data consensus_core.Update `json:"data"` + Data consensus_core.Update } - type FinalityUpdateResponse struct { - Data consensus_core.FinalityUpdate `json:"data"` + Data consensus_core.FinalityUpdate } type OptimisticUpdateResponse struct { - Data consensus_core.OptimisticUpdate `json:"data"` + Data consensus_core.OptimisticUpdate } type SpecResponse struct { Data Spec @@ -142,5 +140,5 @@ type Spec struct { ChainId uint64 } type BootstrapResponse struct { - Data consensus_core.Bootstrap `json:"data"` + Data consensus_core.Bootstrap } diff --git a/consensus/rpc/nimbus_rpc_test.go b/consensus/rpc/nimbus_rpc_test.go index 3e00074..5f82ea9 100644 --- a/consensus/rpc/nimbus_rpc_test.go +++ b/consensus/rpc/nimbus_rpc_test.go @@ -19,10 +19,16 @@ func TestNimbusGetBootstrap(t *testing.T) { expectedPath := fmt.Sprintf("/eth/v1/beacon/light_client/bootstrap/0x%x", blockRoot) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, expectedPath, r.URL.Path) - response := BootstrapResponse{ - Data: consensus_core.Bootstrap{ - Header: consensus_core.Header{ - Slot: 1000, + response := map[string]interface{}{ + "data": map[string]interface{}{ + "header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "1000", + "proposer_index": "12345", + "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", + "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", + }, }, }, } @@ -39,9 +45,31 @@ func TestNimbusGetUpdates(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/updates", r.URL.Path) assert.Equal(t, "start_period=1000&count=5", r.URL.RawQuery) - response := UpdateResponse{ - {Data: consensus_core.Update{AttestedHeader: consensus_core.Header{Slot: 1000}}}, - {Data: consensus_core.Update{AttestedHeader: consensus_core.Header{Slot: 1001}}}, + response := []map[string]interface{}{ + { + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "1", + "proposer_index": "12345", + "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", + "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", + }, + }, + "signature_slot": "1", + }, + }, + { + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "2", + }, + }, + "signature_slot": "2", + }, + }, } err := json.NewEncoder(w).Encode(response) require.NoError(t, err) @@ -51,16 +79,23 @@ func TestNimbusGetUpdates(t *testing.T) { updates, err := nimbusRpc.GetUpdates(1000, 5) assert.NoError(t, err) assert.Len(t, updates, 2) - assert.Equal(t, uint64(1000), updates[0].AttestedHeader.Slot) - assert.Equal(t, uint64(1001), updates[1].AttestedHeader.Slot) + assert.Equal(t, uint64(1), updates[0].AttestedHeader.Slot) + assert.Equal(t, uint64(2), updates[1].AttestedHeader.Slot) } func TestNimbusGetFinalityUpdate(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/finality_update", r.URL.Path) - response := FinalityUpdateResponse{ - Data: consensus_core.FinalityUpdate{ - FinalizedHeader: consensus_core.Header{ - Slot: 2000, + response := map[string]interface{}{ + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "2000", + }, + }, + "finalized_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "2000", + }, }, }, } @@ -76,9 +111,14 @@ func TestNimbusGetFinalityUpdate(t *testing.T) { func TestNimbusGetOptimisticUpdate(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/optimistic_update", r.URL.Path) - response := OptimisticUpdateResponse{ - Data: consensus_core.OptimisticUpdate{ - SignatureSlot: 3000, + response := map[string]interface{}{ + "data": map[string]interface{}{ + "attested_header": map[string]interface{}{ + "beacon": map[string]interface{}{ + "slot": "3000", + }, + }, + "signature_slot": "3000", }, } err := json.NewEncoder(w).Encode(response) @@ -125,4 +165,4 @@ func TestNimbusChainId(t *testing.T) { chainId, err := nimbusRpc.ChainId() assert.NoError(t, err) assert.Equal(t, uint64(5000), chainId) -} \ No newline at end of file +} \ No newline at end of file From ccb63d986bbb48f67529d25a9befaaf66261816c Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 10 Oct 2024 08:59:07 +0000 Subject: [PATCH 07/13] Fixed linter and build --- consensus/consensus.go | 41 ++++++++++++-------- consensus/consensus_core/serde_utils.go | 50 ++++++++++++++++++------- 2 files changed, 62 insertions(+), 29 deletions(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index c56470e..410d665 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -685,8 +685,10 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo forkVersion := utils.CalculateForkVersion(&forks, update.SignatureSlot) forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(in.Config.Chain.GenesisRoot)) - if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { - return ErrInvalidSignature + + + if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { + return ErrInvalidSignature } return nil @@ -889,45 +891,52 @@ func verifySyncCommitteeSignature( signature *consensus_core.SyncAggregate, // Signature bytes forkDataRoot consensus_core.Bytes32, // Fork data root ) bool { - // Collect public keys as references (or suitable Go struct) - if len(pks) == 0 { - fmt.Println("no public keys") - return false - } if signature == nil { fmt.Println("no signature") return false } - collectedPks := make([]*bls.Pubkey, len(pks)) + // Create a slice to hold the collected public keys. + collectedPks := make([]*bls.Pubkey, 0, len(pks)) for i := range pks { - var pksinBytes [48]byte - copy(pksinBytes[:], pks[i][:]) // Copy the bytes safely - var dkey bls.Pubkey + var pksinBytes [48]byte = [48]byte(pks[i]) + dkey := new(bls.Pubkey) err := dkey.Deserialize(&pksinBytes) if err != nil { + fmt.Println("error deserializing public key:", err) return false } - collectedPks[i] = &dkey + + // Include the public key only if the corresponding SyncCommitteeBits bit is set. + if signature.SyncCommitteeBits[i/8]&(byte(1)<<(i%8)) != 0 { + collectedPks = append(collectedPks, dkey) + } } - // Compute signingRoot + // Compute signingRoot. signingRoot := ComputeCommitteeSignRoot(toGethHeader(attestedHeader), forkDataRoot) var sig bls.Signature - signatureForUnmarshalling := [96]byte{} - copy(signatureForUnmarshalling[:], signature.SyncCommitteeSignature[:]) + signatureForUnmarshalling := [96]byte(signature.SyncCommitteeSignature) + // Deserialize the signature. if err := sig.Deserialize(&signatureForUnmarshalling); err != nil { + fmt.Println("error deserializing signature:", err) + return false + } + + // Check if we have collected any public keys before proceeding. + if len(collectedPks) == 0 { + fmt.Println("no valid public keys collected") return false } err := bls.FastAggregateVerify(collectedPks, signingRoot[:], &sig) if err { + fmt.Println("signature verification failed") return false } - return true } diff --git a/consensus/consensus_core/serde_utils.go b/consensus/consensus_core/serde_utils.go index e13907f..7317ca3 100644 --- a/consensus/consensus_core/serde_utils.go +++ b/consensus/consensus_core/serde_utils.go @@ -123,34 +123,24 @@ func (h *Header) UnmarshalJSON(data []byte) error { case uint64: val, err := Str_to_uint64(value.(string)) if err != nil { - return fmt.Errorf("error parsing %s: %w", fieldName, err) + continue } field.Set(reflect.ValueOf(val)) case Bytes32: val, err := Hex_str_to_Bytes32(value.(string)) if err != nil { - return fmt.Errorf("error parsing %s: %w", fieldName, err) + continue } field.Set(reflect.ValueOf(val)) } } else { - return fmt.Errorf("field %s not found in JSON data", fieldName) + continue } } return nil } -func (b *Bytes32) UnmarshalJSON(data []byte) error { - var hexString string - if err := json.Unmarshal(data, &hexString); err != nil { - return err - } - - copy(b[:], hexDecode(hexString)[:]) - - return nil -} func (s *SyncAggregate) UnmarshalJSON(data []byte) error { // Define a temporary map to hold JSON data @@ -282,6 +272,29 @@ func unmarshalJSON(data []byte, v interface{}) error { return nil } +func (b *BeaconBlock) UnmarshalJSON(data []byte) error { + // Define a temporary structure to handle both string and number slots. + var tmp struct { + Slot json.RawMessage `json:"slot"` + } + + // Unmarshal into the temporary struct. + if err := json.Unmarshal(data, &tmp); err != nil { + return fmt.Errorf("error unmarshalling into temporary struct: %w", err) + } + + + + // If it wasn't a string, try unmarshalling as a number. + var slotNum uint64 + if err := json.Unmarshal(tmp.Slot, &slotNum); err == nil { + b.Slot = slotNum + return nil + } + + return fmt.Errorf("slot field is not a valid string or number") +} + func setFieldValue(field reflect.Value, value interface{}) error { switch field.Kind() { case reflect.Struct: @@ -380,3 +393,14 @@ func hexDecode(input string) []byte { data, _ := Hex_str_to_bytes(input) return data } + +func (b *Bytes32) UnmarshalJSON(data []byte) error { + var hexString string + if err := json.Unmarshal(data, &hexString); err != nil { + return err + } + + copy(b[:], hexDecode(hexString)[:]) + + return nil +} From 35e317468c35ea29e0d662a9716091c9250675f8 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 10 Oct 2024 09:18:40 +0000 Subject: [PATCH 08/13] Fixed error code 1 --- consensus/rpc/nimbus_rpc_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/consensus/rpc/nimbus_rpc_test.go b/consensus/rpc/nimbus_rpc_test.go index 5f82ea9..ed6c73d 100644 --- a/consensus/rpc/nimbus_rpc_test.go +++ b/consensus/rpc/nimbus_rpc_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) + func TestNewNimbusRpc(t *testing.T) { rpcURL := "http://example.com" nimbusRpc := NewNimbusRpc(rpcURL) @@ -42,6 +43,11 @@ func TestNimbusGetBootstrap(t *testing.T) { assert.Equal(t, uint64(1000), bootstrap.Header.Slot) } func TestNimbusGetUpdates(t *testing.T) { + defer func() { + if r := recover(); r != nil { + t.Errorf("Test panicked: %v", r) + } + }() server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/updates", r.URL.Path) assert.Equal(t, "start_period=1000&count=5", r.URL.RawQuery) From 256b4a4c7fcc502a2d6eeeb22564c21506b2a4ab Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:25:47 +0000 Subject: [PATCH 09/13] all tests working --- common/errors.go | 3 +- config/base_test.go | 41 ++- config/checkpoints/checkpoints.go | 165 +++++---- config/checkpoints/checkpoints_test.go | 6 +- config/cli.go | 84 ++--- config/cli_test.go | 113 +++--- config/config.toml | 9 + config/config_test.go | 470 ++++++++++++------------ config/networks_test.go | 76 ++-- config/types_test.go | 2 +- consensus/consensus.go | 6 +- consensus/consensus_core/serde_utils.go | 78 ++-- consensus/database.go | 5 + consensus/rpc/consensus_rpc.go | 6 +- consensus/rpc/consensus_rpc_test.go | 9 +- consensus/rpc/mock_rpc.go | 2 +- consensus/rpc/mock_rpc_test.go | 13 +- consensus/rpc/nimbus_rpc_test.go | 17 +- consensus/types/beacon.go | 4 - execution/state.go | 7 +- execution/types.go | 60 +-- utils/bls/bls.go | 4 +- 22 files changed, 582 insertions(+), 598 deletions(-) create mode 100644 config/config.toml diff --git a/common/errors.go b/common/errors.go index d9b2898..d773ee3 100644 --- a/common/errors.go +++ b/common/errors.go @@ -14,9 +14,8 @@ func (e BlockNotFoundError) Error() string { return fmt.Sprintf("block not available: %s", e.Block) } - // need to confirm how such primitive types will be imported -type hash [32]byte; +type hash [32]byte type SlotNotFoundError struct { slot hash diff --git a/config/base_test.go b/config/base_test.go index 1ded12b..6401a76 100644 --- a/config/base_test.go +++ b/config/base_test.go @@ -1,20 +1,21 @@ -package config - -import ( - "testing" -) -func TestCorrectDefaultBaseConfig(t *testing.T) { - baseConfig := BaseConfig{} - - baseConfig = baseConfig.Default() - - if baseConfig.RpcBindIp != "127.0.0.1" { - t.Errorf("Expected RpcBindIP to be %s, but got %s", "127.0.0.1", baseConfig.RpcBindIp) - } - if baseConfig.RpcPort != 0 { - t.Errorf("Expected RpcPort to be %v, but got %v", 0, baseConfig.RpcPort) - } - if baseConfig.ConsensusRpc != nil { - t.Errorf("Expected ConsensusRpc to be %v, but got %v", nil, baseConfig.ConsensusRpc) - } -} \ No newline at end of file +package config + +import ( + "testing" +) + +func TestCorrectDefaultBaseConfig(t *testing.T) { + baseConfig := BaseConfig{} + + baseConfig = baseConfig.Default() + + if baseConfig.RpcBindIp != "127.0.0.1" { + t.Errorf("Expected RpcBindIP to be %s, but got %s", "127.0.0.1", baseConfig.RpcBindIp) + } + if baseConfig.RpcPort != 0 { + t.Errorf("Expected RpcPort to be %v, but got %v", 0, baseConfig.RpcPort) + } + if baseConfig.ConsensusRpc != nil { + t.Errorf("Expected ConsensusRpc to be %v, but got %v", nil, baseConfig.ConsensusRpc) + } +} diff --git a/config/checkpoints/checkpoints.go b/config/checkpoints/checkpoints.go index 6ac2003..4394fdc 100644 --- a/config/checkpoints/checkpoints.go +++ b/config/checkpoints/checkpoints.go @@ -1,19 +1,19 @@ package checkpoints import ( + "context" "encoding/json" "fmt" + "github.com/BlocSoc-iitr/selene/config" + "github.com/avast/retry-go" + "gopkg.in/yaml.v2" "io" + "log" "net/http" "strconv" "strings" "sync" - "context" "time" - "log" - "github.com/BlocSoc-iitr/selene/config" - "github.com/avast/retry-go" - "gopkg.in/yaml.v2" ) // / The location where the list of checkpoint services are stored. @@ -186,10 +186,10 @@ func (ch CheckpointFallback) Build() (CheckpointFallback, error) { return ch, fmt.Errorf("expected a map for service in network %s", network) } - endpoint, _ := serviceMap["endpoint"].(string) // Handle potential nil - name, _ := serviceMap["name"].(string) // Handle potential nil - state, _ := serviceMap["state"].(bool) // Handle potential nil - verification, _ := serviceMap["verification"].(bool) // Handle potential nil + endpoint, _ := serviceMap["endpoint"].(string) // Handle potential nil + name, _ := serviceMap["name"].(string) // Handle potential nil + state, _ := serviceMap["state"].(bool) // Handle potential nil + verification, _ := serviceMap["verification"].(bool) // Handle potential nil // Check contacts and notes var contacts *yaml.MapSlice @@ -206,17 +206,17 @@ func (ch CheckpointFallback) Build() (CheckpointFallback, error) { if !ok { return ch, fmt.Errorf("expected a map for health in service %s", name) } - healthResult, _ := healthRaw["result"].(bool) // Handle potential nil - healthDate, _ := healthRaw["date"].(string) // Handle potential nil + healthResult, _ := healthRaw["result"].(bool) // Handle potential nil + healthDate, _ := healthRaw["date"].(string) // Handle potential nil ch.Services[network] = append(ch.Services[network], CheckpointFallbackService{ - Endpoint: endpoint, - Name: name, - State: state, - Verification: verification, - Contacts: contacts, - Notes: notes, - Health_from_fallback: &Health{ + Endpoint: endpoint, + Name: name, + State: state, + Verification: verification, + Contacts: contacts, + Notes: notes, + Health_from_fallback: &Health{ Result: healthResult, Date: healthDate, }, @@ -227,7 +227,6 @@ func (ch CheckpointFallback) Build() (CheckpointFallback, error) { return ch, nil } - // fetch the latest checkpoint from the given network func (ch CheckpointFallback) FetchLatestCheckpoint(network config.Network) byte256 { services := ch.GetHealthyFallbackServices(network) @@ -258,73 +257,73 @@ func (ch CheckpointFallback) QueryService(endpoint string) (*RawSlotResponse, er // fetch the latest checkpoint from the given services func (ch CheckpointFallback) FetchLatestCheckpointFromServices(services []CheckpointFallbackService) (byte256, error) { - var ( - slots []Slot - wg sync.WaitGroup - slotChan = make(chan Slot, len(services)) // Buffered channel - errorsChan = make(chan error, len(services)) - ) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - - for _, service := range services { - wg.Add(1) - go func(service CheckpointFallbackService) { - defer wg.Done() - raw, err := ch.QueryService(service.Endpoint) - if err != nil { - errorsChan <- fmt.Errorf("failed to fetch checkpoint from service %s: %w", service.Endpoint, err) - return - } - if len(raw.Data.Slots) > 0 { - slotChan <- raw.Data.Slots[0] // Send the first valid slot - } - }(service) - } - - go func() { - wg.Wait() - close(slotChan) - close(errorsChan) - }() - - for { - select { - case slot, ok := <-slotChan: - if !ok { - // Channel closed, all slots processed - if len(slots) == 0 { - return byte256{}, fmt.Errorf("failed to find max epoch from checkpoint slots") - } - return processSlots(slots) - } - slots = append(slots, slot) - case err := <-errorsChan: - if err != nil { - log.Printf("Error fetching checkpoint: %v", err) // Log only if the error is not nil. - } - case <-ctx.Done(): - if len(slots) == 0 { - return byte256{}, ctx.Err() - } - return processSlots(slots) - } - } + var ( + slots []Slot + wg sync.WaitGroup + slotChan = make(chan Slot, len(services)) // Buffered channel + errorsChan = make(chan error, len(services)) + ) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + for _, service := range services { + wg.Add(1) + go func(service CheckpointFallbackService) { + defer wg.Done() + raw, err := ch.QueryService(service.Endpoint) + if err != nil { + errorsChan <- fmt.Errorf("failed to fetch checkpoint from service %s: %w", service.Endpoint, err) + return + } + if len(raw.Data.Slots) > 0 { + slotChan <- raw.Data.Slots[0] // Send the first valid slot + } + }(service) + } + + go func() { + wg.Wait() + close(slotChan) + close(errorsChan) + }() + + for { + select { + case slot, ok := <-slotChan: + if !ok { + // Channel closed, all slots processed + if len(slots) == 0 { + return byte256{}, fmt.Errorf("failed to find max epoch from checkpoint slots") + } + return processSlots(slots) + } + slots = append(slots, slot) + case err := <-errorsChan: + if err != nil { + log.Printf("Error fetching checkpoint: %v", err) // Log only if the error is not nil. + } + case <-ctx.Done(): + if len(slots) == 0 { + return byte256{}, ctx.Err() + } + return processSlots(slots) + } + } } func processSlots(slots []Slot) (byte256, error) { - maxEpochSlot := slots[0] - for _, slot := range slots { - if slot.Epoch > maxEpochSlot.Epoch { - maxEpochSlot = slot - } - } - - if maxEpochSlot.Block_root == nil { - return byte256{}, fmt.Errorf("no valid block root found") - } - - return *maxEpochSlot.Block_root, nil + maxEpochSlot := slots[0] + for _, slot := range slots { + if slot.Epoch > maxEpochSlot.Epoch { + maxEpochSlot = slot + } + } + + if maxEpochSlot.Block_root == nil { + return byte256{}, fmt.Errorf("no valid block root found") + } + + return *maxEpochSlot.Block_root, nil } func (ch CheckpointFallback) FetchLatestCheckpointFromApi(url string) (byte256, error) { diff --git a/config/checkpoints/checkpoints_test.go b/config/checkpoints/checkpoints_test.go index 4a119cf..1038b68 100644 --- a/config/checkpoints/checkpoints_test.go +++ b/config/checkpoints/checkpoints_test.go @@ -3,11 +3,11 @@ package checkpoints import ( "bytes" "encoding/json" + "github.com/BlocSoc-iitr/selene/config" + "io" "net/http" "net/http/httptest" "testing" - "io" - "github.com/BlocSoc-iitr/selene/config" ) type CustomTransport struct { @@ -289,7 +289,6 @@ func TestGetHealthyFallbackServices(t *testing.T) { } } - func equalNetworks(a, b []config.Network) bool { if len(a) != len(b) { return false @@ -317,4 +316,3 @@ func equalStringSlices(a, b []string) bool { } return true } - diff --git a/config/cli.go b/config/cli.go index d0be553..10bdef2 100644 --- a/config/cli.go +++ b/config/cli.go @@ -1,50 +1,52 @@ package config import ( - "encoding/hex" + "encoding/hex" ) + // The format of configuration to be stored in the configuratin file is map[string]interface{} type CliConfig struct { - ExecutionRpc *string `mapstructure:"execution_rpc"` - ConsensusRpc *string `mapstructure:"consensus_rpc"` - Checkpoint *[]byte `mapstructure:"checkpoint"` - RpcBindIp *string `mapstructure:"rpc_bind_ip"` - RpcPort *uint16 `mapstructure:"rpc_port"` - DataDir *string `mapstructure:"data_dir"` - Fallback *string `mapstructure:"fallback"` - LoadExternalFallback *bool `mapstructure:"load_external_fallback"` - StrictCheckpointAge *bool `mapstructure:"strict_checkpoint_age"` + ExecutionRpc *string `mapstructure:"execution_rpc"` + ConsensusRpc *string `mapstructure:"consensus_rpc"` + Checkpoint *[]byte `mapstructure:"checkpoint"` + RpcBindIp *string `mapstructure:"rpc_bind_ip"` + RpcPort *uint16 `mapstructure:"rpc_port"` + DataDir *string `mapstructure:"data_dir"` + Fallback *string `mapstructure:"fallback"` + LoadExternalFallback *bool `mapstructure:"load_external_fallback"` + StrictCheckpointAge *bool `mapstructure:"strict_checkpoint_age"` } + func (cfg *CliConfig) as_provider() map[string]interface{} { - // Create a map to hold the configuration data - userDict := make(map[string]interface{}) - // Populate the map with values from the CliConfig struct - if cfg.ExecutionRpc != nil { - userDict["execution_rpc"] = *cfg.ExecutionRpc - } - if cfg.ConsensusRpc != nil { - userDict["consensus_rpc"] = *cfg.ConsensusRpc - } - if cfg.Checkpoint != nil { - userDict["checkpoint"] = hex.EncodeToString(*cfg.Checkpoint) - } - if cfg.RpcBindIp != nil { - userDict["rpc_bind_ip"] = *cfg.RpcBindIp - } - if cfg.RpcPort != nil { - userDict["rpc_port"] = *cfg.RpcPort - } - if cfg.DataDir != nil { - userDict["data_dir"] = *cfg.DataDir - } - if cfg.Fallback != nil { - userDict["fallback"] = *cfg.Fallback - } - if cfg.LoadExternalFallback != nil { - userDict["load_external_fallback"] = *cfg.LoadExternalFallback - } - if cfg.StrictCheckpointAge != nil { - userDict["strict_checkpoint_age"] = *cfg.StrictCheckpointAge - } - return userDict + // Create a map to hold the configuration data + userDict := make(map[string]interface{}) + // Populate the map with values from the CliConfig struct + if cfg.ExecutionRpc != nil { + userDict["execution_rpc"] = *cfg.ExecutionRpc + } + if cfg.ConsensusRpc != nil { + userDict["consensus_rpc"] = *cfg.ConsensusRpc + } + if cfg.Checkpoint != nil { + userDict["checkpoint"] = hex.EncodeToString(*cfg.Checkpoint) + } + if cfg.RpcBindIp != nil { + userDict["rpc_bind_ip"] = *cfg.RpcBindIp + } + if cfg.RpcPort != nil { + userDict["rpc_port"] = *cfg.RpcPort + } + if cfg.DataDir != nil { + userDict["data_dir"] = *cfg.DataDir + } + if cfg.Fallback != nil { + userDict["fallback"] = *cfg.Fallback + } + if cfg.LoadExternalFallback != nil { + userDict["load_external_fallback"] = *cfg.LoadExternalFallback + } + if cfg.StrictCheckpointAge != nil { + userDict["strict_checkpoint_age"] = *cfg.StrictCheckpointAge + } + return userDict } diff --git a/config/cli_test.go b/config/cli_test.go index ad6391f..f17bf08 100644 --- a/config/cli_test.go +++ b/config/cli_test.go @@ -1,66 +1,67 @@ package config import ( - "encoding/hex" - "testing" + "encoding/hex" + "testing" - "github.com/spf13/viper" + "github.com/spf13/viper" ) + // for the test I have used viper, but ant other configuration library can be used. Just the format of the configuration should be the same i.e. map[string]interface{} func TestCliConfigAsProvider(t *testing.T) { // used some random values for the test - executionRpc := "http://localhost:8545" - consensusRpc := "http://localhost:5052" - checkpoint := []byte{0x01, 0x02, 0x03} - rpcBindIp := "127.0.0.1" - rpcPort := uint16(8080) - dataDir := "/data" - fallback := "http://fallback.example.com" - loadExternalFallback := true - strictCheckpointAge := false + executionRpc := "http://localhost:8545" + consensusRpc := "http://localhost:5052" + checkpoint := []byte{0x01, 0x02, 0x03} + rpcBindIp := "127.0.0.1" + rpcPort := uint16(8080) + dataDir := "/data" + fallback := "http://fallback.example.com" + loadExternalFallback := true + strictCheckpointAge := false - config := CliConfig{ - ExecutionRpc: &executionRpc, - ConsensusRpc: &consensusRpc, - Checkpoint: &checkpoint, - RpcBindIp: &rpcBindIp, - RpcPort: &rpcPort, - DataDir: &dataDir, - Fallback: &fallback, - LoadExternalFallback: &loadExternalFallback, - StrictCheckpointAge: &strictCheckpointAge, - } - v := viper.New() - configMap := config.as_provider() - for key, value := range configMap { - v.Set(key, value) - } - // Assertions to check that Viper has the correct values - if v.GetString("execution_rpc") != executionRpc { - t.Errorf("Expected execution_rpc to be %s, but got %s", executionRpc, v.GetString("execution_rpc")) - } - if v.GetString("consensus_rpc") != consensusRpc { - t.Errorf("Expected consensus_rpc to be %s, but got %s", consensusRpc, v.GetString("consensus_rpc")) - } - if v.GetString("checkpoint") != hex.EncodeToString(checkpoint) { - t.Errorf("Expected checkpoint to be %s, but got %s", hex.EncodeToString(checkpoint), v.GetString("checkpoint")) - } - if v.GetString("rpc_bind_ip") != rpcBindIp { - t.Errorf("Expected rpc_bind_ip to be %s, but got %s", rpcBindIp, v.GetString("rpc_bind_ip")) - } - if v.GetUint16("rpc_port") != rpcPort { - t.Errorf("Expected rpc_port to be %d, but got %d", rpcPort, v.GetUint16("rpc_port")) - } - if v.GetString("data_dir") != dataDir { - t.Errorf("Expected data_dir to be %s, but got %s", dataDir, v.GetString("data_dir")) - } - if v.GetString("fallback") != fallback { - t.Errorf("Expected fallback to be %s, but got %s", fallback, v.GetString("fallback")) - } - if v.GetBool("load_external_fallback") != loadExternalFallback { - t.Errorf("Expected load_external_fallback to be %v, but got %v", loadExternalFallback, v.GetBool("load_external_fallback")) - } - if v.GetBool("strict_checkpoint_age") != strictCheckpointAge { - t.Errorf("Expected strict_checkpoint_age to be %v, but got %v", strictCheckpointAge, v.GetBool("strict_checkpoint_age")) - } + config := CliConfig{ + ExecutionRpc: &executionRpc, + ConsensusRpc: &consensusRpc, + Checkpoint: &checkpoint, + RpcBindIp: &rpcBindIp, + RpcPort: &rpcPort, + DataDir: &dataDir, + Fallback: &fallback, + LoadExternalFallback: &loadExternalFallback, + StrictCheckpointAge: &strictCheckpointAge, + } + v := viper.New() + configMap := config.as_provider() + for key, value := range configMap { + v.Set(key, value) + } + // Assertions to check that Viper has the correct values + if v.GetString("execution_rpc") != executionRpc { + t.Errorf("Expected execution_rpc to be %s, but got %s", executionRpc, v.GetString("execution_rpc")) + } + if v.GetString("consensus_rpc") != consensusRpc { + t.Errorf("Expected consensus_rpc to be %s, but got %s", consensusRpc, v.GetString("consensus_rpc")) + } + if v.GetString("checkpoint") != hex.EncodeToString(checkpoint) { + t.Errorf("Expected checkpoint to be %s, but got %s", hex.EncodeToString(checkpoint), v.GetString("checkpoint")) + } + if v.GetString("rpc_bind_ip") != rpcBindIp { + t.Errorf("Expected rpc_bind_ip to be %s, but got %s", rpcBindIp, v.GetString("rpc_bind_ip")) + } + if v.GetUint16("rpc_port") != rpcPort { + t.Errorf("Expected rpc_port to be %d, but got %d", rpcPort, v.GetUint16("rpc_port")) + } + if v.GetString("data_dir") != dataDir { + t.Errorf("Expected data_dir to be %s, but got %s", dataDir, v.GetString("data_dir")) + } + if v.GetString("fallback") != fallback { + t.Errorf("Expected fallback to be %s, but got %s", fallback, v.GetString("fallback")) + } + if v.GetBool("load_external_fallback") != loadExternalFallback { + t.Errorf("Expected load_external_fallback to be %v, but got %v", loadExternalFallback, v.GetBool("load_external_fallback")) + } + if v.GetBool("strict_checkpoint_age") != strictCheckpointAge { + t.Errorf("Expected strict_checkpoint_age to be %v, but got %v", strictCheckpointAge, v.GetBool("strict_checkpoint_age")) + } } diff --git a/config/config.toml b/config/config.toml new file mode 100644 index 0000000..f1662a2 --- /dev/null +++ b/config/config.toml @@ -0,0 +1,9 @@ +checkpoint = '0x85e6151a246e8fdba36db27a0c7678a575346272fe978c9281e13a8b26cdfa68' +consensus_rpc = 'http://localhost:5052' +data_dir = '/data' +execution_rpc = 'http://localhost:8545' +fallback = 'http://fallback.example.com' +load_external_fallback = true +max_checkpoint_age = 86400 +rpc_bind_ip = '127.0.0.1' +rpc_port = 8080 diff --git a/config/config_test.go b/config/config_test.go index c34095c..858c470 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,235 +1,235 @@ -package config - -import ( - "encoding/hex" - "fmt" - "os" - "reflect" - "testing" - - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - "github.com/spf13/viper" -) - -var ( - executionRpc = "http://localhost:8545" - consensusRpc = "http://localhost:5052" - checkpoint = "0x85e6151a246e8fdba36db27a0c7678a575346272fe978c9281e13a8b26cdfa68" - rpcBindIp = "127.0.0.1" - rpcPort = uint16(8080) - dataDirectory = "/data" - fallback = "http://fallback.example.com" - loadExternalFallback = true - maxCheckpointAge = 86400 - strictCheckpointAge = false - defaultCheckpoint = [32]byte{} -) - -// /////////////////////////// -// /// from_file() tests ///// -// /////////////////////////// -func TestMainnetBaseConfig(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("execution_rpc", executionRpc) - createConfigFile(v) - var cliConfig CliConfig - var config Config - - config = config.from_file(&path, &network, &cliConfig) - - mainnetConfig, _ := Mainnet() - - // config should have BaseConfig values for MAINNET as cliConfig and TomlConfig are uninitialised - if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { - t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) - } - if !reflect.DeepEqual(config.Forks, mainnetConfig.Forks) { - t.Errorf("Expected Forks to be %v, but got %v", mainnetConfig.Forks, config.Forks) - } - if *config.RpcBindIp != mainnetConfig.RpcBindIp { - t.Errorf("Expected RpcBindIP to be %s, but got %s", mainnetConfig.RpcBindIp, *config.RpcBindIp) - } - if *config.RpcPort != mainnetConfig.RpcPort { - t.Errorf("Expected RpcPort to be %v, but got %v", mainnetConfig.RpcPort, *config.RpcPort) - } - if config.ConsensusRpc != *mainnetConfig.ConsensusRpc { - t.Errorf("Expected ConsensusRpc to be %s, but got %s", *mainnetConfig.ConsensusRpc, config.ConsensusRpc) - } -} -func TestConfigFileCreatedSuccessfully(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("consensus_rpc", consensusRpc) - v.SetDefault("execution_rpc", executionRpc) - v.SetDefault("rpc_bind_ip", rpcBindIp) - v.SetDefault("rpc_port", rpcPort) - v.SetDefault("checkpoint", checkpoint) - v.SetDefault("data_dir", dataDirectory) - v.SetDefault("fallback", fallback) - v.SetDefault("load_external_fallback", loadExternalFallback) - v.SetDefault("strict_checkpoint_age", maxCheckpointAge) - createConfigFile(v) - var cliConfig CliConfig - var config Config - - config = config.from_file(&path, &network, &cliConfig) - - if config.ConsensusRpc != consensusRpc { - t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) - } - if config.ExecutionRpc != executionRpc { - t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) - } - if *config.DataDir != dataDirectory { - t.Errorf("Expected data directory to be %s, but got %s", dataDirectory, *config.DataDir) - } - if config.LoadExternalFallback != loadExternalFallback { - t.Errorf("Expected load external fallback to be %v, but got %v", loadExternalFallback, config.LoadExternalFallback) - } - if hex.EncodeToString((*config.Checkpoint)[:]) != checkpoint[2:] { - t.Errorf("Expected checkpoint to be %s, but got %s", checkpoint[2:], hex.EncodeToString((*config.Checkpoint)[:])) - } - -} -func TestCliConfig(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("execution_rpc", executionRpc) - cliConfig := CliConfig{ - ExecutionRpc: &executionRpc, - ConsensusRpc: &consensusRpc, - RpcBindIp: &rpcBindIp, - } - var config Config - - config = config.from_file(&path, &network, &cliConfig) - - if config.ExecutionRpc != *cliConfig.ExecutionRpc { - t.Errorf("Expected Execution rpc to be %s, but got %s", *cliConfig.ExecutionRpc, config.ExecutionRpc) - } - if config.ConsensusRpc != *cliConfig.ConsensusRpc { - t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) - } - if *config.RpcBindIp != *cliConfig.RpcBindIp { - t.Errorf("Expected rpc bind ip to be %s, but got %s", *cliConfig.RpcBindIp, *config.RpcBindIp) - } -} -func TestIfFieldNotInCliDefaultsToTomlThenBaseConfig(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("consensus_rpc", consensusRpc) - v.SetDefault("execution_rpc", executionRpc) - v.SetDefault("rpc_bind_ip", rpcBindIp) - v.SetDefault("rpc_port", rpcPort) - v.SetDefault("checkpoint", checkpoint) - v.SetDefault("data_dir", dataDirectory) - v.SetDefault("fallback", fallback) - v.SetDefault("load_external_fallback", loadExternalFallback) - v.SetDefault("max_checkpoint_age", maxCheckpointAge) - // Create file - createConfigFile(v) - cliConfig := CliConfig{ - ConsensusRpc: &consensusRpc, - RpcBindIp: &rpcBindIp, - } - var config Config - config = config.from_file(&path, &network, &cliConfig) - mainnetConfig, _ := Mainnet() - - // Rpc Port defined in toml file not in cli config - if config.ExecutionRpc != executionRpc { - t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) - } - // Rpc Port defined in toml file not in cli config - if *config.RpcPort != rpcPort { - t.Errorf("Expected rpc port to be %v, but got %v", rpcPort, config.RpcPort) - } - // Chain not defined in either toml or config - if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { - t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) - } -} -func createConfigFile(v *viper.Viper) { - // Specify the configuration file name and type - v.SetConfigName("config") - v.SetConfigType("toml") - v.AddConfigPath(".") - // Write configuration to file - configFile := "./config.toml" - if err := v.WriteConfigAs(configFile); err != nil { - fmt.Printf("Error creating config file: %v\n", err) - - // Create the file if it doesn't exist - if os.IsNotExist(err) { - if err := v.WriteConfigAs(configFile); err != nil { - fmt.Printf("Error creating config file: %v\n", err) - } else { - fmt.Println("Config file created successfully.") - } - } else { - fmt.Printf("Failed to write config file: %v\n", err) - } - } -} - -// //////////////////////////////// -// /// to_base_config() tests ///// -// //////////////////////////////// -func TestReturnsCorrectBaseConfig(t *testing.T) { - config := Config{ - ConsensusRpc: consensusRpc, - RpcBindIp: &rpcBindIp, - RpcPort: &rpcPort, - DefaultCheckpoint: defaultCheckpoint, - Chain: ChainConfig{}, - Forks: consensus_core.Forks{}, - MaxCheckpointAge: uint64(maxCheckpointAge), - DataDir: &dataDirectory, - LoadExternalFallback: loadExternalFallback, - StrictCheckpointAge: strictCheckpointAge, - } - - baseConfig := config.to_base_config() - - if !reflect.DeepEqual(baseConfig.Chain, config.Chain) { - t.Errorf("Expected Chain to be %v, got %v", config.Chain, baseConfig.Chain) - } - if !reflect.DeepEqual(baseConfig.Forks, config.Forks) { - t.Errorf("Expected Forks to be %v, got %v", config.Forks, baseConfig.Forks) - } - if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { - t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) - } -} -func TestReturnsCorrectDefaultValues(t *testing.T) { - config := Config{ - ConsensusRpc: consensusRpc, - DefaultCheckpoint: defaultCheckpoint, - Chain: ChainConfig{}, - Forks: consensus_core.Forks{}, - MaxCheckpointAge: uint64(maxCheckpointAge), - DataDir: &dataDirectory, - LoadExternalFallback: loadExternalFallback, - StrictCheckpointAge: strictCheckpointAge, - } - - baseConfig := config.to_base_config() - if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { - t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) - } - if baseConfig.RpcPort != 8545 { - t.Errorf("Expected rpc Port to be %v, got %v", 8545, baseConfig.RpcPort) - } - if baseConfig.RpcBindIp != "127.0.0.1" { - t.Errorf("Expected Max Checkpoint age to be %v, got %v", "127.0.0.1", baseConfig.RpcBindIp) - } -} +package config + +import ( + "encoding/hex" + "fmt" + "os" + "reflect" + "testing" + + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "github.com/spf13/viper" +) + +var ( + executionRpc = "http://localhost:8545" + consensusRpc = "http://localhost:5052" + checkpoint = "0x85e6151a246e8fdba36db27a0c7678a575346272fe978c9281e13a8b26cdfa68" + rpcBindIp = "127.0.0.1" + rpcPort = uint16(8080) + dataDirectory = "/data" + fallback = "http://fallback.example.com" + loadExternalFallback = true + maxCheckpointAge = 86400 + strictCheckpointAge = false + defaultCheckpoint = [32]byte{} +) + +// /////////////////////////// +// /// from_file() tests ///// +// /////////////////////////// +func TestMainnetBaseConfig(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("execution_rpc", executionRpc) + createConfigFile(v) + var cliConfig CliConfig + var config Config + + config = config.from_file(&path, &network, &cliConfig) + + mainnetConfig, _ := Mainnet() + + // config should have BaseConfig values for MAINNET as cliConfig and TomlConfig are uninitialised + if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { + t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) + } + if !reflect.DeepEqual(config.Forks, mainnetConfig.Forks) { + t.Errorf("Expected Forks to be %v, but got %v", mainnetConfig.Forks, config.Forks) + } + if *config.RpcBindIp != mainnetConfig.RpcBindIp { + t.Errorf("Expected RpcBindIP to be %s, but got %s", mainnetConfig.RpcBindIp, *config.RpcBindIp) + } + if *config.RpcPort != mainnetConfig.RpcPort { + t.Errorf("Expected RpcPort to be %v, but got %v", mainnetConfig.RpcPort, *config.RpcPort) + } + if config.ConsensusRpc != *mainnetConfig.ConsensusRpc { + t.Errorf("Expected ConsensusRpc to be %s, but got %s", *mainnetConfig.ConsensusRpc, config.ConsensusRpc) + } +} +func TestConfigFileCreatedSuccessfully(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("consensus_rpc", consensusRpc) + v.SetDefault("execution_rpc", executionRpc) + v.SetDefault("rpc_bind_ip", rpcBindIp) + v.SetDefault("rpc_port", rpcPort) + v.SetDefault("checkpoint", checkpoint) + v.SetDefault("data_dir", dataDirectory) + v.SetDefault("fallback", fallback) + v.SetDefault("load_external_fallback", loadExternalFallback) + v.SetDefault("strict_checkpoint_age", maxCheckpointAge) + createConfigFile(v) + var cliConfig CliConfig + var config Config + + config = config.from_file(&path, &network, &cliConfig) + + if config.ConsensusRpc != consensusRpc { + t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) + } + if config.ExecutionRpc != executionRpc { + t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) + } + if *config.DataDir != dataDirectory { + t.Errorf("Expected data directory to be %s, but got %s", dataDirectory, *config.DataDir) + } + if config.LoadExternalFallback != loadExternalFallback { + t.Errorf("Expected load external fallback to be %v, but got %v", loadExternalFallback, config.LoadExternalFallback) + } + if hex.EncodeToString((*config.Checkpoint)[:]) != checkpoint[2:] { + t.Errorf("Expected checkpoint to be %s, but got %s", checkpoint[2:], hex.EncodeToString((*config.Checkpoint)[:])) + } + +} +func TestCliConfig(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("execution_rpc", executionRpc) + cliConfig := CliConfig{ + ExecutionRpc: &executionRpc, + ConsensusRpc: &consensusRpc, + RpcBindIp: &rpcBindIp, + } + var config Config + + config = config.from_file(&path, &network, &cliConfig) + + if config.ExecutionRpc != *cliConfig.ExecutionRpc { + t.Errorf("Expected Execution rpc to be %s, but got %s", *cliConfig.ExecutionRpc, config.ExecutionRpc) + } + if config.ConsensusRpc != *cliConfig.ConsensusRpc { + t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) + } + if *config.RpcBindIp != *cliConfig.RpcBindIp { + t.Errorf("Expected rpc bind ip to be %s, but got %s", *cliConfig.RpcBindIp, *config.RpcBindIp) + } +} +func TestIfFieldNotInCliDefaultsToTomlThenBaseConfig(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("consensus_rpc", consensusRpc) + v.SetDefault("execution_rpc", executionRpc) + v.SetDefault("rpc_bind_ip", rpcBindIp) + v.SetDefault("rpc_port", rpcPort) + v.SetDefault("checkpoint", checkpoint) + v.SetDefault("data_dir", dataDirectory) + v.SetDefault("fallback", fallback) + v.SetDefault("load_external_fallback", loadExternalFallback) + v.SetDefault("max_checkpoint_age", maxCheckpointAge) + // Create file + createConfigFile(v) + cliConfig := CliConfig{ + ConsensusRpc: &consensusRpc, + RpcBindIp: &rpcBindIp, + } + var config Config + config = config.from_file(&path, &network, &cliConfig) + mainnetConfig, _ := Mainnet() + + // Rpc Port defined in toml file not in cli config + if config.ExecutionRpc != executionRpc { + t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) + } + // Rpc Port defined in toml file not in cli config + if *config.RpcPort != rpcPort { + t.Errorf("Expected rpc port to be %v, but got %v", rpcPort, config.RpcPort) + } + // Chain not defined in either toml or config + if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { + t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) + } +} +func createConfigFile(v *viper.Viper) { + // Specify the configuration file name and type + v.SetConfigName("config") + v.SetConfigType("toml") + v.AddConfigPath(".") + // Write configuration to file + configFile := "./config.toml" + if err := v.WriteConfigAs(configFile); err != nil { + fmt.Printf("Error creating config file: %v\n", err) + + // Create the file if it doesn't exist + if os.IsNotExist(err) { + if err := v.WriteConfigAs(configFile); err != nil { + fmt.Printf("Error creating config file: %v\n", err) + } else { + fmt.Println("Config file created successfully.") + } + } else { + fmt.Printf("Failed to write config file: %v\n", err) + } + } +} + +// //////////////////////////////// +// /// to_base_config() tests ///// +// //////////////////////////////// +func TestReturnsCorrectBaseConfig(t *testing.T) { + config := Config{ + ConsensusRpc: consensusRpc, + RpcBindIp: &rpcBindIp, + RpcPort: &rpcPort, + DefaultCheckpoint: defaultCheckpoint, + Chain: ChainConfig{}, + Forks: consensus_core.Forks{}, + MaxCheckpointAge: uint64(maxCheckpointAge), + DataDir: &dataDirectory, + LoadExternalFallback: loadExternalFallback, + StrictCheckpointAge: strictCheckpointAge, + } + + baseConfig := config.to_base_config() + + if !reflect.DeepEqual(baseConfig.Chain, config.Chain) { + t.Errorf("Expected Chain to be %v, got %v", config.Chain, baseConfig.Chain) + } + if !reflect.DeepEqual(baseConfig.Forks, config.Forks) { + t.Errorf("Expected Forks to be %v, got %v", config.Forks, baseConfig.Forks) + } + if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { + t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) + } +} +func TestReturnsCorrectDefaultValues(t *testing.T) { + config := Config{ + ConsensusRpc: consensusRpc, + DefaultCheckpoint: defaultCheckpoint, + Chain: ChainConfig{}, + Forks: consensus_core.Forks{}, + MaxCheckpointAge: uint64(maxCheckpointAge), + DataDir: &dataDirectory, + LoadExternalFallback: loadExternalFallback, + StrictCheckpointAge: strictCheckpointAge, + } + + baseConfig := config.to_base_config() + if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { + t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) + } + if baseConfig.RpcPort != 8545 { + t.Errorf("Expected rpc Port to be %v, got %v", 8545, baseConfig.RpcPort) + } + if baseConfig.RpcBindIp != "127.0.0.1" { + t.Errorf("Expected Max Checkpoint age to be %v, got %v", "127.0.0.1", baseConfig.RpcBindIp) + } +} diff --git a/config/networks_test.go b/config/networks_test.go index 88fccaf..24d9b67 100644 --- a/config/networks_test.go +++ b/config/networks_test.go @@ -1,18 +1,20 @@ package config + import ( - "testing" "github.com/stretchr/testify/assert" "strings" + "testing" ) + func TestNetwork_BaseConfig(t *testing.T) { tests := []struct { - name string - inputNetwork string - expectedChainID uint64 - expectedGenesis uint64 - expectedRPCPort uint16 + name string + inputNetwork string + expectedChainID uint64 + expectedGenesis uint64 + expectedRPCPort uint16 checkConsensusRPC func(*testing.T, *string) - wantErr bool + wantErr bool }{ { name: "Mainnet", @@ -24,7 +26,7 @@ func TestNetwork_BaseConfig(t *testing.T) { assert.NotNil(t, rpc) assert.Equal(t, "https://www.lightclientdata.org", *rpc) }, - wantErr: false, + wantErr: false, }, { name: "Goerli", @@ -35,7 +37,7 @@ func TestNetwork_BaseConfig(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { name: "Sepolia", @@ -46,16 +48,16 @@ func TestNetwork_BaseConfig(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { - name: "Invalid", - inputNetwork: "INVALID", - expectedChainID: 0, - expectedGenesis: 0, - expectedRPCPort: 0, + name: "Invalid", + inputNetwork: "INVALID", + expectedChainID: 0, + expectedGenesis: 0, + expectedRPCPort: 0, checkConsensusRPC: func(t *testing.T, rpc *string) {}, - wantErr: true, + wantErr: true, }, } @@ -71,17 +73,17 @@ func TestNetwork_BaseConfig(t *testing.T) { assert.Equal(t, tt.expectedGenesis, config.Chain.GenesisTime) assert.Equal(t, tt.expectedRPCPort, config.RpcPort) tt.checkConsensusRPC(t, config.ConsensusRpc) - + // Check Forks assert.NotEmpty(t, config.Forks.Genesis) assert.NotEmpty(t, config.Forks.Altair) assert.NotEmpty(t, config.Forks.Bellatrix) assert.NotEmpty(t, config.Forks.Capella) assert.NotEmpty(t, config.Forks.Deneb) - + // Check MaxCheckpointAge assert.Equal(t, uint64(1_209_600), config.MaxCheckpointAge) - + // Check DataDir assert.NotNil(t, config.DataDir) assert.Contains(t, strings.ToLower(*config.DataDir), strings.ToLower(tt.inputNetwork)) @@ -91,13 +93,13 @@ func TestNetwork_BaseConfig(t *testing.T) { } func TestNetwork_ChainID(t *testing.T) { tests := []struct { - name string - inputChainID uint64 - expectedChainID uint64 - expectedGenesis uint64 - expectedRPCPort uint16 + name string + inputChainID uint64 + expectedChainID uint64 + expectedGenesis uint64 + expectedRPCPort uint16 checkConsensusRPC func(*testing.T, *string) - wantErr bool + wantErr bool }{ { name: "Mainnet", @@ -109,7 +111,7 @@ func TestNetwork_ChainID(t *testing.T) { assert.NotNil(t, rpc) assert.Equal(t, "https://www.lightclientdata.org", *rpc) }, - wantErr: false, + wantErr: false, }, { name: "Goerli", @@ -120,7 +122,7 @@ func TestNetwork_ChainID(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { name: "Sepolia", @@ -131,16 +133,16 @@ func TestNetwork_ChainID(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { - name: "Invalid ChainID", - inputChainID: 9999, // Non-existent ChainID - expectedChainID: 0, - expectedGenesis: 0, - expectedRPCPort: 0, + name: "Invalid ChainID", + inputChainID: 9999, // Non-existent ChainID + expectedChainID: 0, + expectedGenesis: 0, + expectedRPCPort: 0, checkConsensusRPC: func(t *testing.T, rpc *string) {}, - wantErr: true, + wantErr: true, }, } @@ -156,17 +158,17 @@ func TestNetwork_ChainID(t *testing.T) { assert.Equal(t, tt.expectedGenesis, config.Chain.GenesisTime) assert.Equal(t, tt.expectedRPCPort, config.RpcPort) tt.checkConsensusRPC(t, config.ConsensusRpc) - + // Check Forks assert.NotEmpty(t, config.Forks.Genesis) assert.NotEmpty(t, config.Forks.Altair) assert.NotEmpty(t, config.Forks.Bellatrix) assert.NotEmpty(t, config.Forks.Capella) assert.NotEmpty(t, config.Forks.Deneb) - + // Check MaxCheckpointAge assert.Equal(t, uint64(1_209_600), config.MaxCheckpointAge) - + // Check DataDir assert.NotNil(t, config.DataDir) assert.Contains(t, strings.ToLower(*config.DataDir), strings.ToLower(tt.name)) diff --git a/config/types_test.go b/config/types_test.go index 2c47894..08ce502 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -2,8 +2,8 @@ package config import ( "encoding/json" - "testing" "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "testing" ) func TestChainConfigMarshalUnmarshal(t *testing.T) { diff --git a/consensus/consensus.go b/consensus/consensus.go index 410d665..737e943 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -685,10 +685,8 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo forkVersion := utils.CalculateForkVersion(&forks, update.SignatureSlot) forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(in.Config.Chain.GenesisRoot)) - - - if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { - return ErrInvalidSignature + if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { + return ErrInvalidSignature } return nil diff --git a/consensus/consensus_core/serde_utils.go b/consensus/consensus_core/serde_utils.go index 7317ca3..14a5a1c 100644 --- a/consensus/consensus_core/serde_utils.go +++ b/consensus/consensus_core/serde_utils.go @@ -23,41 +23,7 @@ func (b *Bootstrap) UnmarshalJSON(data []byte) error { return unmarshalJSON(data, b) } -// Unmarshal for Fork -func (f *Fork) UnmarshalJSON(data []byte) error { - var serialized map[string]interface{} - if err := json.Unmarshal(data, &serialized); err != nil { - return fmt.Errorf("error unmarshalling into map: %w", err) - } - v := reflect.ValueOf(f).Elem() - t := v.Type() - - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - fieldType := t.Field(i) - fieldName := fieldType.Tag.Get("json") - if fieldName == "" { - fieldName = snakeCase(fieldType.Name) - } - - if value, ok := serialized[fieldName]; ok { - switch field.Interface().(type) { - case uint64: - val, err := strconv.ParseUint(value.(string), 10, 64) - if err != nil { - return fmt.Errorf("error parsing %s: %w", fieldName, err) - } - field.Set(reflect.ValueOf(val)) - case []byte: - decoded := hexDecode(value.(string)) - field.Set(reflect.ValueOf(decoded)) - } - } - } - - return nil -} func (f *Forks) UnmarshalJSON(data []byte) error { var serialized map[string]interface{} @@ -129,7 +95,7 @@ func (h *Header) UnmarshalJSON(data []byte) error { case Bytes32: val, err := Hex_str_to_Bytes32(value.(string)) if err != nil { - continue + continue } field.Set(reflect.ValueOf(val)) } @@ -141,7 +107,6 @@ func (h *Header) UnmarshalJSON(data []byte) error { return nil } - func (s *SyncAggregate) UnmarshalJSON(data []byte) error { // Define a temporary map to hold JSON data var serialized map[string]string @@ -273,26 +238,24 @@ func unmarshalJSON(data []byte, v interface{}) error { } func (b *BeaconBlock) UnmarshalJSON(data []byte) error { - // Define a temporary structure to handle both string and number slots. - var tmp struct { - Slot json.RawMessage `json:"slot"` - } - - // Unmarshal into the temporary struct. - if err := json.Unmarshal(data, &tmp); err != nil { - return fmt.Errorf("error unmarshalling into temporary struct: %w", err) - } - - - - // If it wasn't a string, try unmarshalling as a number. - var slotNum uint64 - if err := json.Unmarshal(tmp.Slot, &slotNum); err == nil { - b.Slot = slotNum - return nil - } - - return fmt.Errorf("slot field is not a valid string or number") + // Define a temporary structure to handle both string and number slots. + var tmp struct { + Slot json.RawMessage `json:"slot"` + } + + // Unmarshal into the temporary struct. + if err := json.Unmarshal(data, &tmp); err != nil { + return fmt.Errorf("error unmarshalling into temporary struct: %w", err) + } + + // If it wasn't a string, try unmarshalling as a number. + var slotNum uint64 + if err := json.Unmarshal(tmp.Slot, &slotNum); err == nil { + b.Slot = slotNum + return nil + } + + return fmt.Errorf("slot field is not a valid string or number") } func setFieldValue(field reflect.Value, value interface{}) error { @@ -335,6 +298,9 @@ func setFieldValue(field reflect.Value, value interface{}) error { return nil } + + + // if we need to export the functions , just make their first letter capitalised func Hex_str_to_bytes(s string) ([]byte, error) { s = strings.TrimPrefix(s, "0x") diff --git a/consensus/database.go b/consensus/database.go index 77993a8..abdc234 100644 --- a/consensus/database.go +++ b/consensus/database.go @@ -1,10 +1,12 @@ package consensus + import ( "errors" "github.com/BlocSoc-iitr/selene/config" "os" "path/filepath" ) + type Database interface { New(cfg *config.Config) (Database, error) SaveCheckpoint(checkpoint []byte) error @@ -14,6 +16,7 @@ type FileDB struct { DataDir string defaultCheckpoint [32]byte } + func (f *FileDB) New(cfg *config.Config) (Database, error) { if cfg.DataDir == nil || *cfg.DataDir == "" { return nil, errors.New("data directory is not set in the config") @@ -43,9 +46,11 @@ func (f *FileDB) LoadCheckpoint() ([]byte, error) { } return f.defaultCheckpoint[:], nil } + type ConfigDB struct { checkpoint [32]byte } + func (c *ConfigDB) New(cfg *config.Config) (Database, error) { checkpoint := cfg.DefaultCheckpoint if cfg.DataDir == nil { diff --git a/consensus/rpc/consensus_rpc.go b/consensus/rpc/consensus_rpc.go index da0ffe8..9dafef3 100644 --- a/consensus/rpc/consensus_rpc.go +++ b/consensus/rpc/consensus_rpc.go @@ -15,9 +15,9 @@ type ConsensusRpc interface { } func NewConsensusRpc(rpc string) ConsensusRpc { - if(rpc == "testdata/"){ - return NewMockRpc(rpc) - }else { + if rpc == "testdata/" { + return NewMockRpc(rpc) + } else { return NewNimbusRpc(rpc) } } diff --git a/consensus/rpc/consensus_rpc_test.go b/consensus/rpc/consensus_rpc_test.go index 14a3617..e390e58 100644 --- a/consensus/rpc/consensus_rpc_test.go +++ b/consensus/rpc/consensus_rpc_test.go @@ -1,14 +1,17 @@ package rpc + import ( - "testing" "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "testing" ) + // MockConsensusRpc is a mock implementation of the ConsensusRpc interface type MockConsensusRpc struct { mock.Mock } + func (m *MockConsensusRpc) GetBootstrap(block_root [32]byte) (consensus_core.Bootstrap, error) { args := m.Called(block_root) return args.Get(0).(consensus_core.Bootstrap), args.Error(1) @@ -60,7 +63,7 @@ func TestConsensusRpcInterface(t *testing.T) { mockRpc.On("GetFinalityUpdate").Return(mockFinalityUpdate, nil) finalityUpdate, err := mockRpc.GetFinalityUpdate() assert.NoError(t, err) - assert.Equal(t, uint64(3000), finalityUpdate.FinalizedHeader.Slot) + assert.Equal(t, uint64(3000), finalityUpdate.FinalizedHeader.Slot) // Test GetOptimisticUpdate mockOptimisticUpdate := consensus_core.OptimisticUpdate{SignatureSlot: 4000} mockRpc.On("GetOptimisticUpdate").Return(mockOptimisticUpdate, nil) @@ -81,4 +84,4 @@ func TestConsensusRpcInterface(t *testing.T) { assert.Equal(t, uint64(1), chainId) // Assert that all expected mock calls were made mockRpc.AssertExpectations(t) -} \ No newline at end of file +} diff --git a/consensus/rpc/mock_rpc.go b/consensus/rpc/mock_rpc.go index 29230f2..332a23b 100644 --- a/consensus/rpc/mock_rpc.go +++ b/consensus/rpc/mock_rpc.go @@ -5,9 +5,9 @@ package rpc import ( "encoding/json" "fmt" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "os" "path/filepath" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" ) type MockRpc struct { diff --git a/consensus/rpc/mock_rpc_test.go b/consensus/rpc/mock_rpc_test.go index 06a9241..75134d0 100644 --- a/consensus/rpc/mock_rpc_test.go +++ b/consensus/rpc/mock_rpc_test.go @@ -2,11 +2,10 @@ package rpc import ( "encoding/json" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "os" "path/filepath" "testing" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - ) func TestGetBootstrap(t *testing.T) { @@ -59,11 +58,11 @@ func TestGetUpdates(t *testing.T) { "data": map[string]interface{}{ "attested_header": map[string]interface{}{ "beacon": map[string]interface{}{ - "slot": "1", + "slot": "1", "proposer_index": "12345", - "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", - "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", + "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", + "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", }, }, "signature_slot": "1", @@ -216,4 +215,4 @@ func TestChainId(t *testing.T) { if err == nil || err.Error() != "not implemented" { t.Errorf("Expected 'not implemented' error, got %v", err) } -} \ No newline at end of file +} diff --git a/consensus/rpc/nimbus_rpc_test.go b/consensus/rpc/nimbus_rpc_test.go index ed6c73d..45ce21e 100644 --- a/consensus/rpc/nimbus_rpc_test.go +++ b/consensus/rpc/nimbus_rpc_test.go @@ -1,13 +1,14 @@ package rpc + import ( "encoding/json" "fmt" - "net/http" - "net/http/httptest" - "testing" "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "net/http" + "net/http/httptest" + "testing" ) func TestNewNimbusRpc(t *testing.T) { @@ -56,11 +57,11 @@ func TestNimbusGetUpdates(t *testing.T) { "data": map[string]interface{}{ "attested_header": map[string]interface{}{ "beacon": map[string]interface{}{ - "slot": "1", + "slot": "1", "proposer_index": "12345", - "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", - "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", + "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", + "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", }, }, "signature_slot": "1", @@ -171,4 +172,4 @@ func TestNimbusChainId(t *testing.T) { chainId, err := nimbusRpc.ChainId() assert.NoError(t, err) assert.Equal(t, uint64(5000), chainId) -} \ No newline at end of file +} diff --git a/consensus/types/beacon.go b/consensus/types/beacon.go index 18ded48..66c517f 100644 --- a/consensus/types/beacon.go +++ b/consensus/types/beacon.go @@ -2,8 +2,6 @@ package types // Serialization and Deserialization for ExecutionPayload and BeaconBlockBody can be done by importing from prewritten functions in utils wherever needed. - - type BeaconBlock struct { Slot uint64 ProposerIndex uint64 @@ -92,8 +90,6 @@ func (exe *ExecutionPayload) Def() { exe.ExcessBlobGas = 0 // Only for Deneb } // default - - type Withdrawal struct { Index uint64 Amount uint64 diff --git a/execution/state.go b/execution/state.go index dddb75b..36db654 100644 --- a/execution/state.go +++ b/execution/state.go @@ -1,9 +1,11 @@ package execution + import ( - "sync" "github.com/BlocSoc-iitr/selene/common" "github.com/holiman/uint256" + "sync" ) + type State struct { mu sync.RWMutex blocks map[uint64]*common.Block @@ -16,6 +18,7 @@ type TransactionLocation struct { Block uint64 Index int } + func NewState(historyLength uint64, blockChan <-chan *common.Block, finalizedBlockChan <-chan *common.Block) *State { s := &State{ blocks: make(map[uint64]*common.Block), @@ -195,4 +198,4 @@ func (s *State) OldestBlockNumber() *uint64 { return &oldestNumber } return nil -} \ No newline at end of file +} diff --git a/execution/types.go b/execution/types.go index f650ccc..339d2a3 100644 --- a/execution/types.go +++ b/execution/types.go @@ -3,11 +3,12 @@ package execution import ( "encoding/json" "fmt" - "reflect" + "github.com/BlocSoc-iitr/selene/utils" "github.com/ethereum/go-ethereum/common" "math/big" - "github.com/BlocSoc-iitr/selene/utils" + "reflect" ) + type Account struct { Balance *big.Int Nonce uint64 @@ -24,43 +25,44 @@ type CallOpts struct { Value *big.Int `json:"value,omitempty"` Data []byte `json:"data,omitempty"` } + func (c *CallOpts) String() string { return fmt.Sprintf("CallOpts{From: %v, To: %v, Gas: %v, GasPrice: %v, Value: %v, Data: 0x%x}", c.From, c.To, c.Gas, c.GasPrice, c.Value, c.Data) } func (c *CallOpts) Serialize() ([]byte, error) { - serialized := make(map[string]interface{}) - v := reflect.ValueOf(*c) - t := v.Type() + serialized := make(map[string]interface{}) + v := reflect.ValueOf(*c) + t := v.Type() - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - fieldName := t.Field(i).Name + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + fieldName := t.Field(i).Name - if !field.IsNil() { - var value interface{} - var err error + if !field.IsNil() { + var value interface{} + var err error - switch field.Interface().(type) { - case *common.Address: - value = utils.Address_to_hex_string(*field.Interface().(*common.Address)) - case *big.Int: - value = utils.U64_to_hex_string(field.Interface().(*big.Int).Uint64()) - case []byte: - value, err = utils.Bytes_serialize(field.Interface().([]byte)) - if err != nil { - return nil, fmt.Errorf("error serializing %s: %w", fieldName, err) - } - default: - return nil, fmt.Errorf("unsupported type for field %s", fieldName) - } + switch field.Interface().(type) { + case *common.Address: + value = utils.Address_to_hex_string(*field.Interface().(*common.Address)) + case *big.Int: + value = utils.U64_to_hex_string(field.Interface().(*big.Int).Uint64()) + case []byte: + value, err = utils.Bytes_serialize(field.Interface().([]byte)) + if err != nil { + return nil, fmt.Errorf("error serializing %s: %w", fieldName, err) + } + default: + return nil, fmt.Errorf("unsupported type for field %s", fieldName) + } - serialized[fieldName] = value - } - } + serialized[fieldName] = value + } + } - return json.Marshal(serialized) + return json.Marshal(serialized) } func (c *CallOpts) Deserialize(data []byte) error { @@ -105,4 +107,4 @@ func (c *CallOpts) Deserialize(data []byte) error { } return nil -} \ No newline at end of file +} diff --git a/utils/bls/bls.go b/utils/bls/bls.go index 5abe51c..957c5a9 100644 --- a/utils/bls/bls.go +++ b/utils/bls/bls.go @@ -1,9 +1,9 @@ package bls import ( - "math/big" "github.com/consensys/gnark-crypto/ecc/bls12-381" "github.com/consensys/gnark-crypto/ecc/bls12-381/fp" + "math/big" ) type G1Point struct { @@ -82,4 +82,4 @@ func AggregatePublicKeys(pubkeys []*G2Point) *G2Point { agg.Add(agg, pubkey.G2Affine) } return &G2Point{agg} -} \ No newline at end of file +} From bf9531ee3d8b76f5206f53afb0a918565b22eadc Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Sat, 12 Oct 2024 05:41:05 +0000 Subject: [PATCH 10/13] minor fixes --- consensus/consensus.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index 737e943..25d2d49 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -677,15 +677,15 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo } else { syncCommittee = in.Store.NextSyncCommitee } - pks, err := utils.GetParticipatingKeys(syncCommittee, [64]byte(update.SyncAggregate.SyncCommitteeBits)) + _, err := utils.GetParticipatingKeys(syncCommittee, [64]byte(update.SyncAggregate.SyncCommitteeBits)) if err != nil { return fmt.Errorf("failed to get participating keys: %w", err) } forkVersion := utils.CalculateForkVersion(&forks, update.SignatureSlot) - forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(in.Config.Chain.GenesisRoot)) + forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(genesisRoots)) - if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { + if !verifySyncCommitteeSignature(syncCommittee.Pubkeys, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { return ErrInvalidSignature } @@ -930,12 +930,10 @@ func verifySyncCommitteeSignature( return false } - err := bls.FastAggregateVerify(collectedPks, signingRoot[:], &sig) - if err { - fmt.Println("signature verification failed") - return false - } - return true + + + return utils.FastAggregateVerify(collectedPks, signingRoot[:], &sig) + } func ComputeCommitteeSignRoot(header *beacon.Header, fork consensus_core.Bytes32) consensus_core.Bytes32 { @@ -1175,6 +1173,6 @@ func toGethSyncCommittee(committee *consensus_core.SyncCommittee) *beacon.Serial for i, key := range jsoncommittee.Pubkeys { copy(s[i*48:], key[:]) } - copy(s[512*48:], jsoncommittee.Aggregate[:]) +copy(s[512*48:], jsoncommittee.Aggregate[:]) return &s } From cc5d497d4cc52b8d8f686f223d135dabf265f542 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Sat, 12 Oct 2024 05:41:21 +0000 Subject: [PATCH 11/13] minor fixes --- utils/utils.go | 75 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index b90f97a..40b13fe 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,7 +2,6 @@ package utils import ( "encoding/hex" - "net/url" "strconv" "strings" @@ -17,7 +16,11 @@ import ( consensus_core "github.com/BlocSoc-iitr/selene/consensus/consensus_core" beacon "github.com/ethereum/go-ethereum/beacon/types" + kbls "github.com/kilic/bls12-381" + bls "github.com/protolambda/bls12-381-util" ) +var domain = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") + // if we need to export the functions , just make their first letter capitalised func Hex_str_to_bytes(s string) ([]byte, error) { @@ -221,7 +224,71 @@ func BranchToNodes(branch []consensus_core.Bytes32) ([][]byte, error) { } return nodes, nil } -func IsURL(str string) bool { - u, err := url.Parse(str) - return err == nil && u.Scheme != "" && u.Host != "" + +func FastAggregateVerify(pubkeys []*bls.Pubkey, message []byte, signature *bls.Signature) bool { + n := uint64(len(pubkeys)) + if n == 0 { + return false + } + + g1 := kbls.NewG1() + // Procedure: + // 1. aggregate = pubkey_to_point(PK_1) + // copy the first pubkey + aggregate := *(*kbls.PointG1)(pubkeys[0]) + // check identity pubkey + if (*kbls.G1)(nil).IsZero(&aggregate) { + fmt.Println("Identity pubkey") + return false + } + // 2. for i in 2, ..., n: + for i := uint64(1); i < n; i++ { + // 3. next = pubkey_to_point(PK_i) + next := (*kbls.PointG1)(pubkeys[i]) + // check identity pubkey + if (*kbls.G1)(nil).IsZero(next) { + fmt.Println("Identity pubkey") + return false + } + // 4. aggregate = aggregate + next + g1.Add(&aggregate, &aggregate, next) + } + // 5. PK = point_to_pubkey(aggregate) + PK := (*bls.Pubkey)(&aggregate) + return coreVerify(PK, message, signature) } + +func coreVerify(pk *bls.Pubkey, message []byte, signature *bls.Signature) bool { + // 1. R = signature_to_point(signature) + R := (*kbls.PointG2)(signature) + // 2. If R is INVALID, return INVALID + // 3. If signature_subgroup_check(R) is INVALID, return INVALID + // 4. If KeyValidate(PK) is INVALID, return INVALID + // steps 2-4 are part of bytes -> *Signature deserialization + if (*kbls.G2)(nil).IsZero(R) { + // KeyValidate is assumed through deserialization of Pubkey and Signature, + // but the identity pubkey/signature case is not part of that, thus verify here. + fmt.Print("Identity signature") + return false + } + + // 5. xP = pubkey_to_point(PK) + xP := (*kbls.PointG1)(pk) + // 6. Q = hash_to_point(message) + Q, err := kbls.NewG2().HashToCurve(message, domain) + if err != nil { + // e.g. when the domain is too long. Maybe change to panic if never due to a usage error? + fmt.Print("Failed to hash message to point") + return false + } + + // 7. C1 = pairing(Q, xP) + eng := kbls.NewEngine() + eng.AddPair(xP, Q) + // 8. C2 = pairing(R, P) + P := &kbls.G1One + eng.AddPairInv(P, R) + // 9. If C1 != C2, return INVALID + return !eng.Check() +} + From b4fa59f2c8108f515f995c8700f591599b948aa0 Mon Sep 17 00:00:00 2001 From: Sambhav Jain <136801346+DarkLord017@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:10:43 +0000 Subject: [PATCH 12/13] minor bug fix --- consensus/consensus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index 25d2d49..0622653 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -666,7 +666,7 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo if !isNextCommitteeProofValid(&update.AttestedHeader, update.NextSyncCommittee, *update.NextSyncCommitteeBranch) { return ErrInvalidNextSyncCommitteeProof } - } else if (update.NextSyncCommittee != nil && update.NextSyncCommitteeBranch == nil) && (update.NextSyncCommittee == nil && update.NextSyncCommitteeBranch != nil) { + } else if (update.NextSyncCommittee != nil && update.NextSyncCommitteeBranch == nil) || (update.NextSyncCommittee == nil && update.NextSyncCommitteeBranch != nil) { return ErrInvalidNextSyncCommitteeProof } From b7eb4331ce8f95e44f0215a6b9b71009c2943195 Mon Sep 17 00:00:00 2001 From: Vasu Khanna <117103753+star-gazer111@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:31:22 +0530 Subject: [PATCH 13/13] Revert "Implement consenus test go" --- common/errors.go | 3 +- config/base_test.go | 41 +- config/checkpoints/checkpoints.go | 165 +++--- config/checkpoints/checkpoints_test.go | 6 +- config/cli.go | 84 ++-- config/cli_test.go | 113 +++-- config/config.toml | 9 - config/config_test.go | 470 ++++++++--------- config/networks_test.go | 76 ++- config/types_test.go | 2 +- consensus/consensus.go | 420 ++++++---------- consensus/consensus_core/consensus_core.go | 245 +++++---- consensus/consensus_core/serde_utils.go | 372 -------------- consensus/consensus_test.go | 312 ------------ consensus/database.go | 5 - consensus/rpc/consensus_rpc.go | 6 +- consensus/rpc/consensus_rpc_test.go | 9 +- consensus/rpc/mock_rpc.go | 40 +- consensus/rpc/mock_rpc_test.go | 103 +--- consensus/rpc/nimbus_rpc_test.go | 87 +--- consensus/types/beacon.go | 4 + execution/state.go | 7 +- execution/types.go | 60 ++- go.mod | 41 -- go.sum | 560 --------------------- utils/bls/bls.go | 4 +- utils/utils.go | 241 +++++---- 27 files changed, 984 insertions(+), 2501 deletions(-) delete mode 100644 config/config.toml delete mode 100644 consensus/consensus_core/serde_utils.go delete mode 100644 consensus/consensus_test.go diff --git a/common/errors.go b/common/errors.go index d773ee3..d9b2898 100644 --- a/common/errors.go +++ b/common/errors.go @@ -14,8 +14,9 @@ func (e BlockNotFoundError) Error() string { return fmt.Sprintf("block not available: %s", e.Block) } + // need to confirm how such primitive types will be imported -type hash [32]byte +type hash [32]byte; type SlotNotFoundError struct { slot hash diff --git a/config/base_test.go b/config/base_test.go index 6401a76..1ded12b 100644 --- a/config/base_test.go +++ b/config/base_test.go @@ -1,21 +1,20 @@ -package config - -import ( - "testing" -) - -func TestCorrectDefaultBaseConfig(t *testing.T) { - baseConfig := BaseConfig{} - - baseConfig = baseConfig.Default() - - if baseConfig.RpcBindIp != "127.0.0.1" { - t.Errorf("Expected RpcBindIP to be %s, but got %s", "127.0.0.1", baseConfig.RpcBindIp) - } - if baseConfig.RpcPort != 0 { - t.Errorf("Expected RpcPort to be %v, but got %v", 0, baseConfig.RpcPort) - } - if baseConfig.ConsensusRpc != nil { - t.Errorf("Expected ConsensusRpc to be %v, but got %v", nil, baseConfig.ConsensusRpc) - } -} +package config + +import ( + "testing" +) +func TestCorrectDefaultBaseConfig(t *testing.T) { + baseConfig := BaseConfig{} + + baseConfig = baseConfig.Default() + + if baseConfig.RpcBindIp != "127.0.0.1" { + t.Errorf("Expected RpcBindIP to be %s, but got %s", "127.0.0.1", baseConfig.RpcBindIp) + } + if baseConfig.RpcPort != 0 { + t.Errorf("Expected RpcPort to be %v, but got %v", 0, baseConfig.RpcPort) + } + if baseConfig.ConsensusRpc != nil { + t.Errorf("Expected ConsensusRpc to be %v, but got %v", nil, baseConfig.ConsensusRpc) + } +} \ No newline at end of file diff --git a/config/checkpoints/checkpoints.go b/config/checkpoints/checkpoints.go index 4394fdc..6ac2003 100644 --- a/config/checkpoints/checkpoints.go +++ b/config/checkpoints/checkpoints.go @@ -1,19 +1,19 @@ package checkpoints import ( - "context" "encoding/json" "fmt" - "github.com/BlocSoc-iitr/selene/config" - "github.com/avast/retry-go" - "gopkg.in/yaml.v2" "io" - "log" "net/http" "strconv" "strings" "sync" + "context" "time" + "log" + "github.com/BlocSoc-iitr/selene/config" + "github.com/avast/retry-go" + "gopkg.in/yaml.v2" ) // / The location where the list of checkpoint services are stored. @@ -186,10 +186,10 @@ func (ch CheckpointFallback) Build() (CheckpointFallback, error) { return ch, fmt.Errorf("expected a map for service in network %s", network) } - endpoint, _ := serviceMap["endpoint"].(string) // Handle potential nil - name, _ := serviceMap["name"].(string) // Handle potential nil - state, _ := serviceMap["state"].(bool) // Handle potential nil - verification, _ := serviceMap["verification"].(bool) // Handle potential nil + endpoint, _ := serviceMap["endpoint"].(string) // Handle potential nil + name, _ := serviceMap["name"].(string) // Handle potential nil + state, _ := serviceMap["state"].(bool) // Handle potential nil + verification, _ := serviceMap["verification"].(bool) // Handle potential nil // Check contacts and notes var contacts *yaml.MapSlice @@ -206,17 +206,17 @@ func (ch CheckpointFallback) Build() (CheckpointFallback, error) { if !ok { return ch, fmt.Errorf("expected a map for health in service %s", name) } - healthResult, _ := healthRaw["result"].(bool) // Handle potential nil - healthDate, _ := healthRaw["date"].(string) // Handle potential nil + healthResult, _ := healthRaw["result"].(bool) // Handle potential nil + healthDate, _ := healthRaw["date"].(string) // Handle potential nil ch.Services[network] = append(ch.Services[network], CheckpointFallbackService{ - Endpoint: endpoint, - Name: name, - State: state, - Verification: verification, - Contacts: contacts, - Notes: notes, - Health_from_fallback: &Health{ + Endpoint: endpoint, + Name: name, + State: state, + Verification: verification, + Contacts: contacts, + Notes: notes, + Health_from_fallback: &Health{ Result: healthResult, Date: healthDate, }, @@ -227,6 +227,7 @@ func (ch CheckpointFallback) Build() (CheckpointFallback, error) { return ch, nil } + // fetch the latest checkpoint from the given network func (ch CheckpointFallback) FetchLatestCheckpoint(network config.Network) byte256 { services := ch.GetHealthyFallbackServices(network) @@ -257,73 +258,73 @@ func (ch CheckpointFallback) QueryService(endpoint string) (*RawSlotResponse, er // fetch the latest checkpoint from the given services func (ch CheckpointFallback) FetchLatestCheckpointFromServices(services []CheckpointFallbackService) (byte256, error) { - var ( - slots []Slot - wg sync.WaitGroup - slotChan = make(chan Slot, len(services)) // Buffered channel - errorsChan = make(chan error, len(services)) - ) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - - for _, service := range services { - wg.Add(1) - go func(service CheckpointFallbackService) { - defer wg.Done() - raw, err := ch.QueryService(service.Endpoint) - if err != nil { - errorsChan <- fmt.Errorf("failed to fetch checkpoint from service %s: %w", service.Endpoint, err) - return - } - if len(raw.Data.Slots) > 0 { - slotChan <- raw.Data.Slots[0] // Send the first valid slot - } - }(service) - } - - go func() { - wg.Wait() - close(slotChan) - close(errorsChan) - }() - - for { - select { - case slot, ok := <-slotChan: - if !ok { - // Channel closed, all slots processed - if len(slots) == 0 { - return byte256{}, fmt.Errorf("failed to find max epoch from checkpoint slots") - } - return processSlots(slots) - } - slots = append(slots, slot) - case err := <-errorsChan: - if err != nil { - log.Printf("Error fetching checkpoint: %v", err) // Log only if the error is not nil. - } - case <-ctx.Done(): - if len(slots) == 0 { - return byte256{}, ctx.Err() - } - return processSlots(slots) - } - } + var ( + slots []Slot + wg sync.WaitGroup + slotChan = make(chan Slot, len(services)) // Buffered channel + errorsChan = make(chan error, len(services)) + ) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + for _, service := range services { + wg.Add(1) + go func(service CheckpointFallbackService) { + defer wg.Done() + raw, err := ch.QueryService(service.Endpoint) + if err != nil { + errorsChan <- fmt.Errorf("failed to fetch checkpoint from service %s: %w", service.Endpoint, err) + return + } + if len(raw.Data.Slots) > 0 { + slotChan <- raw.Data.Slots[0] // Send the first valid slot + } + }(service) + } + + go func() { + wg.Wait() + close(slotChan) + close(errorsChan) + }() + + for { + select { + case slot, ok := <-slotChan: + if !ok { + // Channel closed, all slots processed + if len(slots) == 0 { + return byte256{}, fmt.Errorf("failed to find max epoch from checkpoint slots") + } + return processSlots(slots) + } + slots = append(slots, slot) + case err := <-errorsChan: + if err != nil { + log.Printf("Error fetching checkpoint: %v", err) // Log only if the error is not nil. + } + case <-ctx.Done(): + if len(slots) == 0 { + return byte256{}, ctx.Err() + } + return processSlots(slots) + } + } } func processSlots(slots []Slot) (byte256, error) { - maxEpochSlot := slots[0] - for _, slot := range slots { - if slot.Epoch > maxEpochSlot.Epoch { - maxEpochSlot = slot - } - } - - if maxEpochSlot.Block_root == nil { - return byte256{}, fmt.Errorf("no valid block root found") - } - - return *maxEpochSlot.Block_root, nil + maxEpochSlot := slots[0] + for _, slot := range slots { + if slot.Epoch > maxEpochSlot.Epoch { + maxEpochSlot = slot + } + } + + if maxEpochSlot.Block_root == nil { + return byte256{}, fmt.Errorf("no valid block root found") + } + + return *maxEpochSlot.Block_root, nil } func (ch CheckpointFallback) FetchLatestCheckpointFromApi(url string) (byte256, error) { diff --git a/config/checkpoints/checkpoints_test.go b/config/checkpoints/checkpoints_test.go index 1038b68..4a119cf 100644 --- a/config/checkpoints/checkpoints_test.go +++ b/config/checkpoints/checkpoints_test.go @@ -3,11 +3,11 @@ package checkpoints import ( "bytes" "encoding/json" - "github.com/BlocSoc-iitr/selene/config" - "io" "net/http" "net/http/httptest" "testing" + "io" + "github.com/BlocSoc-iitr/selene/config" ) type CustomTransport struct { @@ -289,6 +289,7 @@ func TestGetHealthyFallbackServices(t *testing.T) { } } + func equalNetworks(a, b []config.Network) bool { if len(a) != len(b) { return false @@ -316,3 +317,4 @@ func equalStringSlices(a, b []string) bool { } return true } + diff --git a/config/cli.go b/config/cli.go index 10bdef2..d0be553 100644 --- a/config/cli.go +++ b/config/cli.go @@ -1,52 +1,50 @@ package config import ( - "encoding/hex" + "encoding/hex" ) - // The format of configuration to be stored in the configuratin file is map[string]interface{} type CliConfig struct { - ExecutionRpc *string `mapstructure:"execution_rpc"` - ConsensusRpc *string `mapstructure:"consensus_rpc"` - Checkpoint *[]byte `mapstructure:"checkpoint"` - RpcBindIp *string `mapstructure:"rpc_bind_ip"` - RpcPort *uint16 `mapstructure:"rpc_port"` - DataDir *string `mapstructure:"data_dir"` - Fallback *string `mapstructure:"fallback"` - LoadExternalFallback *bool `mapstructure:"load_external_fallback"` - StrictCheckpointAge *bool `mapstructure:"strict_checkpoint_age"` + ExecutionRpc *string `mapstructure:"execution_rpc"` + ConsensusRpc *string `mapstructure:"consensus_rpc"` + Checkpoint *[]byte `mapstructure:"checkpoint"` + RpcBindIp *string `mapstructure:"rpc_bind_ip"` + RpcPort *uint16 `mapstructure:"rpc_port"` + DataDir *string `mapstructure:"data_dir"` + Fallback *string `mapstructure:"fallback"` + LoadExternalFallback *bool `mapstructure:"load_external_fallback"` + StrictCheckpointAge *bool `mapstructure:"strict_checkpoint_age"` } - func (cfg *CliConfig) as_provider() map[string]interface{} { - // Create a map to hold the configuration data - userDict := make(map[string]interface{}) - // Populate the map with values from the CliConfig struct - if cfg.ExecutionRpc != nil { - userDict["execution_rpc"] = *cfg.ExecutionRpc - } - if cfg.ConsensusRpc != nil { - userDict["consensus_rpc"] = *cfg.ConsensusRpc - } - if cfg.Checkpoint != nil { - userDict["checkpoint"] = hex.EncodeToString(*cfg.Checkpoint) - } - if cfg.RpcBindIp != nil { - userDict["rpc_bind_ip"] = *cfg.RpcBindIp - } - if cfg.RpcPort != nil { - userDict["rpc_port"] = *cfg.RpcPort - } - if cfg.DataDir != nil { - userDict["data_dir"] = *cfg.DataDir - } - if cfg.Fallback != nil { - userDict["fallback"] = *cfg.Fallback - } - if cfg.LoadExternalFallback != nil { - userDict["load_external_fallback"] = *cfg.LoadExternalFallback - } - if cfg.StrictCheckpointAge != nil { - userDict["strict_checkpoint_age"] = *cfg.StrictCheckpointAge - } - return userDict + // Create a map to hold the configuration data + userDict := make(map[string]interface{}) + // Populate the map with values from the CliConfig struct + if cfg.ExecutionRpc != nil { + userDict["execution_rpc"] = *cfg.ExecutionRpc + } + if cfg.ConsensusRpc != nil { + userDict["consensus_rpc"] = *cfg.ConsensusRpc + } + if cfg.Checkpoint != nil { + userDict["checkpoint"] = hex.EncodeToString(*cfg.Checkpoint) + } + if cfg.RpcBindIp != nil { + userDict["rpc_bind_ip"] = *cfg.RpcBindIp + } + if cfg.RpcPort != nil { + userDict["rpc_port"] = *cfg.RpcPort + } + if cfg.DataDir != nil { + userDict["data_dir"] = *cfg.DataDir + } + if cfg.Fallback != nil { + userDict["fallback"] = *cfg.Fallback + } + if cfg.LoadExternalFallback != nil { + userDict["load_external_fallback"] = *cfg.LoadExternalFallback + } + if cfg.StrictCheckpointAge != nil { + userDict["strict_checkpoint_age"] = *cfg.StrictCheckpointAge + } + return userDict } diff --git a/config/cli_test.go b/config/cli_test.go index f17bf08..ad6391f 100644 --- a/config/cli_test.go +++ b/config/cli_test.go @@ -1,67 +1,66 @@ package config import ( - "encoding/hex" - "testing" + "encoding/hex" + "testing" - "github.com/spf13/viper" + "github.com/spf13/viper" ) - // for the test I have used viper, but ant other configuration library can be used. Just the format of the configuration should be the same i.e. map[string]interface{} func TestCliConfigAsProvider(t *testing.T) { // used some random values for the test - executionRpc := "http://localhost:8545" - consensusRpc := "http://localhost:5052" - checkpoint := []byte{0x01, 0x02, 0x03} - rpcBindIp := "127.0.0.1" - rpcPort := uint16(8080) - dataDir := "/data" - fallback := "http://fallback.example.com" - loadExternalFallback := true - strictCheckpointAge := false + executionRpc := "http://localhost:8545" + consensusRpc := "http://localhost:5052" + checkpoint := []byte{0x01, 0x02, 0x03} + rpcBindIp := "127.0.0.1" + rpcPort := uint16(8080) + dataDir := "/data" + fallback := "http://fallback.example.com" + loadExternalFallback := true + strictCheckpointAge := false - config := CliConfig{ - ExecutionRpc: &executionRpc, - ConsensusRpc: &consensusRpc, - Checkpoint: &checkpoint, - RpcBindIp: &rpcBindIp, - RpcPort: &rpcPort, - DataDir: &dataDir, - Fallback: &fallback, - LoadExternalFallback: &loadExternalFallback, - StrictCheckpointAge: &strictCheckpointAge, - } - v := viper.New() - configMap := config.as_provider() - for key, value := range configMap { - v.Set(key, value) - } - // Assertions to check that Viper has the correct values - if v.GetString("execution_rpc") != executionRpc { - t.Errorf("Expected execution_rpc to be %s, but got %s", executionRpc, v.GetString("execution_rpc")) - } - if v.GetString("consensus_rpc") != consensusRpc { - t.Errorf("Expected consensus_rpc to be %s, but got %s", consensusRpc, v.GetString("consensus_rpc")) - } - if v.GetString("checkpoint") != hex.EncodeToString(checkpoint) { - t.Errorf("Expected checkpoint to be %s, but got %s", hex.EncodeToString(checkpoint), v.GetString("checkpoint")) - } - if v.GetString("rpc_bind_ip") != rpcBindIp { - t.Errorf("Expected rpc_bind_ip to be %s, but got %s", rpcBindIp, v.GetString("rpc_bind_ip")) - } - if v.GetUint16("rpc_port") != rpcPort { - t.Errorf("Expected rpc_port to be %d, but got %d", rpcPort, v.GetUint16("rpc_port")) - } - if v.GetString("data_dir") != dataDir { - t.Errorf("Expected data_dir to be %s, but got %s", dataDir, v.GetString("data_dir")) - } - if v.GetString("fallback") != fallback { - t.Errorf("Expected fallback to be %s, but got %s", fallback, v.GetString("fallback")) - } - if v.GetBool("load_external_fallback") != loadExternalFallback { - t.Errorf("Expected load_external_fallback to be %v, but got %v", loadExternalFallback, v.GetBool("load_external_fallback")) - } - if v.GetBool("strict_checkpoint_age") != strictCheckpointAge { - t.Errorf("Expected strict_checkpoint_age to be %v, but got %v", strictCheckpointAge, v.GetBool("strict_checkpoint_age")) - } + config := CliConfig{ + ExecutionRpc: &executionRpc, + ConsensusRpc: &consensusRpc, + Checkpoint: &checkpoint, + RpcBindIp: &rpcBindIp, + RpcPort: &rpcPort, + DataDir: &dataDir, + Fallback: &fallback, + LoadExternalFallback: &loadExternalFallback, + StrictCheckpointAge: &strictCheckpointAge, + } + v := viper.New() + configMap := config.as_provider() + for key, value := range configMap { + v.Set(key, value) + } + // Assertions to check that Viper has the correct values + if v.GetString("execution_rpc") != executionRpc { + t.Errorf("Expected execution_rpc to be %s, but got %s", executionRpc, v.GetString("execution_rpc")) + } + if v.GetString("consensus_rpc") != consensusRpc { + t.Errorf("Expected consensus_rpc to be %s, but got %s", consensusRpc, v.GetString("consensus_rpc")) + } + if v.GetString("checkpoint") != hex.EncodeToString(checkpoint) { + t.Errorf("Expected checkpoint to be %s, but got %s", hex.EncodeToString(checkpoint), v.GetString("checkpoint")) + } + if v.GetString("rpc_bind_ip") != rpcBindIp { + t.Errorf("Expected rpc_bind_ip to be %s, but got %s", rpcBindIp, v.GetString("rpc_bind_ip")) + } + if v.GetUint16("rpc_port") != rpcPort { + t.Errorf("Expected rpc_port to be %d, but got %d", rpcPort, v.GetUint16("rpc_port")) + } + if v.GetString("data_dir") != dataDir { + t.Errorf("Expected data_dir to be %s, but got %s", dataDir, v.GetString("data_dir")) + } + if v.GetString("fallback") != fallback { + t.Errorf("Expected fallback to be %s, but got %s", fallback, v.GetString("fallback")) + } + if v.GetBool("load_external_fallback") != loadExternalFallback { + t.Errorf("Expected load_external_fallback to be %v, but got %v", loadExternalFallback, v.GetBool("load_external_fallback")) + } + if v.GetBool("strict_checkpoint_age") != strictCheckpointAge { + t.Errorf("Expected strict_checkpoint_age to be %v, but got %v", strictCheckpointAge, v.GetBool("strict_checkpoint_age")) + } } diff --git a/config/config.toml b/config/config.toml deleted file mode 100644 index f1662a2..0000000 --- a/config/config.toml +++ /dev/null @@ -1,9 +0,0 @@ -checkpoint = '0x85e6151a246e8fdba36db27a0c7678a575346272fe978c9281e13a8b26cdfa68' -consensus_rpc = 'http://localhost:5052' -data_dir = '/data' -execution_rpc = 'http://localhost:8545' -fallback = 'http://fallback.example.com' -load_external_fallback = true -max_checkpoint_age = 86400 -rpc_bind_ip = '127.0.0.1' -rpc_port = 8080 diff --git a/config/config_test.go b/config/config_test.go index 858c470..c34095c 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,235 +1,235 @@ -package config - -import ( - "encoding/hex" - "fmt" - "os" - "reflect" - "testing" - - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - "github.com/spf13/viper" -) - -var ( - executionRpc = "http://localhost:8545" - consensusRpc = "http://localhost:5052" - checkpoint = "0x85e6151a246e8fdba36db27a0c7678a575346272fe978c9281e13a8b26cdfa68" - rpcBindIp = "127.0.0.1" - rpcPort = uint16(8080) - dataDirectory = "/data" - fallback = "http://fallback.example.com" - loadExternalFallback = true - maxCheckpointAge = 86400 - strictCheckpointAge = false - defaultCheckpoint = [32]byte{} -) - -// /////////////////////////// -// /// from_file() tests ///// -// /////////////////////////// -func TestMainnetBaseConfig(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("execution_rpc", executionRpc) - createConfigFile(v) - var cliConfig CliConfig - var config Config - - config = config.from_file(&path, &network, &cliConfig) - - mainnetConfig, _ := Mainnet() - - // config should have BaseConfig values for MAINNET as cliConfig and TomlConfig are uninitialised - if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { - t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) - } - if !reflect.DeepEqual(config.Forks, mainnetConfig.Forks) { - t.Errorf("Expected Forks to be %v, but got %v", mainnetConfig.Forks, config.Forks) - } - if *config.RpcBindIp != mainnetConfig.RpcBindIp { - t.Errorf("Expected RpcBindIP to be %s, but got %s", mainnetConfig.RpcBindIp, *config.RpcBindIp) - } - if *config.RpcPort != mainnetConfig.RpcPort { - t.Errorf("Expected RpcPort to be %v, but got %v", mainnetConfig.RpcPort, *config.RpcPort) - } - if config.ConsensusRpc != *mainnetConfig.ConsensusRpc { - t.Errorf("Expected ConsensusRpc to be %s, but got %s", *mainnetConfig.ConsensusRpc, config.ConsensusRpc) - } -} -func TestConfigFileCreatedSuccessfully(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("consensus_rpc", consensusRpc) - v.SetDefault("execution_rpc", executionRpc) - v.SetDefault("rpc_bind_ip", rpcBindIp) - v.SetDefault("rpc_port", rpcPort) - v.SetDefault("checkpoint", checkpoint) - v.SetDefault("data_dir", dataDirectory) - v.SetDefault("fallback", fallback) - v.SetDefault("load_external_fallback", loadExternalFallback) - v.SetDefault("strict_checkpoint_age", maxCheckpointAge) - createConfigFile(v) - var cliConfig CliConfig - var config Config - - config = config.from_file(&path, &network, &cliConfig) - - if config.ConsensusRpc != consensusRpc { - t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) - } - if config.ExecutionRpc != executionRpc { - t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) - } - if *config.DataDir != dataDirectory { - t.Errorf("Expected data directory to be %s, but got %s", dataDirectory, *config.DataDir) - } - if config.LoadExternalFallback != loadExternalFallback { - t.Errorf("Expected load external fallback to be %v, but got %v", loadExternalFallback, config.LoadExternalFallback) - } - if hex.EncodeToString((*config.Checkpoint)[:]) != checkpoint[2:] { - t.Errorf("Expected checkpoint to be %s, but got %s", checkpoint[2:], hex.EncodeToString((*config.Checkpoint)[:])) - } - -} -func TestCliConfig(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("execution_rpc", executionRpc) - cliConfig := CliConfig{ - ExecutionRpc: &executionRpc, - ConsensusRpc: &consensusRpc, - RpcBindIp: &rpcBindIp, - } - var config Config - - config = config.from_file(&path, &network, &cliConfig) - - if config.ExecutionRpc != *cliConfig.ExecutionRpc { - t.Errorf("Expected Execution rpc to be %s, but got %s", *cliConfig.ExecutionRpc, config.ExecutionRpc) - } - if config.ConsensusRpc != *cliConfig.ConsensusRpc { - t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) - } - if *config.RpcBindIp != *cliConfig.RpcBindIp { - t.Errorf("Expected rpc bind ip to be %s, but got %s", *cliConfig.RpcBindIp, *config.RpcBindIp) - } -} -func TestIfFieldNotInCliDefaultsToTomlThenBaseConfig(t *testing.T) { - network := "MAINNET" - path := "./config.toml" - v := viper.New() - // Set default values for the configuration - v.SetDefault("consensus_rpc", consensusRpc) - v.SetDefault("execution_rpc", executionRpc) - v.SetDefault("rpc_bind_ip", rpcBindIp) - v.SetDefault("rpc_port", rpcPort) - v.SetDefault("checkpoint", checkpoint) - v.SetDefault("data_dir", dataDirectory) - v.SetDefault("fallback", fallback) - v.SetDefault("load_external_fallback", loadExternalFallback) - v.SetDefault("max_checkpoint_age", maxCheckpointAge) - // Create file - createConfigFile(v) - cliConfig := CliConfig{ - ConsensusRpc: &consensusRpc, - RpcBindIp: &rpcBindIp, - } - var config Config - config = config.from_file(&path, &network, &cliConfig) - mainnetConfig, _ := Mainnet() - - // Rpc Port defined in toml file not in cli config - if config.ExecutionRpc != executionRpc { - t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) - } - // Rpc Port defined in toml file not in cli config - if *config.RpcPort != rpcPort { - t.Errorf("Expected rpc port to be %v, but got %v", rpcPort, config.RpcPort) - } - // Chain not defined in either toml or config - if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { - t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) - } -} -func createConfigFile(v *viper.Viper) { - // Specify the configuration file name and type - v.SetConfigName("config") - v.SetConfigType("toml") - v.AddConfigPath(".") - // Write configuration to file - configFile := "./config.toml" - if err := v.WriteConfigAs(configFile); err != nil { - fmt.Printf("Error creating config file: %v\n", err) - - // Create the file if it doesn't exist - if os.IsNotExist(err) { - if err := v.WriteConfigAs(configFile); err != nil { - fmt.Printf("Error creating config file: %v\n", err) - } else { - fmt.Println("Config file created successfully.") - } - } else { - fmt.Printf("Failed to write config file: %v\n", err) - } - } -} - -// //////////////////////////////// -// /// to_base_config() tests ///// -// //////////////////////////////// -func TestReturnsCorrectBaseConfig(t *testing.T) { - config := Config{ - ConsensusRpc: consensusRpc, - RpcBindIp: &rpcBindIp, - RpcPort: &rpcPort, - DefaultCheckpoint: defaultCheckpoint, - Chain: ChainConfig{}, - Forks: consensus_core.Forks{}, - MaxCheckpointAge: uint64(maxCheckpointAge), - DataDir: &dataDirectory, - LoadExternalFallback: loadExternalFallback, - StrictCheckpointAge: strictCheckpointAge, - } - - baseConfig := config.to_base_config() - - if !reflect.DeepEqual(baseConfig.Chain, config.Chain) { - t.Errorf("Expected Chain to be %v, got %v", config.Chain, baseConfig.Chain) - } - if !reflect.DeepEqual(baseConfig.Forks, config.Forks) { - t.Errorf("Expected Forks to be %v, got %v", config.Forks, baseConfig.Forks) - } - if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { - t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) - } -} -func TestReturnsCorrectDefaultValues(t *testing.T) { - config := Config{ - ConsensusRpc: consensusRpc, - DefaultCheckpoint: defaultCheckpoint, - Chain: ChainConfig{}, - Forks: consensus_core.Forks{}, - MaxCheckpointAge: uint64(maxCheckpointAge), - DataDir: &dataDirectory, - LoadExternalFallback: loadExternalFallback, - StrictCheckpointAge: strictCheckpointAge, - } - - baseConfig := config.to_base_config() - if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { - t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) - } - if baseConfig.RpcPort != 8545 { - t.Errorf("Expected rpc Port to be %v, got %v", 8545, baseConfig.RpcPort) - } - if baseConfig.RpcBindIp != "127.0.0.1" { - t.Errorf("Expected Max Checkpoint age to be %v, got %v", "127.0.0.1", baseConfig.RpcBindIp) - } -} +package config + +import ( + "encoding/hex" + "fmt" + "os" + "reflect" + "testing" + + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "github.com/spf13/viper" +) + +var ( + executionRpc = "http://localhost:8545" + consensusRpc = "http://localhost:5052" + checkpoint = "0x85e6151a246e8fdba36db27a0c7678a575346272fe978c9281e13a8b26cdfa68" + rpcBindIp = "127.0.0.1" + rpcPort = uint16(8080) + dataDirectory = "/data" + fallback = "http://fallback.example.com" + loadExternalFallback = true + maxCheckpointAge = 86400 + strictCheckpointAge = false + defaultCheckpoint = [32]byte{} +) + +// /////////////////////////// +// /// from_file() tests ///// +// /////////////////////////// +func TestMainnetBaseConfig(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("execution_rpc", executionRpc) + createConfigFile(v) + var cliConfig CliConfig + var config Config + + config = config.from_file(&path, &network, &cliConfig) + + mainnetConfig, _ := Mainnet() + + // config should have BaseConfig values for MAINNET as cliConfig and TomlConfig are uninitialised + if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { + t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) + } + if !reflect.DeepEqual(config.Forks, mainnetConfig.Forks) { + t.Errorf("Expected Forks to be %v, but got %v", mainnetConfig.Forks, config.Forks) + } + if *config.RpcBindIp != mainnetConfig.RpcBindIp { + t.Errorf("Expected RpcBindIP to be %s, but got %s", mainnetConfig.RpcBindIp, *config.RpcBindIp) + } + if *config.RpcPort != mainnetConfig.RpcPort { + t.Errorf("Expected RpcPort to be %v, but got %v", mainnetConfig.RpcPort, *config.RpcPort) + } + if config.ConsensusRpc != *mainnetConfig.ConsensusRpc { + t.Errorf("Expected ConsensusRpc to be %s, but got %s", *mainnetConfig.ConsensusRpc, config.ConsensusRpc) + } +} +func TestConfigFileCreatedSuccessfully(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("consensus_rpc", consensusRpc) + v.SetDefault("execution_rpc", executionRpc) + v.SetDefault("rpc_bind_ip", rpcBindIp) + v.SetDefault("rpc_port", rpcPort) + v.SetDefault("checkpoint", checkpoint) + v.SetDefault("data_dir", dataDirectory) + v.SetDefault("fallback", fallback) + v.SetDefault("load_external_fallback", loadExternalFallback) + v.SetDefault("strict_checkpoint_age", maxCheckpointAge) + createConfigFile(v) + var cliConfig CliConfig + var config Config + + config = config.from_file(&path, &network, &cliConfig) + + if config.ConsensusRpc != consensusRpc { + t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) + } + if config.ExecutionRpc != executionRpc { + t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) + } + if *config.DataDir != dataDirectory { + t.Errorf("Expected data directory to be %s, but got %s", dataDirectory, *config.DataDir) + } + if config.LoadExternalFallback != loadExternalFallback { + t.Errorf("Expected load external fallback to be %v, but got %v", loadExternalFallback, config.LoadExternalFallback) + } + if hex.EncodeToString((*config.Checkpoint)[:]) != checkpoint[2:] { + t.Errorf("Expected checkpoint to be %s, but got %s", checkpoint[2:], hex.EncodeToString((*config.Checkpoint)[:])) + } + +} +func TestCliConfig(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("execution_rpc", executionRpc) + cliConfig := CliConfig{ + ExecutionRpc: &executionRpc, + ConsensusRpc: &consensusRpc, + RpcBindIp: &rpcBindIp, + } + var config Config + + config = config.from_file(&path, &network, &cliConfig) + + if config.ExecutionRpc != *cliConfig.ExecutionRpc { + t.Errorf("Expected Execution rpc to be %s, but got %s", *cliConfig.ExecutionRpc, config.ExecutionRpc) + } + if config.ConsensusRpc != *cliConfig.ConsensusRpc { + t.Errorf("Expected ConsensusRpc to be %s, but got %s", consensusRpc, config.ConsensusRpc) + } + if *config.RpcBindIp != *cliConfig.RpcBindIp { + t.Errorf("Expected rpc bind ip to be %s, but got %s", *cliConfig.RpcBindIp, *config.RpcBindIp) + } +} +func TestIfFieldNotInCliDefaultsToTomlThenBaseConfig(t *testing.T) { + network := "MAINNET" + path := "./config.toml" + v := viper.New() + // Set default values for the configuration + v.SetDefault("consensus_rpc", consensusRpc) + v.SetDefault("execution_rpc", executionRpc) + v.SetDefault("rpc_bind_ip", rpcBindIp) + v.SetDefault("rpc_port", rpcPort) + v.SetDefault("checkpoint", checkpoint) + v.SetDefault("data_dir", dataDirectory) + v.SetDefault("fallback", fallback) + v.SetDefault("load_external_fallback", loadExternalFallback) + v.SetDefault("max_checkpoint_age", maxCheckpointAge) + // Create file + createConfigFile(v) + cliConfig := CliConfig{ + ConsensusRpc: &consensusRpc, + RpcBindIp: &rpcBindIp, + } + var config Config + config = config.from_file(&path, &network, &cliConfig) + mainnetConfig, _ := Mainnet() + + // Rpc Port defined in toml file not in cli config + if config.ExecutionRpc != executionRpc { + t.Errorf("Expected executionRpc to be %s, but got %s", executionRpc, config.ExecutionRpc) + } + // Rpc Port defined in toml file not in cli config + if *config.RpcPort != rpcPort { + t.Errorf("Expected rpc port to be %v, but got %v", rpcPort, config.RpcPort) + } + // Chain not defined in either toml or config + if !reflect.DeepEqual(config.Chain, mainnetConfig.Chain) { + t.Errorf("Expected Chain to be %v, but got %v", mainnetConfig.Chain, config.Chain) + } +} +func createConfigFile(v *viper.Viper) { + // Specify the configuration file name and type + v.SetConfigName("config") + v.SetConfigType("toml") + v.AddConfigPath(".") + // Write configuration to file + configFile := "./config.toml" + if err := v.WriteConfigAs(configFile); err != nil { + fmt.Printf("Error creating config file: %v\n", err) + + // Create the file if it doesn't exist + if os.IsNotExist(err) { + if err := v.WriteConfigAs(configFile); err != nil { + fmt.Printf("Error creating config file: %v\n", err) + } else { + fmt.Println("Config file created successfully.") + } + } else { + fmt.Printf("Failed to write config file: %v\n", err) + } + } +} + +// //////////////////////////////// +// /// to_base_config() tests ///// +// //////////////////////////////// +func TestReturnsCorrectBaseConfig(t *testing.T) { + config := Config{ + ConsensusRpc: consensusRpc, + RpcBindIp: &rpcBindIp, + RpcPort: &rpcPort, + DefaultCheckpoint: defaultCheckpoint, + Chain: ChainConfig{}, + Forks: consensus_core.Forks{}, + MaxCheckpointAge: uint64(maxCheckpointAge), + DataDir: &dataDirectory, + LoadExternalFallback: loadExternalFallback, + StrictCheckpointAge: strictCheckpointAge, + } + + baseConfig := config.to_base_config() + + if !reflect.DeepEqual(baseConfig.Chain, config.Chain) { + t.Errorf("Expected Chain to be %v, got %v", config.Chain, baseConfig.Chain) + } + if !reflect.DeepEqual(baseConfig.Forks, config.Forks) { + t.Errorf("Expected Forks to be %v, got %v", config.Forks, baseConfig.Forks) + } + if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { + t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) + } +} +func TestReturnsCorrectDefaultValues(t *testing.T) { + config := Config{ + ConsensusRpc: consensusRpc, + DefaultCheckpoint: defaultCheckpoint, + Chain: ChainConfig{}, + Forks: consensus_core.Forks{}, + MaxCheckpointAge: uint64(maxCheckpointAge), + DataDir: &dataDirectory, + LoadExternalFallback: loadExternalFallback, + StrictCheckpointAge: strictCheckpointAge, + } + + baseConfig := config.to_base_config() + if baseConfig.MaxCheckpointAge != config.MaxCheckpointAge { + t.Errorf("Expected Max Checkpoint age to be %v, got %v", config.MaxCheckpointAge, baseConfig.MaxCheckpointAge) + } + if baseConfig.RpcPort != 8545 { + t.Errorf("Expected rpc Port to be %v, got %v", 8545, baseConfig.RpcPort) + } + if baseConfig.RpcBindIp != "127.0.0.1" { + t.Errorf("Expected Max Checkpoint age to be %v, got %v", "127.0.0.1", baseConfig.RpcBindIp) + } +} diff --git a/config/networks_test.go b/config/networks_test.go index 24d9b67..88fccaf 100644 --- a/config/networks_test.go +++ b/config/networks_test.go @@ -1,20 +1,18 @@ package config - import ( + "testing" "github.com/stretchr/testify/assert" "strings" - "testing" ) - func TestNetwork_BaseConfig(t *testing.T) { tests := []struct { - name string - inputNetwork string - expectedChainID uint64 - expectedGenesis uint64 - expectedRPCPort uint16 + name string + inputNetwork string + expectedChainID uint64 + expectedGenesis uint64 + expectedRPCPort uint16 checkConsensusRPC func(*testing.T, *string) - wantErr bool + wantErr bool }{ { name: "Mainnet", @@ -26,7 +24,7 @@ func TestNetwork_BaseConfig(t *testing.T) { assert.NotNil(t, rpc) assert.Equal(t, "https://www.lightclientdata.org", *rpc) }, - wantErr: false, + wantErr: false, }, { name: "Goerli", @@ -37,7 +35,7 @@ func TestNetwork_BaseConfig(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { name: "Sepolia", @@ -48,16 +46,16 @@ func TestNetwork_BaseConfig(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { - name: "Invalid", - inputNetwork: "INVALID", - expectedChainID: 0, - expectedGenesis: 0, - expectedRPCPort: 0, + name: "Invalid", + inputNetwork: "INVALID", + expectedChainID: 0, + expectedGenesis: 0, + expectedRPCPort: 0, checkConsensusRPC: func(t *testing.T, rpc *string) {}, - wantErr: true, + wantErr: true, }, } @@ -73,17 +71,17 @@ func TestNetwork_BaseConfig(t *testing.T) { assert.Equal(t, tt.expectedGenesis, config.Chain.GenesisTime) assert.Equal(t, tt.expectedRPCPort, config.RpcPort) tt.checkConsensusRPC(t, config.ConsensusRpc) - + // Check Forks assert.NotEmpty(t, config.Forks.Genesis) assert.NotEmpty(t, config.Forks.Altair) assert.NotEmpty(t, config.Forks.Bellatrix) assert.NotEmpty(t, config.Forks.Capella) assert.NotEmpty(t, config.Forks.Deneb) - + // Check MaxCheckpointAge assert.Equal(t, uint64(1_209_600), config.MaxCheckpointAge) - + // Check DataDir assert.NotNil(t, config.DataDir) assert.Contains(t, strings.ToLower(*config.DataDir), strings.ToLower(tt.inputNetwork)) @@ -93,13 +91,13 @@ func TestNetwork_BaseConfig(t *testing.T) { } func TestNetwork_ChainID(t *testing.T) { tests := []struct { - name string - inputChainID uint64 - expectedChainID uint64 - expectedGenesis uint64 - expectedRPCPort uint16 + name string + inputChainID uint64 + expectedChainID uint64 + expectedGenesis uint64 + expectedRPCPort uint16 checkConsensusRPC func(*testing.T, *string) - wantErr bool + wantErr bool }{ { name: "Mainnet", @@ -111,7 +109,7 @@ func TestNetwork_ChainID(t *testing.T) { assert.NotNil(t, rpc) assert.Equal(t, "https://www.lightclientdata.org", *rpc) }, - wantErr: false, + wantErr: false, }, { name: "Goerli", @@ -122,7 +120,7 @@ func TestNetwork_ChainID(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { name: "Sepolia", @@ -133,16 +131,16 @@ func TestNetwork_ChainID(t *testing.T) { checkConsensusRPC: func(t *testing.T, rpc *string) { assert.Nil(t, rpc) }, - wantErr: false, + wantErr: false, }, { - name: "Invalid ChainID", - inputChainID: 9999, // Non-existent ChainID - expectedChainID: 0, - expectedGenesis: 0, - expectedRPCPort: 0, + name: "Invalid ChainID", + inputChainID: 9999, // Non-existent ChainID + expectedChainID: 0, + expectedGenesis: 0, + expectedRPCPort: 0, checkConsensusRPC: func(t *testing.T, rpc *string) {}, - wantErr: true, + wantErr: true, }, } @@ -158,17 +156,17 @@ func TestNetwork_ChainID(t *testing.T) { assert.Equal(t, tt.expectedGenesis, config.Chain.GenesisTime) assert.Equal(t, tt.expectedRPCPort, config.RpcPort) tt.checkConsensusRPC(t, config.ConsensusRpc) - + // Check Forks assert.NotEmpty(t, config.Forks.Genesis) assert.NotEmpty(t, config.Forks.Altair) assert.NotEmpty(t, config.Forks.Bellatrix) assert.NotEmpty(t, config.Forks.Capella) assert.NotEmpty(t, config.Forks.Deneb) - + // Check MaxCheckpointAge assert.Equal(t, uint64(1_209_600), config.MaxCheckpointAge) - + // Check DataDir assert.NotNil(t, config.DataDir) assert.Contains(t, strings.ToLower(*config.DataDir), strings.ToLower(tt.name)) diff --git a/config/types_test.go b/config/types_test.go index 08ce502..2c47894 100644 --- a/config/types_test.go +++ b/config/types_test.go @@ -2,8 +2,8 @@ package config import ( "encoding/json" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "testing" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" ) func TestChainConfigMarshalUnmarshal(t *testing.T) { diff --git a/consensus/consensus.go b/consensus/consensus.go index 0622653..2a25cf3 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -6,6 +6,7 @@ package consensus // uses common for datatypes import ( "bytes" + "context" "encoding/hex" "fmt" "log" @@ -20,15 +21,12 @@ import ( "github.com/BlocSoc-iitr/selene/config/checkpoints" "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "github.com/BlocSoc-iitr/selene/consensus/rpc" - "github.com/BlocSoc-iitr/selene/utils" - beacon "github.com/ethereum/go-ethereum/beacon/types" + "github.com/BlocSoc-iitr/selene/utils/bls" geth "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" "github.com/holiman/uint256" "github.com/pkg/errors" - bls "github.com/protolambda/bls12-381-util" ) // Error definitions @@ -183,72 +181,48 @@ func (con ConsensusClient) Expected_current_slot() uint64 { } func sync_fallback(inner *Inner, fallback *string) error { - // Create a buffered channel to receive any errors from the goroutine - errorChan := make(chan error, 1) - - go func() { - // Attempt to fetch the latest checkpoint from the API - cf, err := (&checkpoints.CheckpointFallback{}).FetchLatestCheckpointFromApi(*fallback) - if err != nil { - - errorChan <- err - return - } - - if err := inner.sync(cf); err != nil { - - errorChan <- err - return - } - - errorChan <- nil - }() + cf, err := (&checkpoints.CheckpointFallback{}).FetchLatestCheckpointFromApi(*fallback) + if err != nil { + return errors.Wrap(err, "failed to fetch checkpoint from API") + } + return inner.sync(cf) - return <-errorChan } - func sync_all_fallback(inner *Inner, chainID uint64) error { var n config.Network network, err := n.ChainID(chainID) if err != nil { return err } - errorChan := make(chan error, 1) - - go func() { - ch := checkpoints.CheckpointFallback{} + ch := checkpoints.CheckpointFallback{} - checkpointFallback, errWhileCheckpoint := ch.Build() - if errWhileCheckpoint != nil { - errorChan <- errWhileCheckpoint - return - } + checkpointFallback, errWhileCheckpoint := ch.Build() + if errWhileCheckpoint != nil { + return err + } - chainId := network.Chain.ChainID - var networkName config.Network - if chainId == 1 { - networkName = config.MAINNET - } else if chainId == 5 { - networkName = config.GOERLI - } else if chainId == 11155111 { - networkName = config.SEPOLIA - } else { - errorChan <- errors.New("chain id not recognized") - return - } + chainId := network.Chain.ChainID + var networkName config.Network + if chainId == 1 { + networkName = config.MAINNET + } else if chainId == 5 { + networkName = config.GOERLI + } else if chainId == 11155111 { + networkName = config.SEPOLIA + } else { + return errors.New("chain id not recognized") + } - // Fetch the latest checkpoint from the network - checkpoint := checkpointFallback.FetchLatestCheckpoint(networkName) + // Fetch the latest checkpoint from the network + checkpoint := checkpointFallback.FetchLatestCheckpoint(networkName) - // Sync using the inner struct's sync method - if err := inner.sync(checkpoint); err != nil { - errorChan <- err - } + // Sync using the inner struct's sync method + if err := inner.sync(checkpoint); err != nil { + return err + } - errorChan <- nil - }() - return <-errorChan + return nil } func (in *Inner) New(rpcURL string, blockSend chan common.Block, finalizedBlockSend chan *common.Block, checkpointSend chan *[]byte, config *config.Config) *Inner { @@ -266,60 +240,47 @@ func (in *Inner) New(rpcURL string, blockSend chan common.Block, finalizedBlockS } func (in *Inner) Check_rpc() error { - errorChan := make(chan error, 1) - - go func() { - chainID, err := in.RPC.ChainId() - if err != nil { - errorChan <- err - return - } - if chainID != in.Config.Chain.ChainID { - errorChan <- ErrIncorrectRpcNetwork - return - } - errorChan <- nil - }() - return <-errorChan + chainID, err := in.RPC.ChainId() + if err != nil { + return err + } + if chainID != in.Config.Chain.ChainID { + return ErrIncorrectRpcNetwork + } + return nil } -func (in *Inner) get_execution_payload(slot *uint64) (*consensus_core.ExecutionPayload, error) { - errorChan := make(chan error, 1) - blockChan := make(chan consensus_core.BeaconBlock, 1) - go func() { - var err error - block, err := in.RPC.GetBlock(*slot) - if err != nil { - errorChan <- err - } - errorChan <- nil - blockChan <- block - }() - - if err := <-errorChan; err != nil { +func (in *Inner) get_execution_payload(ctx context.Context, slot *uint64) (*consensus_core.ExecutionPayload, error) { + block, err := in.RPC.GetBlock(*slot) + if err != nil { return nil, err } - block := <-blockChan - Gethblock, err := beacon.BlockFromJSON("capella", block.Body.Hash) + blockHash, err := utils.TreeHashRoot(block.Body.ToBytes()) if err != nil { return nil, err } - blockHash := Gethblock.Root() latestSlot := in.Store.OptimisticHeader.Slot finalizedSlot := in.Store.FinalizedHeader.Slot - var verifiedBlockHash geth.Hash + var verifiedBlockHash []byte + var errGettingBlockHash error if *slot == latestSlot { - verifiedBlockHash = toGethHeader(&in.Store.OptimisticHeader).Hash() + verifiedBlockHash, errGettingBlockHash = utils.TreeHashRoot(in.Store.OptimisticHeader.ToBytes()) + if errGettingBlockHash != nil { + return nil, ErrPayloadNotFound + } } else if *slot == finalizedSlot { - verifiedBlockHash = toGethHeader(&in.Store.FinalizedHeader).Hash() + verifiedBlockHash, errGettingBlockHash = utils.TreeHashRoot(in.Store.FinalizedHeader.ToBytes()) + if errGettingBlockHash != nil { + return nil, ErrPayloadNotFound + } } else { return nil, ErrPayloadNotFound } // Compare the hashes - if !bytes.Equal(verifiedBlockHash[:], blockHash.Bytes()) { + if !bytes.Equal(verifiedBlockHash, blockHash) { return nil, fmt.Errorf("%w: expected %v but got %v", ErrInvalidHeaderHash, verifiedBlockHash, blockHash) } @@ -327,7 +288,7 @@ func (in *Inner) get_execution_payload(slot *uint64) (*consensus_core.ExecutionP return &payload, nil } -func (in *Inner) Get_payloads(startSlot, endSlot uint64) ([]interface{}, error) { +func (in *Inner) Get_payloads(ctx context.Context, startSlot, endSlot uint64) ([]interface{}, error) { var payloads []interface{} // Fetch the block at endSlot to get the initial parent hash @@ -384,22 +345,11 @@ func (in *Inner) Get_payloads(startSlot, endSlot uint64) ([]interface{}, error) } } func (in *Inner) advance() error { - ErrorChan := make(chan error, 1) - finalityChan := make(chan consensus_core.FinalityUpdate, 1) - - go func() { - finalityUpdate, err := in.RPC.GetFinalityUpdate() - if err != nil { - ErrorChan <- err - return - } - finalityChan <- finalityUpdate - ErrorChan <- nil - }() - if ErrorChan != nil { - return <-ErrorChan + // Fetch and apply finality update + finalityUpdate, err := in.RPC.GetFinalityUpdate() + if err != nil { + return err } - finalityUpdate := <-finalityChan if err := in.verify_finality_update(&finalityUpdate); err != nil { return err } @@ -444,74 +394,60 @@ func (in *Inner) sync(checkpoint [32]byte) error { // Perform bootstrap with the given checkpoint in.bootstrap(checkpoint) + // Calculate the current sync period currentPeriod := utils.CalcSyncPeriod(in.Store.FinalizedHeader.Slot) - errorChan := make(chan error, 1) - var updates []consensus_core.Update - var err error - go func() { - updates, err = in.RPC.GetUpdates(currentPeriod, MAX_REQUEST_LIGHT_CLIENT_UPDATES) - if err != nil { - errorChan <- err - } - - // Apply updates - for _, update := range updates { - if err := in.verify_update(&update); err != nil { - - errorChan <- err - return - } - in.apply_update(&update) - } - - finalityUpdate, err := in.RPC.GetFinalityUpdate() - if err != nil { - - errorChan <- err - return - } + // Fetch updates + updates, err := in.RPC.GetUpdates(currentPeriod, MAX_REQUEST_LIGHT_CLIENT_UPDATES) + if err != nil { + return err + } - if err := in.verify_finality_update(&finalityUpdate); err != nil { - errorChan <- err - return + // Apply updates + for _, update := range updates { + if err := in.verify_update(&update); err != nil { + return err } - in.apply_finality_update(&finalityUpdate) + in.apply_update(&update) + } - // Fetch and apply optimistic update + // Fetch and apply finality update + finalityUpdate, err := in.RPC.GetFinalityUpdate() + if err != nil { + return err + } + if err := in.verify_finality_update(&finalityUpdate); err != nil { + return err + } + in.apply_finality_update(&finalityUpdate) - optimisticUpdate, err := in.RPC.GetOptimisticUpdate() - if err != nil { - errorChan <- err - return - } - if err := in.verify_optimistic_update(&optimisticUpdate); err != nil { - errorChan <- err - return - } - in.apply_optimistic_update(&optimisticUpdate) - errorChan <- nil - log.Printf("consensus client in sync with checkpoint: 0x%s", hex.EncodeToString(checkpoint[:])) - }() + // Fetch and apply optimistic update - if err := <-errorChan; err != nil { + optimisticUpdate, err := in.RPC.GetOptimisticUpdate() + if err != nil { return err } + if err := in.verify_optimistic_update(&optimisticUpdate); err != nil { + return err + } + in.apply_optimistic_update(&optimisticUpdate) + // Log the success message + log.Printf("consensus client in sync with checkpoint: 0x%s", hex.EncodeToString(checkpoint[:])) return nil } func (in *Inner) send_blocks() error { // Get slot from the optimistic header slot := in.Store.OptimisticHeader.Slot - payload, err := in.get_execution_payload(&slot) + payload, err := in.get_execution_payload(context.Background(), &slot) if err != nil { return err } // Get finalized slot from the finalized header finalizedSlot := in.Store.FinalizedHeader.Slot - finalizedPayload, err := in.get_execution_payload(&finalizedSlot) + finalizedPayload, err := in.get_execution_payload(context.Background(), &finalizedSlot) if err != nil { return err } @@ -557,28 +493,18 @@ func (in *Inner) duration_until_next_update() time.Duration { return time.Duration(nextUpdate) * time.Second } func (in *Inner) bootstrap(checkpoint [32]byte) { - errorChan := make(chan error, 1) - bootstrapChan := make(chan consensus_core.Bootstrap, 1) - go func() { - bootstrap, errInBootstrap := in.RPC.GetBootstrap(checkpoint) - if errInBootstrap != nil { - log.Printf("failed to fetch bootstrap: %v", errInBootstrap) - errorChan <- errInBootstrap - return - } - bootstrapChan <- bootstrap - errorChan <- nil - }() - if err := <-errorChan; err != nil { + bootstrap, errInBootstrap := in.RPC.GetBootstrap(checkpoint) + if errInBootstrap != nil { + log.Printf("failed to fetch bootstrap: %v", errInBootstrap) return } - bootstrap := <-bootstrapChan isValid := in.is_valid_checkpoint(bootstrap.Header.Slot) if !isValid { if in.Config.StrictCheckpointAge { - panic("checkpoint too old, consider using a more recent checkpoint") + log.Printf("checkpoint too old, consider using a more recent checkpoint") + return } else { log.Printf("checkpoint too old, consider using a more recent checkpoint") } @@ -595,8 +521,11 @@ func verify_bootstrap(checkpoint [32]byte, bootstrap consensus_core.Bootstrap) { return } - headerHash := toGethHeader(&bootstrap.Header).Hash() - + headerHash, err := utils.TreeHashRoot(bootstrap.Header.ToBytes()) + if err != nil { + log.Println("failed to hash header") + return + } HeaderValid := bytes.Equal(headerHash[:], checkpoint[:]) if !HeaderValid { @@ -618,7 +547,7 @@ func apply_bootstrap(store *LightClientStore, bootstrap consensus_core.Bootstrap func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlot uint64, store *LightClientStore, genesisRoots []byte, forks consensus_core.Forks) error { { - bits := getBits(update.SyncAggregate.SyncCommitteeBits[:]) + bits := getBits(update.SyncAggregate.SyncCommitteeBits) if bits == 0 { return ErrInsufficientParticipation } @@ -658,15 +587,16 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo if !isFinalityProofValid(&update.AttestedHeader, &update.FinalizedHeader, update.FinalityBranch) { return ErrInvalidFinalityProof } - } else if (update.FinalizedHeader != (consensus_core.Header{}) && update.FinalityBranch == nil) || (update.FinalizedHeader == (consensus_core.Header{}) && update.FinalityBranch != nil) { + } else if update.FinalizedHeader != (consensus_core.Header{}) { return ErrInvalidFinalityProof } + // Validate next sync committee and its branch if update.NextSyncCommittee != nil && update.NextSyncCommitteeBranch != nil { if !isNextCommitteeProofValid(&update.AttestedHeader, update.NextSyncCommittee, *update.NextSyncCommitteeBranch) { return ErrInvalidNextSyncCommitteeProof } - } else if (update.NextSyncCommittee != nil && update.NextSyncCommitteeBranch == nil) || (update.NextSyncCommittee == nil && update.NextSyncCommitteeBranch != nil) { + } else if update.NextSyncCommittee != nil { return ErrInvalidNextSyncCommitteeProof } @@ -677,15 +607,15 @@ func (in *Inner) verify_generic_update(update *GenericUpdate, expectedCurrentSlo } else { syncCommittee = in.Store.NextSyncCommitee } - _, err := utils.GetParticipatingKeys(syncCommittee, [64]byte(update.SyncAggregate.SyncCommitteeBits)) + pks, err := utils.GetParticipatingKeys(syncCommittee, update.SyncAggregate.SyncCommitteeBits) if err != nil { return fmt.Errorf("failed to get participating keys: %w", err) } forkVersion := utils.CalculateForkVersion(&forks, update.SignatureSlot) - forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(genesisRoots)) + forkDataRoot := utils.ComputeForkDataRoot(forkVersion, consensus_core.Bytes32(in.Config.Chain.GenesisRoot)) - if !verifySyncCommitteeSignature(syncCommittee.Pubkeys, &update.AttestedHeader, &update.SyncAggregate, forkDataRoot) { + if !verifySyncCommitteeSignature(pks, &update.AttestedHeader, &update.SyncAggregate.SyncCommitteeSignature, forkDataRoot) { return ErrInvalidSignature } @@ -705,9 +635,6 @@ func (in *Inner) verify_update(update *consensus_core.Update) error { return in.verify_generic_update(&genUpdate, in.expected_current_slot(), &in.Store, in.Config.Chain.GenesisRoot, in.Config.Forks) } func (in *Inner) verify_finality_update(update *consensus_core.FinalityUpdate) error { - if update == nil { - return ErrInvalidUpdate - } genUpdate := GenericUpdate{ AttestedHeader: update.AttestedHeader, SyncAggregate: update.SyncAggregate, @@ -726,7 +653,7 @@ func (in *Inner) verify_optimistic_update(update *consensus_core.OptimisticUpdat return in.verify_generic_update(&genUpdate, in.expected_current_slot(), &in.Store, in.Config.Chain.GenesisRoot, in.Config.Forks) } func (in *Inner) apply_generic_update(store *LightClientStore, update *GenericUpdate) *[]byte { - committeeBits := getBits(update.SyncAggregate.SyncCommitteeBits[:]) + committeeBits := getBits(update.SyncAggregate.SyncCommitteeBits) // Update max active participants if committeeBits > store.CurrentMaxActiveParticipants { @@ -788,9 +715,11 @@ func (in *Inner) apply_generic_update(store *LightClientStore, update *GenericUp } if store.FinalizedHeader.Slot%32 == 0 { - checkpoint := toGethHeader(&store.FinalizedHeader).Hash() - checkpointBytes := checkpoint.Bytes() - return &checkpointBytes + checkpoint, err := utils.TreeHashRoot(store.FinalizedHeader.ToBytes()) + if err != nil { + return nil + } + return &checkpoint } } } @@ -837,7 +766,7 @@ func (in *Inner) apply_optimistic_update(update *consensus_core.OptimisticUpdate } } func (in *Inner) Log_finality_update(update *consensus_core.FinalityUpdate) { - participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits[:])) / 512.0 * 100.0 + participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits)) / 512.0 * 100.0 decimals := 2 if participation == 100.0 { decimals = 1 @@ -855,7 +784,7 @@ func (in *Inner) Log_finality_update(update *consensus_core.FinalityUpdate) { ) } func (in *Inner) Log_optimistic_update(update *consensus_core.OptimisticUpdate) { - participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits[:])) / 512.0 * 100.0 + participation := float32(getBits(update.SyncAggregate.SyncCommitteeBits)) / 512.0 * 100.0 decimals := 2 if participation == 100.0 { decimals = 1 @@ -886,57 +815,38 @@ func (in *Inner) safety_threshold() uint64 { func verifySyncCommitteeSignature( pks []consensus_core.BLSPubKey, // Public keys slice attestedHeader *consensus_core.Header, // Attested header - signature *consensus_core.SyncAggregate, // Signature bytes + signature *consensus_core.SignatureBytes, // Signature bytes forkDataRoot consensus_core.Bytes32, // Fork data root ) bool { - - if signature == nil { - fmt.Println("no signature") - return false - } - - // Create a slice to hold the collected public keys. - collectedPks := make([]*bls.Pubkey, 0, len(pks)) + // Collect public keys as references (or suitable Go struct) + collectedPks := make([]*consensus_core.BLSPubKey, len(pks)) for i := range pks { - var pksinBytes [48]byte = [48]byte(pks[i]) - dkey := new(bls.Pubkey) - err := dkey.Deserialize(&pksinBytes) - if err != nil { - fmt.Println("error deserializing public key:", err) - return false - } - - // Include the public key only if the corresponding SyncCommitteeBits bit is set. - if signature.SyncCommitteeBits[i/8]&(byte(1)<<(i%8)) != 0 { - collectedPks = append(collectedPks, dkey) - } + collectedPks[i] = &pks[i] } - // Compute signingRoot. - signingRoot := ComputeCommitteeSignRoot(toGethHeader(attestedHeader), forkDataRoot) - - var sig bls.Signature - signatureForUnmarshalling := [96]byte(signature.SyncCommitteeSignature) - - // Deserialize the signature. - if err := sig.Deserialize(&signatureForUnmarshalling); err != nil { - fmt.Println("error deserializing signature:", err) + // Compute headerRoot + headerRoot, err := utils.TreeHashRoot(attestedHeader.ToBytes()) + if err != nil { return false } - - // Check if we have collected any public keys before proceeding. - if len(collectedPks) == 0 { - fmt.Println("no valid public keys collected") - return false + var headerRootBytes consensus_core.Bytes32 + copy(headerRootBytes[:], headerRoot[:]) + // Compute signingRoot + signingRoot := ComputeCommitteeSignRoot(headerRootBytes, forkDataRoot) + var g2Points []*bls.G2Point + for _, pk := range collectedPks { + var g2Point bls.G2Point + errWhileCoonvertingtoG2 := g2Point.Unmarshal(pk[:]) + + if errWhileCoonvertingtoG2 != nil { + return false + } } - - - return utils.FastAggregateVerify(collectedPks, signingRoot[:], &sig) - + return utils.IsAggregateValid(*signature, signingRoot, g2Points) } -func ComputeCommitteeSignRoot(header *beacon.Header, fork consensus_core.Bytes32) consensus_core.Bytes32 { +func ComputeCommitteeSignRoot(header consensus_core.Bytes32, fork consensus_core.Bytes32) consensus_core.Bytes32 { // Domain type for the sync committee domainType := [4]byte{7, 0, 0, 0} @@ -970,18 +880,27 @@ func (in *Inner) is_valid_checkpoint(blockHashSlot uint64) bool { } func isFinalityProofValid(attestedHeader *consensus_core.Header, finalizedHeader *consensus_core.Header, finalityBranch []consensus_core.Bytes32) bool { - - return utils.IsProofValid(attestedHeader, toGethHeader(finalizedHeader).Hash(), finalityBranch, 6, 105) + finalityBranchForProof, err := utils.BranchToNodes(finalityBranch) + if err != nil { + return false + } + return utils.IsProofValid(attestedHeader, finalizedHeader.ToBytes(), finalityBranchForProof, 6, 41) } func isCurrentCommitteeProofValid(attestedHeader *consensus_core.Header, currentCommittee *consensus_core.SyncCommittee, currentCommitteeBranch []consensus_core.Bytes32) bool { - - return utils.IsProofValid(attestedHeader, toGethSyncCommittee(currentCommittee).Root(), currentCommitteeBranch, 5, 54) + CurrentCommitteeForProof, err := utils.BranchToNodes(currentCommitteeBranch) + if err != nil { + return false + } + return utils.IsProofValid(attestedHeader, currentCommittee.ToBytes(), CurrentCommitteeForProof, 5, 22) } -func isNextCommitteeProofValid(attestedHeader *consensus_core.Header, nextCommittee *consensus_core.SyncCommittee, nextCommitteeBranch []consensus_core.Bytes32) bool { - - return utils.IsProofValid(attestedHeader, toGethSyncCommittee(nextCommittee).Root(), nextCommitteeBranch, 5, 55) +func isNextCommitteeProofValid(attestedHeader *consensus_core.Header, currentCommittee *consensus_core.SyncCommittee, currentCommitteeBranch []consensus_core.Bytes32) bool { + currentCommitteeBranchForProof, err := utils.BranchToNodes(currentCommitteeBranch) + if err != nil { + return false + } + return utils.IsProofValid(attestedHeader, currentCommittee.ToBytes(), currentCommitteeBranchForProof, 5, 23) } func PayloadToBlock(value *consensus_core.ExecutionPayload) (*common.Block, error) { @@ -1086,7 +1005,7 @@ func processTransaction(txBytes *[1073741824]byte, blockHash consensus_core.Byte } // getBits counts the number of bits set to 1 in a [64]byte array -func getBits(bitfield []byte) uint64 { +func getBits(bitfield [64]byte) uint64 { var count uint64 for _, b := range bitfield { count += uint64(popCount(b)) @@ -1143,36 +1062,3 @@ func SomeGasPrice(gasFeeCap, gasTipCap *big.Int, baseFeePerGas uint64) *big.Int } return maxGasPrice } - -func toGethHeader(header *consensus_core.Header) *beacon.Header { - return &beacon.Header{ - Slot: header.Slot, - ProposerIndex: header.ProposerIndex, - ParentRoot: [32]byte(header.ParentRoot), - StateRoot: [32]byte(header.StateRoot), - BodyRoot: [32]byte(header.BodyRoot), - } -} - -type jsonSyncCommittee struct { - Pubkeys []hexutil.Bytes - Aggregate hexutil.Bytes -} - -func toGethSyncCommittee(committee *consensus_core.SyncCommittee) *beacon.SerializedSyncCommittee { - jsoncommittee := &jsonSyncCommittee{ - Aggregate: committee.AggregatePubkey[:], - } - - for _, pubkey := range committee.Pubkeys { - jsoncommittee.Pubkeys = append(jsoncommittee.Pubkeys, pubkey[:]) - } - - var s beacon.SerializedSyncCommittee - - for i, key := range jsoncommittee.Pubkeys { - copy(s[i*48:], key[:]) - } -copy(s[512*48:], jsoncommittee.Aggregate[:]) - return &s -} diff --git a/consensus/consensus_core/consensus_core.go b/consensus/consensus_core/consensus_core.go index 3e8c661..aab009b 100644 --- a/consensus/consensus_core/consensus_core.go +++ b/consensus/consensus_core/consensus_core.go @@ -1,6 +1,12 @@ package consensus_core -type Transaction = [1073741824]byte +import ( + "bytes" + + "github.com/BlocSoc-iitr/selene/consensus/types" + "github.com/ugorji/go/codec" +) + type Bytes32 [32]byte type BLSPubKey [48]byte type Address [20]byte @@ -8,198 +14,196 @@ type LogsBloom [256]byte type SignatureBytes [96]byte type BeaconBlock struct { - Slot uint64 `json:"slot"` - ProposerIndex uint64 `json:"proposer_index"` - ParentRoot Bytes32 `json:"parent_root"` - StateRoot Bytes32 `json:"state_root"` - Body BeaconBlockBody `json:"body"` + Slot uint64 + ProposerIndex uint64 + ParentRoot Bytes32 + StateRoot Bytes32 + Body BeaconBlockBody } type Eth1Data struct { - DepositRoot Bytes32 `json:"deposit_root"` - DepositCount uint64 `json:"deposit_count"` - BlockHash Bytes32 `json:"block_hash"` + DepositRoot Bytes32 + DepositCount uint64 + BlockHash Bytes32 } type ProposerSlashing struct { - SignedHeader1 SignedBeaconBlockHeader `json:"signed_header_1"` - SignedHeader2 SignedBeaconBlockHeader `json:"signed_header_2"` + SignedHeader1 SignedBeaconBlockHeader + SignedHeader2 SignedBeaconBlockHeader } type SignedBeaconBlockHeader struct { - Message BeaconBlockHeader `json:"message"` - Signature SignatureBytes `json:"signature"` + Message BeaconBlockHeader + Signature SignatureBytes } type BeaconBlockHeader struct { - Slot uint64 `json:"slot"` - ProposerIndex uint64 `json:"proposer_index"` - ParentRoot Bytes32 `json:"parent_root"` - StateRoot Bytes32 `json:"state_root"` - BodyRoot Bytes32 `json:"body_root"` + Slot uint64 + ProposerIndex uint64 + ParentRoot Bytes32 + StateRoot Bytes32 + BodyRoot Bytes32 } type AttesterSlashing struct { - Attestation1 IndexedAttestation `json:"attestation_1"` - Attestation2 IndexedAttestation `json:"attestation_2"` + Attestation1 IndexedAttestation + Attestation2 IndexedAttestation } type IndexedAttestation struct { - AttestingIndices [2048]uint64 `json:"attesting_indices"` // Dynamic slice - Data AttestationData `json:"data"` - Signature SignatureBytes `json:"signature"` + AttestingIndices [2048]uint64 + Data AttestationData + Signature SignatureBytes } type AttestationData struct { - Slot uint64 `json:"slot"` - Index uint64 `json:"index"` - BeaconBlockRoot Bytes32 `json:"beacon_block_root"` - Source Checkpoint `json:"source"` - Target Checkpoint `json:"target"` + Slot uint64 + Index uint64 + BeaconBlockRoot Bytes32 + Source Checkpoint + Target Checkpoint } type Checkpoint struct { - Epoch uint64 `json:"epoch"` - Root Bytes32 `json:"root"` + Epoch uint64 + Root Bytes32 } type Bitlist []bool type Attestation struct { - AggregationBits Bitlist `json:"aggregation_bits"` - Data AttestationData `json:"data"` - Signature SignatureBytes `json:"signature"` + AggregationBits Bitlist `ssz-max:"2048"` + Data AttestationData + Signature SignatureBytes } type Deposit struct { - Proof [33]Bytes32 `json:"proof"` // Dynamic slice - Data DepositData `json:"data"` + Proof [33]Bytes32 // fixed size array + Data DepositData } type DepositData struct { - Pubkey BLSPubKey `json:"pubkey"` - WithdrawalCredentials Bytes32 `json:"withdrawal_credentials"` - Amount uint64 `json:"amount"` - Signature SignatureBytes `json:"signature"` + Pubkey [48]byte + WithdrawalCredentials Bytes32 + Amount uint64 + Signature SignatureBytes } type SignedVoluntaryExit struct { - Message VoluntaryExit `json:"message"` - Signature SignatureBytes `json:"signature"` + Message VoluntaryExit + Signature SignatureBytes } type VoluntaryExit struct { - Epoch uint64 `json:"epoch"` - ValidatorIndex uint64 `json:"validator_index"` + Epoch uint64 + ValidatorIndex uint64 } type SyncAggregate struct { - SyncCommitteeBits []byte `json:"sync_committee_bits"` - SyncCommitteeSignature SignatureBytes `json:"sync_committee_signature"` + SyncCommitteeBits [64]byte + SyncCommitteeSignature SignatureBytes } type Withdrawal struct { - Index uint64 `json:"index"` - ValidatorIndex uint64 `json:"validator_index"` - Address Address `json:"address"` - Amount uint64 `json:"amount"` + Index uint64 + ValidatorIndex uint64 + Address Address + Amount uint64 } type ExecutionPayload struct { - ParentHash Bytes32 `json:"parent_hash"` - FeeRecipient Address `json:"fee_recipient"` - StateRoot Bytes32 `json:"state_root"` - ReceiptsRoot Bytes32 `json:"receipts_root"` - LogsBloom LogsBloom `json:"logs_bloom"` - PrevRandao Bytes32 `json:"prev_randao"` - BlockNumber uint64 `json:"block_number"` - GasLimit uint64 `json:"gas_limit"` - GasUsed uint64 `json:"gas_used"` - Timestamp uint64 `json:"timestamp"` - ExtraData []byte `json:"extra_data"` - BaseFeePerGas uint64 `json:"base_fee_per_gas"` - BlockHash Bytes32 `json:"block_hash"` - Transactions []Transaction `json:"transactions"` - Withdrawals *[]Withdrawal `json:"withdrawals"` //Only capella and deneb - BlobGasUsed *uint64 `json:"blob_gas_used"` // Only deneb - ExcessBlobGas *uint64 `json:"excess_blob_gas"` // Only deneb + ParentHash Bytes32 + FeeRecipient Address + StateRoot Bytes32 + ReceiptsRoot Bytes32 + LogsBloom LogsBloom + PrevRandao Bytes32 + BlockNumber uint64 + GasLimit uint64 + GasUsed uint64 + Timestamp uint64 + ExtraData [32]byte + BaseFeePerGas uint64 + BlockHash Bytes32 + Transactions []types.Transaction `ssz-max:"1048576"` + Withdrawals []types.Withdrawal `ssz-max:"16"` + BlobGasUsed *uint64 // Deneb-specific field, use pointer for optionality + ExcessBlobGas *uint64 // Deneb-specific field, use pointer for optionality } type SignedBlsToExecutionChange struct { - Message BlsToExecutionChange `json:"message"` - Signature SignatureBytes `json:"signature"` + Message BlsToExecutionChange + Signature SignatureBytes } type BlsToExecutionChange struct { - ValidatorIndex uint64 `json:"validator_index"` - FromBlsPubkey BLSPubKey `json:"from_bls_pubkey"` + ValidatorIndex uint64 + FromBlsPubkey [48]byte } // BeaconBlockBody represents the body of a beacon block. type BeaconBlockBody struct { - RandaoReveal SignatureBytes `json:"randao_reveal"` - Eth1Data Eth1Data `json:"eth1_data"` - Graffiti Bytes32 `json:"graffiti"` - ProposerSlashings []ProposerSlashing `json:"proposer_slashings"` - AttesterSlashings []AttesterSlashing `json:"attester_slashings"` - Attestations []Attestation `json:"attestations"` - Deposits []Deposit `json:"deposits"` - VoluntaryExits []SignedVoluntaryExit `json:"voluntary_exits"` - SyncAggregate SyncAggregate `json:"sync_aggregate"` - ExecutionPayload ExecutionPayload `json:"execution_payload"` - BlsToExecutionChanges *[]SignedBlsToExecutionChange `json:"bls_to_execution_changes"` //Only capella and deneb - BlobKzgCommitments *[][]byte `json:"blob_kzg_commitments"` // Dynamic slice - Hash []byte + RandaoReveal SignatureBytes + Eth1Data Eth1Data + Graffiti Bytes32 + ProposerSlashings []ProposerSlashing `ssz-max:"16"` + AttesterSlashings []AttesterSlashing `ssz-max:"2"` + Attestations []Attestation `ssz-max:"128"` + Deposits []Deposit `ssz-max:"16"` + VoluntaryExits []SignedVoluntaryExit `ssz-max:"16"` + SyncAggregate SyncAggregate + ExecutionPayload ExecutionPayload + BlsToExecutionChanges []SignedBlsToExecutionChange `ssz-max:"16"` + BlobKzgCommitments [][48]byte `ssz-max:"4096"` } type Header struct { - Slot uint64 `json:"slot"` - ProposerIndex uint64 `json:"proposer_index"` - ParentRoot Bytes32 `json:"parent_root"` - StateRoot Bytes32 `json:"state_root"` - BodyRoot Bytes32 `json:"body_root"` + Slot uint64 + ProposerIndex uint64 + ParentRoot Bytes32 + StateRoot Bytes32 + BodyRoot Bytes32 } type SyncCommittee struct { - Pubkeys []BLSPubKey `json:"pubkeys"` - AggregatePubkey BLSPubKey `json:"aggregate_pubkey"` + Pubkeys [512]BLSPubKey + AggregatePubkey BLSPubKey } type Update struct { - AttestedHeader Header `json:"attested_header"` - NextSyncCommittee SyncCommittee `json:"next_sync_committee"` - NextSyncCommitteeBranch []Bytes32 `json:"next_sync_committee_branch"` - FinalizedHeader Header `json:"finalized_header"` - FinalityBranch []Bytes32 `json:"finality_branch"` - SyncAggregate SyncAggregate `json:"sync_aggregate"` - SignatureSlot uint64 `json:"signature_slot"` + AttestedHeader Header + NextSyncCommittee SyncCommittee + NextSyncCommitteeBranch []Bytes32 + FinalizedHeader Header + FinalityBranch []Bytes32 + SyncAggregate SyncAggregate + SignatureSlot uint64 } type FinalityUpdate struct { - AttestedHeader Header `json:"attested_header"` - FinalizedHeader Header `json:"finalized_header"` - FinalityBranch []Bytes32 `json:"finality_branch"` - SyncAggregate SyncAggregate `json:"sync_aggregate"` - SignatureSlot uint64 `json:"signature_slot"` + AttestedHeader Header + FinalizedHeader Header + FinalityBranch []Bytes32 + SyncAggregate SyncAggregate + SignatureSlot uint64 } type OptimisticUpdate struct { - AttestedHeader Header `json:"attested_header"` - SyncAggregate SyncAggregate `json:"sync_aggregate"` - SignatureSlot uint64 `json:"signature_slot"` + AttestedHeader Header + SyncAggregate SyncAggregate + SignatureSlot uint64 } type Bootstrap struct { - Header Header `json:"header"` - CurrentSyncCommittee SyncCommittee `json:"current_sync_committee"` - CurrentSyncCommitteeBranch []Bytes32 `json:"current_sync_committee_branch"` + Header Header + CurrentSyncCommittee SyncCommittee + CurrentSyncCommitteeBranch []Bytes32 } type Fork struct { Epoch uint64 `json:"epoch"` ForkVersion []byte `json:"fork_version"` } - type Forks struct { Genesis Fork `json:"genesis"` Altair Fork `json:"altair"` @@ -207,3 +211,26 @@ type Forks struct { Capella Fork `json:"capella"` Deneb Fork `json:"deneb"` } + +// ToBytes serializes the Header struct to a byte slice. +func (h *Header) ToBytes() []byte { + var buf bytes.Buffer + enc := codec.NewEncoder(&buf, new(codec.JsonHandle)) + _ = enc.Encode(h) // Ignore error + return buf.Bytes() +} + +func (b *BeaconBlockBody) ToBytes() []byte { + var buf bytes.Buffer + enc := codec.NewEncoder(&buf, new(codec.JsonHandle)) + _ = enc.Encode(b) // Ignore error + return buf.Bytes() +} + +// ToBytes serializes the SyncCommittee struct to a byte slice. +func (sc *SyncCommittee) ToBytes() []byte { + var buf bytes.Buffer + enc := codec.NewEncoder(&buf, new(codec.JsonHandle)) + _ = enc.Encode(sc) // Ignore error + return buf.Bytes() +} diff --git a/consensus/consensus_core/serde_utils.go b/consensus/consensus_core/serde_utils.go deleted file mode 100644 index 14a5a1c..0000000 --- a/consensus/consensus_core/serde_utils.go +++ /dev/null @@ -1,372 +0,0 @@ -package consensus_core - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "reflect" - "strconv" - "strings" - - "github.com/ethereum/go-ethereum/common" -) - -func (f *FinalityUpdate) UnmarshalJSON(data []byte) error { - return unmarshalJSON(data, f) -} - -func (o *OptimisticUpdate) UnmarshalJSON(data []byte) error { - return unmarshalJSON(data, o) -} - -func (b *Bootstrap) UnmarshalJSON(data []byte) error { - return unmarshalJSON(data, b) -} - - - -func (f *Forks) UnmarshalJSON(data []byte) error { - var serialized map[string]interface{} - if err := json.Unmarshal(data, &serialized); err != nil { - return fmt.Errorf("error unmarshalling into map: %w", err) - } - - v := reflect.ValueOf(f).Elem() - t := v.Type() - - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - fieldType := t.Field(i) - fieldName := fieldType.Tag.Get("json") - if fieldName == "" { - fieldName = snakeCase(fieldType.Name) - } - - if forkData, ok := serialized[fieldName]; ok { - forkJSON, err := json.Marshal(forkData) - if err != nil { - return fmt.Errorf("error marshalling %s: %w", fieldName, err) - } - if err := json.Unmarshal(forkJSON, field.Addr().Interface()); err != nil { - return fmt.Errorf("error unmarshalling %s: %w", fieldName, err) - } - } - } - - return nil -} - -func (h *Header) UnmarshalJSON(data []byte) error { - // Define a temporary map to hold JSON data - var serialized map[string]interface{} - if err := json.Unmarshal(data, &serialized); err != nil { - return fmt.Errorf("error unmarshalling into map: %w", err) - } - - // Extract the "beacon" field from the serialized map - beaconData, ok := serialized["beacon"].(map[string]interface{}) - if !ok { - return fmt.Errorf("beacon field missing or invalid") - } - - v := reflect.ValueOf(h).Elem() - t := v.Type() - - // Iterate through each field of the Header struct using reflection - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - fieldType := t.Field(i) - jsonTag := fieldType.Tag.Get("json") - - // Convert the struct field name or its json tag to snake_case for matching - fieldName := jsonTag - if fieldName == "" { - fieldName = snakeCase(fieldType.Name) - } - - if value, ok := beaconData[fieldName]; ok { - switch field.Interface().(type) { - case uint64: - val, err := Str_to_uint64(value.(string)) - if err != nil { - continue - } - field.Set(reflect.ValueOf(val)) - case Bytes32: - val, err := Hex_str_to_Bytes32(value.(string)) - if err != nil { - continue - } - field.Set(reflect.ValueOf(val)) - } - } else { - continue - } - } - - return nil -} - -func (s *SyncAggregate) UnmarshalJSON(data []byte) error { - // Define a temporary map to hold JSON data - var serialized map[string]string - if err := json.Unmarshal(data, &serialized); err != nil { - return fmt.Errorf("error unmarshalling into map: %w", err) - } - - v := reflect.ValueOf(s).Elem() - t := v.Type() - - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - fieldName := t.Field(i).Name - snakeFieldName := snakeCase(fieldName) - - switch snakeFieldName { - case "sync_committee_bits": - if bits, ok := serialized[snakeFieldName]; ok { - decodedBits := hexDecode(bits) - if decodedBits == nil { - return fmt.Errorf("error decoding sync_committee_bits") - } - field.SetBytes(decodedBits) - } else { - return fmt.Errorf("%s field missing or invalid", snakeFieldName) - } - case "sync_committee_signature": - if signature, ok := serialized[snakeFieldName]; ok { - decodedSignature := hexDecode(signature) - if decodedSignature == nil { - return fmt.Errorf("error decoding sync_committee_signature") - } - if len(decodedSignature) != len(s.SyncCommitteeSignature) { - return fmt.Errorf("decoded sync_committee_signature length mismatch") - } - copy(s.SyncCommitteeSignature[:], decodedSignature) - } else { - return fmt.Errorf("%s field missing or invalid", snakeFieldName) - } - default: - return fmt.Errorf("unsupported field %s", fieldName) - } - } - - return nil -} - -func (s *SyncCommittee) UnmarshalJSON(data []byte) error { - var serialized map[string]interface{} - if err := json.Unmarshal(data, &serialized); err != nil { - return fmt.Errorf("error unmarshalling into map: %w", err) - } - - v := reflect.ValueOf(s).Elem() - t := v.Type() - - for i := 0; i < v.NumField(); i++ { - fieldName := t.Field(i).Name - snakeFieldName := snakeCase(fieldName) - - switch snakeFieldName { - case "pubkeys": - if pubkeys, ok := serialized[snakeFieldName].([]interface{}); ok { - s.Pubkeys = make([]BLSPubKey, len(pubkeys)) - for j, pubkey := range pubkeys { - if pubkeyStr, ok := pubkey.(string); ok { - decoded := hexDecode(pubkeyStr) - if decoded == nil { - return fmt.Errorf("error decoding pubkey at index %d", j) - } - s.Pubkeys[j] = BLSPubKey(decoded) - } else { - return fmt.Errorf("invalid pubkey format at index %d", j) - } - } - } else { - return fmt.Errorf("%s field missing or invalid", snakeFieldName) - } - case "aggregate_pubkey": - if aggPubkey, ok := serialized[snakeFieldName].(string); ok { - decoded := hexDecode(aggPubkey) - if decoded == nil { - return fmt.Errorf("error decoding aggregate pubkey") - } - s.AggregatePubkey = BLSPubKey(decoded) - } else { - return fmt.Errorf("%s field missing or invalid", snakeFieldName) - } - default: - return fmt.Errorf("unsupported field %s", fieldName) - } - } - - return nil -} - -func (u *Update) UnmarshalJSON(data []byte) error { - return unmarshalJSON(data, u) -} - -func unmarshalJSON(data []byte, v interface{}) error { - var serialized map[string]interface{} - if err := json.Unmarshal(data, &serialized); err != nil { - return fmt.Errorf("error unmarshalling into map: %w", err) - } - - // Get the value of the struct using reflection - value := reflect.ValueOf(v).Elem() - typeOfValue := value.Type() - - for i := 0; i < value.NumField(); i++ { - field := value.Field(i) - fieldType := typeOfValue.Field(i) - jsonTag := fieldType.Tag.Get("json") - - // Convert the struct field name or its json tag to snake_case for matching - fieldName := jsonTag - if fieldName == "" { - fieldName = snakeCase(fieldType.Name) - } - - if rawValue, ok := serialized[fieldName]; ok { - if err := setFieldValue(field, rawValue); err != nil { - return fmt.Errorf("error setting field %s: %w", fieldName, err) - } - } - } - return nil -} - -func (b *BeaconBlock) UnmarshalJSON(data []byte) error { - // Define a temporary structure to handle both string and number slots. - var tmp struct { - Slot json.RawMessage `json:"slot"` - } - - // Unmarshal into the temporary struct. - if err := json.Unmarshal(data, &tmp); err != nil { - return fmt.Errorf("error unmarshalling into temporary struct: %w", err) - } - - // If it wasn't a string, try unmarshalling as a number. - var slotNum uint64 - if err := json.Unmarshal(tmp.Slot, &slotNum); err == nil { - b.Slot = slotNum - return nil - } - - return fmt.Errorf("slot field is not a valid string or number") -} - -func setFieldValue(field reflect.Value, value interface{}) error { - switch field.Kind() { - case reflect.Struct: - // Marshal and unmarshal for struct types - rawJSON, err := json.Marshal(value) - if err != nil { - return err - } - return json.Unmarshal(rawJSON, field.Addr().Interface()) - - case reflect.Slice: - if field.Type().Elem().Kind() == reflect.Uint8 { - // For Bytes32 conversion - dataSlice := value.([]interface{}) - for _, b := range dataSlice { - field.Set(reflect.Append(field, reflect.ValueOf(Bytes32(hexDecode(b.(string)))))) // Adjust hexDecode as needed - } - return nil - } - // For other slice types, marshal and unmarshal - rawJSON, err := json.Marshal(value) - if err != nil { - return err - } - return json.Unmarshal(rawJSON, field.Addr().Interface()) - - case reflect.String: - field.SetString(value.(string)) - case reflect.Uint64: - val, err := Str_to_uint64(value.(string)) - if err != nil { - return err - } - field.SetUint(val) - default: - return fmt.Errorf("unsupported field type: %s", field.Type()) - } - return nil -} - - - - -// if we need to export the functions , just make their first letter capitalised -func Hex_str_to_bytes(s string) ([]byte, error) { - s = strings.TrimPrefix(s, "0x") - - bytesArray, err := hex.DecodeString(s) - - if err != nil { - return nil, err - } - - return bytesArray, nil -} - -func Hex_str_to_Bytes32(s string) (Bytes32, error) { - bytesArray, err := Hex_str_to_bytes(s) - if err != nil { - return Bytes32{}, err - } - - var bytes32 Bytes32 - copy(bytes32[:], bytesArray) - return bytes32, nil -} - -func Address_to_hex_string(addr common.Address) string { - bytesArray := addr.Bytes() - return fmt.Sprintf("0x%x", hex.EncodeToString(bytesArray)) -} - -func U64_to_hex_string(val uint64) string { - return fmt.Sprintf("0x%x", val) -} - -func Str_to_uint64(s string) (uint64, error) { - num, err := strconv.ParseUint(s, 10, 64) - if err != nil { - return 0, err - } - return num, nil -} - -// snakeCase converts CamelCase strings to snake_case (e.g., "ParentRoot" to "parent_root"). -func snakeCase(input string) string { - var result []rune - for i, r := range input { - if i > 0 && r >= 'A' && r <= 'Z' { - result = append(result, '_') - } - result = append(result, r) - } - return strings.ToLower(string(result)) -} - -// hexDecode is a utility function to decode hex strings to byte slices. -func hexDecode(input string) []byte { - data, _ := Hex_str_to_bytes(input) - return data -} - -func (b *Bytes32) UnmarshalJSON(data []byte) error { - var hexString string - if err := json.Unmarshal(data, &hexString); err != nil { - return err - } - - copy(b[:], hexDecode(hexString)[:]) - - return nil -} diff --git a/consensus/consensus_test.go b/consensus/consensus_test.go deleted file mode 100644 index 1de1620..0000000 --- a/consensus/consensus_test.go +++ /dev/null @@ -1,312 +0,0 @@ -package consensus - -import ( - "encoding/hex" - "log" - "testing" - - "github.com/BlocSoc-iitr/selene/common" - "github.com/BlocSoc-iitr/selene/config" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - "github.com/BlocSoc-iitr/selene/utils" -) - -func GetClient(strictCheckpointAge bool, sync bool) (*Inner, error) { - var n config.Network - baseConfig, err := n.BaseConfig("MAINNET") - if err != nil { - return nil, err - } - - config := &config.Config{ - ConsensusRpc: "", - ExecutionRpc: "", - Chain: baseConfig.Chain, - Forks: baseConfig.Forks, - StrictCheckpointAge: strictCheckpointAge, - } - - checkpoint := "5afc212a7924789b2bc86acad3ab3a6ffb1f6e97253ea50bee7f4f51422c9275" - - //Decode the hex string into a byte slice - checkpointBytes, err := hex.DecodeString(checkpoint) - checkpointBytes32 := [32]byte{} - copy(checkpointBytes32[:], checkpointBytes) - if err != nil { - log.Fatalf("failed to decode checkpoint: %v", err) - } - - blockSend := make(chan common.Block, 256) - finalizedBlockSend := make(chan *common.Block) - channelSend := make(chan *[]byte) - - In := Inner{} - client := In.New( - "testdata/", - blockSend, - finalizedBlockSend, - channelSend, - config, - ) - - if sync { - err := client.sync(checkpointBytes32) - if err != nil { - return nil, err - } - } else { - client.bootstrap(checkpointBytes32) - } - - return client, nil -} - -// testVerifyUpdate runs the test and returns its result via a channel (no inputs required). -func TestVerifyUpdate(t *testing.T) { - //Get the client - client, err := GetClient(false, false) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - //Calculate the sync period - period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) - - //Fetch updates - updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) - if err != nil { - t.Fatalf("failed to get updates: %v", err) - } - - //Ensure we have updates to verify - if len(updates) == 0 { - t.Fatalf("no updates fetched") - } - - //Verify the first update - update := updates[0] - err = client.verify_update(&update) - if err != nil { - t.Fatalf("failed to verify update: %v", err) - } - -} - -func TestVerifyUpdateInvalidCommittee(t *testing.T) { - client, err := GetClient(false, false) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) - updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) - if err != nil { - t.Fatalf("failed to get updates: %v", err) - } - - if len(updates) == 0 { - t.Fatalf("no updates fetched") - } - - update := updates[0] - update.NextSyncCommittee.Pubkeys[0] = consensus_core.BLSPubKey{} // Invalid public key - - err = client.verify_update(&update) - if err == nil || err.Error() != "invalid next sync committee proof" { - t.Fatalf("expected 'invalid next sync committee proof', got %v", err) - } -} - -func TestVerifyUpdateInvalidFinality(t *testing.T) { - client, err := GetClient(false, false) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) - updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) - if err != nil { - t.Fatalf("failed to get updates: %v", err) - } - - if len(updates) == 0 { - t.Fatalf("no updates fetched") - } - - update := updates[0] - update.FinalizedHeader = consensus_core.Header{} // Assuming an empty header is invalid - - err = client.verify_update(&update) - if err == nil || err.Error() != "invalid finality proof" { - t.Fatalf("expected 'invalid finality proof', got %v", err) - } -} - -func TestVerifyUpdateInvalidSig(t *testing.T) { - client, err := GetClient(false, false) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - period := utils.CalcSyncPeriod(client.Store.FinalizedHeader.Slot) - updates, err := client.RPC.GetUpdates(period, MAX_REQUEST_LIGHT_CLIENT_UPDATES) - if err != nil { - t.Fatalf("failed to get updates: %v", err) - } - - if len(updates) == 0 { - t.Fatalf("no updates fetched") - } - - update := updates[0] - update.SyncAggregate.SyncCommitteeSignature = consensus_core.SignatureBytes{} // Assuming an empty signature is invalid - - err = client.verify_update(&update) - if err == nil || err.Error() != "invalid signature" { - t.Fatalf("expected 'invalid signature', got %v", err) - } -} - -func TestVerifyFinality(t *testing.T) { - //Get the client - client, err := GetClient(false, true) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - //Fetch the finality update - update, err := client.RPC.GetFinalityUpdate() - if err != nil { - t.Fatalf("failed to get finality update: %v", err) - } - - //Verify the finality update - err = client.verify_finality_update(&update) - if err != nil { - t.Fatalf("finality verification failed: %v", err) - } -} - -func TestVerifyFinalityInvalidFinality(t *testing.T) { - //Get the client - client, err := GetClient(false, true) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - //Fetch the finality update - update, err := client.RPC.GetFinalityUpdate() - if err != nil { - t.Fatalf("failed to get finality update: %v", err) - } - - //Modify the finalized header to be invalid - update.FinalizedHeader = consensus_core.Header{} //Assuming an empty header is invalid - - //Verify the finality update and expect an error - err = client.verify_finality_update(&update) - if err == nil { - t.Fatalf("expected error, got nil") - } - - //Check if the error matches the expected error message - expectedErr := "invalid finality proof" - if err.Error() != expectedErr { - t.Errorf("expected %s, got %v", expectedErr, err) - } -} - -func TestVerifyFinalityInvalidSignature(t *testing.T) { - //Get the client - client, err := GetClient(false, true) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - //Fetch the finality update - update, err := client.RPC.GetFinalityUpdate() - if err != nil { - t.Fatalf("failed to get finality update: %v", err) - } - - //Modify the sync aggregate signature to be invalid - update.SyncAggregate.SyncCommitteeSignature = consensus_core.SignatureBytes{} //Assuming an empty signature is invalid - - //Verify the finality update and expect an error - err = client.verify_finality_update(&update) - if err == nil { - t.Fatalf("expected error, got nil") - } - - //Check if the error matches the expected error message - expectedErr := "invalid signature" - if err.Error() != expectedErr { - t.Errorf("expected %s, got %v", expectedErr, err) - } -} - -func TestVerifyOptimistic(t *testing.T) { - //Get the client - client, err := GetClient(false, true) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - //Fetch the optimistic update - update, err := client.RPC.GetOptimisticUpdate() - if err != nil { - t.Fatalf("failed to get optimistic update: %v", err) - } - - //Verify the optimistic update - err = client.verify_optimistic_update(&update) - if err != nil { - t.Fatalf("optimistic verification failed: %v", err) - } -} -func TestVerifyOptimisticInvalidSignature(t *testing.T) { - //Get the client - client, err := GetClient(false, true) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } - - //Fetch the optimistic update - update, err := client.RPC.GetOptimisticUpdate() - if err != nil { - t.Fatalf("failed to get optimistic update: %v", err) - } - - //Modify the sync aggregate signature to be invalid - update.SyncAggregate.SyncCommitteeSignature = consensus_core.SignatureBytes{} //Assuming an empty signature is invalid - - //Verify the optimistic update and expect an error - err = client.verify_optimistic_update(&update) - if err == nil { - t.Fatalf("expected error, got nil") - } - - //Check if the error matches the expected error message - expectedErr := "invalid signature" - if err.Error() != expectedErr { - t.Errorf("expected %s, got %v", expectedErr, err) - } -} -func TestVerifyCheckpointAgeInvalid(t *testing.T) { - defer func() { - if r := recover(); r == nil { - t.Fatalf("expected panic due to invalid checkpoint age, but no panic occurred") - } else { - expectedPanicMessage := "checkpoint too old, consider using a more recent checkpoint" - if msg, ok := r.(string); ok && msg != expectedPanicMessage { - t.Errorf("expected panic message '%s', got '%s'", expectedPanicMessage, msg) - } - } - }() - - // This should trigger a panic due to the invalid checkpoint age - _, err := GetClient(true, false) - if err != nil { - t.Fatalf("failed to get client: %v", err) - } -} diff --git a/consensus/database.go b/consensus/database.go index abdc234..77993a8 100644 --- a/consensus/database.go +++ b/consensus/database.go @@ -1,12 +1,10 @@ package consensus - import ( "errors" "github.com/BlocSoc-iitr/selene/config" "os" "path/filepath" ) - type Database interface { New(cfg *config.Config) (Database, error) SaveCheckpoint(checkpoint []byte) error @@ -16,7 +14,6 @@ type FileDB struct { DataDir string defaultCheckpoint [32]byte } - func (f *FileDB) New(cfg *config.Config) (Database, error) { if cfg.DataDir == nil || *cfg.DataDir == "" { return nil, errors.New("data directory is not set in the config") @@ -46,11 +43,9 @@ func (f *FileDB) LoadCheckpoint() ([]byte, error) { } return f.defaultCheckpoint[:], nil } - type ConfigDB struct { checkpoint [32]byte } - func (c *ConfigDB) New(cfg *config.Config) (Database, error) { checkpoint := cfg.DefaultCheckpoint if cfg.DataDir == nil { diff --git a/consensus/rpc/consensus_rpc.go b/consensus/rpc/consensus_rpc.go index 9dafef3..22dc00e 100644 --- a/consensus/rpc/consensus_rpc.go +++ b/consensus/rpc/consensus_rpc.go @@ -15,9 +15,5 @@ type ConsensusRpc interface { } func NewConsensusRpc(rpc string) ConsensusRpc { - if rpc == "testdata/" { - return NewMockRpc(rpc) - } else { - return NewNimbusRpc(rpc) - } + return NewNimbusRpc(rpc) } diff --git a/consensus/rpc/consensus_rpc_test.go b/consensus/rpc/consensus_rpc_test.go index e390e58..14a3617 100644 --- a/consensus/rpc/consensus_rpc_test.go +++ b/consensus/rpc/consensus_rpc_test.go @@ -1,17 +1,14 @@ package rpc - import ( + "testing" "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "testing" ) - // MockConsensusRpc is a mock implementation of the ConsensusRpc interface type MockConsensusRpc struct { mock.Mock } - func (m *MockConsensusRpc) GetBootstrap(block_root [32]byte) (consensus_core.Bootstrap, error) { args := m.Called(block_root) return args.Get(0).(consensus_core.Bootstrap), args.Error(1) @@ -63,7 +60,7 @@ func TestConsensusRpcInterface(t *testing.T) { mockRpc.On("GetFinalityUpdate").Return(mockFinalityUpdate, nil) finalityUpdate, err := mockRpc.GetFinalityUpdate() assert.NoError(t, err) - assert.Equal(t, uint64(3000), finalityUpdate.FinalizedHeader.Slot) + assert.Equal(t, uint64(3000), finalityUpdate.FinalizedHeader.Slot) // Test GetOptimisticUpdate mockOptimisticUpdate := consensus_core.OptimisticUpdate{SignatureSlot: 4000} mockRpc.On("GetOptimisticUpdate").Return(mockOptimisticUpdate, nil) @@ -84,4 +81,4 @@ func TestConsensusRpcInterface(t *testing.T) { assert.Equal(t, uint64(1), chainId) // Assert that all expected mock calls were made mockRpc.AssertExpectations(t) -} +} \ No newline at end of file diff --git a/consensus/rpc/mock_rpc.go b/consensus/rpc/mock_rpc.go index 332a23b..971f381 100644 --- a/consensus/rpc/mock_rpc.go +++ b/consensus/rpc/mock_rpc.go @@ -13,85 +13,79 @@ import ( type MockRpc struct { testdata string } - func NewMockRpc(path string) *MockRpc { return &MockRpc{ testdata: path, } } -func (m *MockRpc) GetBootstrap(block_root [32]byte) (consensus_core.Bootstrap, error) { +func (m *MockRpc) GetBootstrap(block_root []byte) (*consensus_core.Bootstrap, error) { path := filepath.Join(m.testdata, "bootstrap.json") res, err := os.ReadFile(path) if err != nil { - return consensus_core.Bootstrap{}, fmt.Errorf("failed to read file: %w", err) + return nil, fmt.Errorf("failed to read file: %w", err) } var bootstrap BootstrapResponse err = json.Unmarshal(res, &bootstrap) if err != nil { - return consensus_core.Bootstrap{}, fmt.Errorf("bootstrap error: %w", err) + return &consensus_core.Bootstrap{}, fmt.Errorf("bootstrap error: %w", err) } - return bootstrap.Data, nil + return &bootstrap.Data, nil } func (m *MockRpc) GetUpdates(period uint64, count uint8) ([]consensus_core.Update, error) { path := filepath.Join(m.testdata, "updates.json") res, err := os.ReadFile(path) - if err != nil { return nil, fmt.Errorf("failed to read file: %w", err) } var updatesResponse UpdateResponse - err = json.Unmarshal(res, &updatesResponse) if err != nil { return nil, fmt.Errorf("updates error: %w", err) } - - var updates = make([]consensus_core.Update, len(updatesResponse)) + updates := make([]consensus_core.Update, len(updatesResponse)) for i, update := range updatesResponse { updates[i] = update.Data } - - //fmt.Print("Data", updates) return updates, nil } -func (m *MockRpc) GetFinalityUpdate() (consensus_core.FinalityUpdate, error) { +func (m *MockRpc) GetFinalityUpdate() (*consensus_core.FinalityUpdate, error) { path := filepath.Join(m.testdata, "finality.json") res, err := os.ReadFile(path) if err != nil { - return consensus_core.FinalityUpdate{}, fmt.Errorf("failed to read file: %w", err) + return nil, fmt.Errorf("failed to read file: %w", err) } var finality FinalityUpdateResponse err = json.Unmarshal(res, &finality) if err != nil { - return consensus_core.FinalityUpdate{}, fmt.Errorf("finality update error: %w", err) + return &consensus_core.FinalityUpdate{}, fmt.Errorf("finality update error: %w", err) } - return finality.Data, nil + return &finality.Data, nil } -func (m *MockRpc) GetOptimisticUpdate() (consensus_core.OptimisticUpdate, error) { +func (m *MockRpc) GetOptimisticUpdate() (*consensus_core.OptimisticUpdate, error) { path := filepath.Join(m.testdata, "optimistic.json") res, err := os.ReadFile(path) if err != nil { - return consensus_core.OptimisticUpdate{}, fmt.Errorf("failed to read file: %w", err) + return nil, fmt.Errorf("failed to read file: %w", err) } var optimistic OptimisticUpdateResponse err = json.Unmarshal(res, &optimistic) if err != nil { - return consensus_core.OptimisticUpdate{}, fmt.Errorf("optimistic update error: %w", err) + return &consensus_core.OptimisticUpdate{}, fmt.Errorf("optimistic update error: %w", err) } - return optimistic.Data, nil + return &optimistic.Data, nil } -func (m *MockRpc) GetBlock(slot uint64) (consensus_core.BeaconBlock, error) { +func (m *MockRpc) GetBlock(slot uint64) (*consensus_core.BeaconBlock, error) { path := filepath.Join(m.testdata, fmt.Sprintf("blocks/%d.json", slot)) res, err := os.ReadFile(path) if err != nil { - return consensus_core.BeaconBlock{}, fmt.Errorf("failed to read file: %w", err) + return nil, fmt.Errorf("failed to read file: %w", err) } var block BeaconBlockResponse err = json.Unmarshal(res, &block) if err != nil { - return consensus_core.BeaconBlock{}, err + return nil, err } - return block.Data.Message, nil + return &block.Data.Message, nil } func (m *MockRpc) ChainId() (uint64, error) { return 0, fmt.Errorf("not implemented") diff --git a/consensus/rpc/mock_rpc_test.go b/consensus/rpc/mock_rpc_test.go index 75134d0..b371a54 100644 --- a/consensus/rpc/mock_rpc_test.go +++ b/consensus/rpc/mock_rpc_test.go @@ -1,97 +1,66 @@ package rpc - import ( "encoding/json" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" "os" "path/filepath" "testing" -) + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" +) +func TestNewMockRpc(t *testing.T) { + path := "/tmp/testdata" + mockRpc := NewMockRpc(path) + if mockRpc.testdata != path { + t.Errorf("Expected testdata path to be %s, got %s", path, mockRpc.testdata) + } +} func TestGetBootstrap(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - - mockBootstrap := map[string]interface{}{ - "data": map[string]interface{}{ - "header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "1000", - "proposer_index": "12345", - "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", - "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", - }, + mockBootstrap := BootstrapResponse{ + Data: consensus_core.Bootstrap{ + Header: consensus_core.Header{ + Slot: 1000, }, }, } - bootstrapJSON, _ := json.Marshal(mockBootstrap) err = os.WriteFile(filepath.Join(tempDir, "bootstrap.json"), bootstrapJSON, 0644) if err != nil { t.Fatalf("Failed to write mock bootstrap file: %v", err) } - mockRpc := NewMockRpc(tempDir) - bootstrap, err := mockRpc.GetBootstrap([32]byte{}) + bootstrap, err := mockRpc.GetBootstrap([]byte{}) if err != nil { t.Fatalf("GetBootstrap failed: %v", err) } - if bootstrap.Header.Slot != 1000 { t.Errorf("Expected bootstrap slot to be 1000, got %d", bootstrap.Header.Slot) } } - func TestGetUpdates(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - - mockUpdates := []map[string]interface{}{ - { - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "1", - "proposer_index": "12345", - "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", - "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", - }, - }, - "signature_slot": "1", - }, - }, - { - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "2", - }, - }, - "signature_slot": "2", - }, - }, + mockUpdates := UpdateResponse{ + {Data: consensus_core.Update{SignatureSlot: 1}}, + {Data: consensus_core.Update{SignatureSlot: 2}}, } - updatesJSON, _ := json.Marshal(mockUpdates) err = os.WriteFile(filepath.Join(tempDir, "updates.json"), updatesJSON, 0644) if err != nil { t.Fatalf("Failed to write mock updates file: %v", err) } - mockRpc := NewMockRpc(tempDir) updates, err := mockRpc.GetUpdates(1, 2) if err != nil { t.Fatalf("GetUpdates failed: %v", err) } - if len(updates) != 2 { t.Errorf("Expected 2 updates, got %d", len(updates)) } @@ -99,81 +68,58 @@ func TestGetUpdates(t *testing.T) { t.Errorf("Unexpected update signature slots") } } - func TestGetFinalityUpdate(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - - mockFinality := map[string]interface{}{ - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "1000", - }, - }, - "finalized_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "2000", - }, + mockFinality := FinalityUpdateResponse{ + Data: consensus_core.FinalityUpdate{ + FinalizedHeader: consensus_core.Header{ + Slot: 2000, }, }, } - finalityJSON, _ := json.Marshal(mockFinality) err = os.WriteFile(filepath.Join(tempDir, "finality.json"), finalityJSON, 0644) if err != nil { t.Fatalf("Failed to write mock finality file: %v", err) } - mockRpc := NewMockRpc(tempDir) finality, err := mockRpc.GetFinalityUpdate() if err != nil { t.Fatalf("GetFinalityUpdate failed: %v", err) } - if finality.FinalizedHeader.Slot != 2000 { t.Errorf("Expected finality slot to be 2000, got %d", finality.FinalizedHeader.Slot) } } - func TestGetOptimisticUpdate(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } defer os.RemoveAll(tempDir) - - mockOptimistic := map[string]interface{}{ - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "3000", - }, - }, - "signature_slot": "3000", + mockOptimistic := OptimisticUpdateResponse{ + Data: consensus_core.OptimisticUpdate{ + SignatureSlot: 3000, }, } - optimisticJSON, _ := json.Marshal(mockOptimistic) err = os.WriteFile(filepath.Join(tempDir, "optimistic.json"), optimisticJSON, 0644) if err != nil { t.Fatalf("Failed to write mock optimistic file: %v", err) } - mockRpc := NewMockRpc(tempDir) optimistic, err := mockRpc.GetOptimisticUpdate() if err != nil { t.Fatalf("GetOptimisticUpdate failed: %v", err) } - if optimistic.SignatureSlot != 3000 { t.Errorf("Expected optimistic signature slot to be 3000, got %d", optimistic.SignatureSlot) } } - func TestGetBlock(t *testing.T) { tempDir, err := os.MkdirTemp("", "mock_rpc_test") if err != nil { @@ -208,7 +154,6 @@ func TestGetBlock(t *testing.T) { t.Errorf("Expected block slot to be 4000, got %d", block.Slot) } } - func TestChainId(t *testing.T) { mockRpc := NewMockRpc("/tmp/testdata") _, err := mockRpc.ChainId() diff --git a/consensus/rpc/nimbus_rpc_test.go b/consensus/rpc/nimbus_rpc_test.go index 45ce21e..3e00074 100644 --- a/consensus/rpc/nimbus_rpc_test.go +++ b/consensus/rpc/nimbus_rpc_test.go @@ -1,16 +1,14 @@ package rpc - import ( "encoding/json" "fmt" - "github.com/BlocSoc-iitr/selene/consensus/consensus_core" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "net/http" "net/http/httptest" "testing" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) - func TestNewNimbusRpc(t *testing.T) { rpcURL := "http://example.com" nimbusRpc := NewNimbusRpc(rpcURL) @@ -21,16 +19,10 @@ func TestNimbusGetBootstrap(t *testing.T) { expectedPath := fmt.Sprintf("/eth/v1/beacon/light_client/bootstrap/0x%x", blockRoot) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, expectedPath, r.URL.Path) - response := map[string]interface{}{ - "data": map[string]interface{}{ - "header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "1000", - "proposer_index": "12345", - "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", - "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", - }, + response := BootstrapResponse{ + Data: consensus_core.Bootstrap{ + Header: consensus_core.Header{ + Slot: 1000, }, }, } @@ -44,39 +36,12 @@ func TestNimbusGetBootstrap(t *testing.T) { assert.Equal(t, uint64(1000), bootstrap.Header.Slot) } func TestNimbusGetUpdates(t *testing.T) { - defer func() { - if r := recover(); r != nil { - t.Errorf("Test panicked: %v", r) - } - }() server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/updates", r.URL.Path) assert.Equal(t, "start_period=1000&count=5", r.URL.RawQuery) - response := []map[string]interface{}{ - { - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "1", - "proposer_index": "12345", - "parent_root": "0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", - "state_root": "0x2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f40", - "body_root": "0x4142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f60", - }, - }, - "signature_slot": "1", - }, - }, - { - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "2", - }, - }, - "signature_slot": "2", - }, - }, + response := UpdateResponse{ + {Data: consensus_core.Update{AttestedHeader: consensus_core.Header{Slot: 1000}}}, + {Data: consensus_core.Update{AttestedHeader: consensus_core.Header{Slot: 1001}}}, } err := json.NewEncoder(w).Encode(response) require.NoError(t, err) @@ -86,23 +51,16 @@ func TestNimbusGetUpdates(t *testing.T) { updates, err := nimbusRpc.GetUpdates(1000, 5) assert.NoError(t, err) assert.Len(t, updates, 2) - assert.Equal(t, uint64(1), updates[0].AttestedHeader.Slot) - assert.Equal(t, uint64(2), updates[1].AttestedHeader.Slot) + assert.Equal(t, uint64(1000), updates[0].AttestedHeader.Slot) + assert.Equal(t, uint64(1001), updates[1].AttestedHeader.Slot) } func TestNimbusGetFinalityUpdate(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/finality_update", r.URL.Path) - response := map[string]interface{}{ - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "2000", - }, - }, - "finalized_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "2000", - }, + response := FinalityUpdateResponse{ + Data: consensus_core.FinalityUpdate{ + FinalizedHeader: consensus_core.Header{ + Slot: 2000, }, }, } @@ -118,14 +76,9 @@ func TestNimbusGetFinalityUpdate(t *testing.T) { func TestNimbusGetOptimisticUpdate(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/eth/v1/beacon/light_client/optimistic_update", r.URL.Path) - response := map[string]interface{}{ - "data": map[string]interface{}{ - "attested_header": map[string]interface{}{ - "beacon": map[string]interface{}{ - "slot": "3000", - }, - }, - "signature_slot": "3000", + response := OptimisticUpdateResponse{ + Data: consensus_core.OptimisticUpdate{ + SignatureSlot: 3000, }, } err := json.NewEncoder(w).Encode(response) @@ -172,4 +125,4 @@ func TestNimbusChainId(t *testing.T) { chainId, err := nimbusRpc.ChainId() assert.NoError(t, err) assert.Equal(t, uint64(5000), chainId) -} +} \ No newline at end of file diff --git a/consensus/types/beacon.go b/consensus/types/beacon.go index 66c517f..18ded48 100644 --- a/consensus/types/beacon.go +++ b/consensus/types/beacon.go @@ -2,6 +2,8 @@ package types // Serialization and Deserialization for ExecutionPayload and BeaconBlockBody can be done by importing from prewritten functions in utils wherever needed. + + type BeaconBlock struct { Slot uint64 ProposerIndex uint64 @@ -90,6 +92,8 @@ func (exe *ExecutionPayload) Def() { exe.ExcessBlobGas = 0 // Only for Deneb } // default + + type Withdrawal struct { Index uint64 Amount uint64 diff --git a/execution/state.go b/execution/state.go index 36db654..dddb75b 100644 --- a/execution/state.go +++ b/execution/state.go @@ -1,11 +1,9 @@ package execution - import ( + "sync" "github.com/BlocSoc-iitr/selene/common" "github.com/holiman/uint256" - "sync" ) - type State struct { mu sync.RWMutex blocks map[uint64]*common.Block @@ -18,7 +16,6 @@ type TransactionLocation struct { Block uint64 Index int } - func NewState(historyLength uint64, blockChan <-chan *common.Block, finalizedBlockChan <-chan *common.Block) *State { s := &State{ blocks: make(map[uint64]*common.Block), @@ -198,4 +195,4 @@ func (s *State) OldestBlockNumber() *uint64 { return &oldestNumber } return nil -} +} \ No newline at end of file diff --git a/execution/types.go b/execution/types.go index 339d2a3..f650ccc 100644 --- a/execution/types.go +++ b/execution/types.go @@ -3,12 +3,11 @@ package execution import ( "encoding/json" "fmt" - "github.com/BlocSoc-iitr/selene/utils" + "reflect" "github.com/ethereum/go-ethereum/common" "math/big" - "reflect" + "github.com/BlocSoc-iitr/selene/utils" ) - type Account struct { Balance *big.Int Nonce uint64 @@ -25,44 +24,43 @@ type CallOpts struct { Value *big.Int `json:"value,omitempty"` Data []byte `json:"data,omitempty"` } - func (c *CallOpts) String() string { return fmt.Sprintf("CallOpts{From: %v, To: %v, Gas: %v, GasPrice: %v, Value: %v, Data: 0x%x}", c.From, c.To, c.Gas, c.GasPrice, c.Value, c.Data) } func (c *CallOpts) Serialize() ([]byte, error) { - serialized := make(map[string]interface{}) - v := reflect.ValueOf(*c) - t := v.Type() + serialized := make(map[string]interface{}) + v := reflect.ValueOf(*c) + t := v.Type() - for i := 0; i < v.NumField(); i++ { - field := v.Field(i) - fieldName := t.Field(i).Name + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + fieldName := t.Field(i).Name - if !field.IsNil() { - var value interface{} - var err error + if !field.IsNil() { + var value interface{} + var err error - switch field.Interface().(type) { - case *common.Address: - value = utils.Address_to_hex_string(*field.Interface().(*common.Address)) - case *big.Int: - value = utils.U64_to_hex_string(field.Interface().(*big.Int).Uint64()) - case []byte: - value, err = utils.Bytes_serialize(field.Interface().([]byte)) - if err != nil { - return nil, fmt.Errorf("error serializing %s: %w", fieldName, err) - } - default: - return nil, fmt.Errorf("unsupported type for field %s", fieldName) - } + switch field.Interface().(type) { + case *common.Address: + value = utils.Address_to_hex_string(*field.Interface().(*common.Address)) + case *big.Int: + value = utils.U64_to_hex_string(field.Interface().(*big.Int).Uint64()) + case []byte: + value, err = utils.Bytes_serialize(field.Interface().([]byte)) + if err != nil { + return nil, fmt.Errorf("error serializing %s: %w", fieldName, err) + } + default: + return nil, fmt.Errorf("unsupported type for field %s", fieldName) + } - serialized[fieldName] = value - } - } + serialized[fieldName] = value + } + } - return json.Marshal(serialized) + return json.Marshal(serialized) } func (c *CallOpts) Deserialize(data []byte) error { @@ -107,4 +105,4 @@ func (c *CallOpts) Deserialize(data []byte) error { } return nil -} +} \ No newline at end of file diff --git a/go.mod b/go.mod index 7df0ec9..ce01ecf 100644 --- a/go.mod +++ b/go.mod @@ -10,61 +10,24 @@ require ( ) require ( - github.com/DataDog/zstd v1.4.5 // indirect - github.com/StackExchange/wmi v1.2.1 // indirect github.com/avast/retry-go v3.0.0+incompatible // indirect - github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/cockroachdb/errors v1.11.3 // indirect - github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/pebble v1.1.1 // indirect - github.com/cockroachdb/redact v1.1.5 // indirect - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect - github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/getsentry/sentry-go v0.27.0 // indirect - github.com/go-ole/go-ole v1.3.0 // indirect - github.com/gofrs/flock v0.8.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/kilic/bls12-381 v0.1.0 // indirect - github.com/klauspost/compress v1.17.2 // indirect - github.com/klauspost/cpuid/v2 v2.0.9 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-runewidth v0.0.13 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.12.0 // indirect - github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect - github.com/protolambda/bls12-381-util v0.1.0 // indirect - github.com/protolambda/zrnt v0.32.2 // indirect - github.com/protolambda/ztyp v0.2.2 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect @@ -73,9 +36,6 @@ require ( github.com/stretchr/testify v1.9.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/supranational/blst v0.3.11 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect - github.com/tklauser/go-sysconf v0.3.12 // indirect - github.com/tklauser/numcpus v0.6.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/wealdtech/go-merkletree v1.0.0 // indirect go.uber.org/atomic v1.9.0 // indirect @@ -85,7 +45,6 @@ require ( golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 67f6dbd..1de4e33 100644 --- a/go.sum +++ b/go.sum @@ -1,90 +1,17 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= -github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0= github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= -github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= -github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -92,217 +19,35 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.8 h1:NgOWvXS+lauK+zFukEvi85UmmsS/OkV0N23UZ1VTIig= github.com/ethereum/go-ethereum v1.14.8/go.mod h1:TJhyuDq0JDppAkFXgqjwpdlQApywnu/m10kFPxh8vvs= -github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4= -github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= -github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= -github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs= github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4= -github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= -github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= -github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= -github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= -github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/protolambda/bls12-381-util v0.1.0 h1:05DU2wJN7DTU7z28+Q+zejXkIsA/MF8JZQGhtBZZiWk= -github.com/protolambda/bls12-381-util v0.1.0/go.mod h1:cdkysJTRpeFeuUVx/TXGDQNMTiRAalk1vQw3TYTHcE4= -github.com/protolambda/zrnt v0.32.2 h1:KZ48T+3UhsPXNdtE/5QEvGc9DGjUaRI17nJaoznoIaM= -github.com/protolambda/zrnt v0.32.2/go.mod h1:A0fezkp9Tt3GBLATSPIbuY4ywYESyAuc/FFmPKg8Lqs= -github.com/protolambda/ztyp v0.2.2 h1:rVcL3vBu9W/aV646zF6caLS/dyn9BN8NYiuJzicLNyY= -github.com/protolambda/ztyp v0.2.2/go.mod h1:9bYgKGqg3wJqT9ac1gI2hnVb0STQq7p/1lapqrqY1dU= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -314,14 +59,11 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -331,337 +73,35 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8 github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/wealdtech/go-merkletree v1.0.0 h1:DsF1xMzj5rK3pSQM6mPv8jlyJyHXhFxpnA2bwEjMMBY= github.com/wealdtech/go-merkletree v1.0.0/go.mod h1:cdil512d/8ZC7Kx3bfrDvGMQXB25NTKbsm0rFrmDax4= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/utils/bls/bls.go b/utils/bls/bls.go index 957c5a9..5abe51c 100644 --- a/utils/bls/bls.go +++ b/utils/bls/bls.go @@ -1,9 +1,9 @@ package bls import ( + "math/big" "github.com/consensys/gnark-crypto/ecc/bls12-381" "github.com/consensys/gnark-crypto/ecc/bls12-381/fp" - "math/big" ) type G1Point struct { @@ -82,4 +82,4 @@ func AggregatePublicKeys(pubkeys []*G2Point) *G2Point { agg.Add(agg, pubkey.G2Affine) } return &G2Point{agg} -} +} \ No newline at end of file diff --git a/utils/utils.go b/utils/utils.go index 40b13fe..c44317c 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -2,25 +2,24 @@ package utils import ( "encoding/hex" - "strconv" + "strings" + "bytes" "crypto/sha256" "encoding/json" "fmt" "log" - "github.com/ethereum/go-ethereum/beacon/merkle" "github.com/ethereum/go-ethereum/common" - consensus_core "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "github.com/BlocSoc-iitr/selene/consensus/consensus_core" + "github.com/BlocSoc-iitr/selene/utils/bls" - beacon "github.com/ethereum/go-ethereum/beacon/types" - kbls "github.com/kilic/bls12-381" - bls "github.com/protolambda/bls12-381-util" + bls12381 "github.com/consensys/gnark-crypto/ecc/bls12-381" + "github.com/pkg/errors" + merkletree "github.com/wealdtech/go-merkletree" ) -var domain = []byte("BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_") - // if we need to export the functions , just make their first letter capitalised func Hex_str_to_bytes(s string) ([]byte, error) { @@ -35,17 +34,6 @@ func Hex_str_to_bytes(s string) ([]byte, error) { return bytesArray, nil } -func Hex_str_to_Bytes32(s string) (consensus_core.Bytes32, error) { - bytesArray, err := Hex_str_to_bytes(s) - if err != nil { - return consensus_core.Bytes32{}, err - } - - var bytes32 consensus_core.Bytes32 - copy(bytes32[:], bytesArray) - return bytes32, nil -} - func Address_to_hex_string(addr common.Address) string { bytesArray := addr.Bytes() return fmt.Sprintf("0x%x", hex.EncodeToString(bytesArray)) @@ -72,12 +60,37 @@ func Bytes_serialize(bytes []byte) ([]byte, error) { return json.Marshal(hexString) } -func Str_to_uint64(s string) (uint64, error) { - num, err := strconv.ParseUint(s, 10, 64) +// TreeHashRoot computes the Merkle root from the provided leaves in a flat []byte slice. +// TreeHashRoot calculates the root hash from the input data. +func TreeHashRoot(data []byte) ([]byte, error) { + // Convert the input data into a slice of leaves + leaves, err := bytesToLeaves(data) if err != nil { - return 0, err + return nil, fmt.Errorf("error converting bytes to leaves: %w", err) + } + + // Create the Merkle tree using the leaves + tree, errorCreatingMerkleTree := merkletree.New(leaves) + if errorCreatingMerkleTree != nil { + return nil, fmt.Errorf("error creating Merkle tree: %w", err) + } + + // Fetch the root hash of the tree + root := tree.Root() + if root == nil { + return nil, errors.New("failed to calculate the Merkle root: root is nil") } - return num, nil + + return root, nil +} + +func bytesToLeaves(data []byte) ([][]byte, error) { + var leaves [][]byte + if err := json.Unmarshal(data, &leaves); err != nil { + return nil, err + } + + return leaves, nil } func CalcSyncPeriod(slot uint64) uint64 { @@ -86,25 +99,72 @@ func CalcSyncPeriod(slot uint64) uint64 { } // isAggregateValid checks if the provided signature is valid for the given message and public keys. -//NO NEED OF THIS FUNCTION HERE AS IT IS NOW DIRECTLY IMPORTED FROM GETH IN CONSENSUS +func IsAggregateValid(sigBytes consensus_core.SignatureBytes, msg [32]byte, pks []*bls.G2Point) bool { + var sigInBytes [96]byte + copy(sigInBytes[:], sigBytes[:]) + // Deserialize the signature from bytes + var sig bls12381.G1Affine + if err := sig.Unmarshal(sigInBytes[:]); err != nil { + return false + } + + // Map the message to a point on the curve + msgPoint := bls.MapToCurve(msg) + + // Aggregate the public keys + aggPubKey := bls.AggregatePublicKeys(pks) + + // Prepare the pairing check inputs + P := [2]bls12381.G1Affine{*msgPoint, sig} + Q := [2]bls12381.G2Affine{*aggPubKey.G2Affine, *bls.GetG2Generator()} + + // Perform the pairing check + ok, err := bls12381.PairingCheck(P[:], Q[:]) + if err != nil { + return false + } + return ok +} func IsProofValid( attestedHeader *consensus_core.Header, - leafObject common.Hash, // Single byte slice of the leaf object - branch []consensus_core.Bytes32, // Slice of byte slices for the branch + leafObject []byte, // Single byte slice of the leaf object + branch [][]byte, // Slice of byte slices for the branch depth, index int, // Depth of the Merkle proof and index of the leaf ) bool { - var branchInMerkle merkle.Values - for _, node := range branch { - branchInMerkle = append(branchInMerkle, merkle.Value(node)) + // If the branch length is not equal to the depth, return false + if len(branch) != depth { + return false } - fmt.Print(attestedHeader.StateRoot) - err := merkle.VerifyProof(common.Hash(attestedHeader.StateRoot), uint64(index), branchInMerkle, merkle.Value(leafObject)) - if err != nil { - log.Println("Error in verifying Merkle proof:", err) + + // Initialize the derived root as the leaf object's hash + derivedRoot, errFetchingTreeHashRoot := TreeHashRoot(leafObject) + + if errFetchingTreeHashRoot != nil { + fmt.Printf("Error fetching tree hash root: %v", errFetchingTreeHashRoot) return false } - return true + + // Iterate over the proof's hashes + for i, hash := range branch { + hasher := sha256.New() + + // Use the index to determine how to combine the hashes + if (index>>i)&1 == 1 { + // If index is odd, hash node || derivedRoot + hasher.Write(hash) + hasher.Write(derivedRoot) + } else { + // If index is even, hash derivedRoot || node + hasher.Write(derivedRoot) + hasher.Write(hash) + } + // Update derivedRoot for the next level + derivedRoot = hasher.Sum(nil) + } + + // Compare the final derived root with the attested header's state root + return bytes.Equal(derivedRoot, attestedHeader.StateRoot[:]) } func CalculateForkVersion(forks *consensus_core.Forks, slot uint64) [4]byte { @@ -124,19 +184,17 @@ func CalculateForkVersion(forks *consensus_core.Forks, slot uint64) [4]byte { } } -// computed not as helios but as per go-ethereum/beacon/consensus.go func ComputeForkDataRoot(currentVersion [4]byte, genesisValidatorRoot consensus_core.Bytes32) consensus_core.Bytes32 { - var ( - hasher = sha256.New() - forkVersion32 merkle.Value - forkDataRoot merkle.Value - ) - copy(forkVersion32[:], currentVersion[:]) - hasher.Write(forkVersion32[:]) - hasher.Write(genesisValidatorRoot[:]) - hasher.Sum(forkDataRoot[:0]) - - return consensus_core.Bytes32(forkDataRoot) + forkData := ForkData{ + CurrentVersion: currentVersion, + GenesisValidatorRoot: genesisValidatorRoot, + } + + hash, err := TreeHashRoot(forkData.ToBytes()) + if err != nil { + return consensus_core.Bytes32{} + } + return consensus_core.Bytes32(hash) } // GetParticipatingKeys retrieves the participating public keys from the committee based on the bitfield represented as a byte array. @@ -164,21 +222,18 @@ func GetParticipatingKeys(committee *consensus_core.SyncCommittee, bitfield [64] return pks, nil } -// implemented as per go-ethereum/beacon/types/config.go -func ComputeSigningRoot(header *beacon.Header, domain consensus_core.Bytes32) consensus_core.Bytes32 { - var ( - signingRoot common.Hash - headerHash = header.Hash() - hasher = sha256.New() - ) - hasher.Write(headerHash[:]) - hasher.Write(domain[:]) - hasher.Sum(signingRoot[:0]) - - return consensus_core.Bytes32(signingRoot.Bytes()) +func ComputeSigningRoot(objectRoot, domain consensus_core.Bytes32) consensus_core.Bytes32 { + signingData := SigningData{ + ObjectRoot: objectRoot, + Domain: domain, + } + hash, err := TreeHashRoot(signingData.ToBytes()) + if err != nil { + return consensus_core.Bytes32{} + } + return consensus_core.Bytes32(hash) } -// implemented as per go-ethereum/beacon/types/config.go func ComputeDomain(domainType [4]byte, forkDataRoot consensus_core.Bytes32) consensus_core.Bytes32 { data := append(domainType[:], forkDataRoot[:28]...) return sha256.Sum256(data) @@ -224,71 +279,3 @@ func BranchToNodes(branch []consensus_core.Bytes32) ([][]byte, error) { } return nodes, nil } - -func FastAggregateVerify(pubkeys []*bls.Pubkey, message []byte, signature *bls.Signature) bool { - n := uint64(len(pubkeys)) - if n == 0 { - return false - } - - g1 := kbls.NewG1() - // Procedure: - // 1. aggregate = pubkey_to_point(PK_1) - // copy the first pubkey - aggregate := *(*kbls.PointG1)(pubkeys[0]) - // check identity pubkey - if (*kbls.G1)(nil).IsZero(&aggregate) { - fmt.Println("Identity pubkey") - return false - } - // 2. for i in 2, ..., n: - for i := uint64(1); i < n; i++ { - // 3. next = pubkey_to_point(PK_i) - next := (*kbls.PointG1)(pubkeys[i]) - // check identity pubkey - if (*kbls.G1)(nil).IsZero(next) { - fmt.Println("Identity pubkey") - return false - } - // 4. aggregate = aggregate + next - g1.Add(&aggregate, &aggregate, next) - } - // 5. PK = point_to_pubkey(aggregate) - PK := (*bls.Pubkey)(&aggregate) - return coreVerify(PK, message, signature) -} - -func coreVerify(pk *bls.Pubkey, message []byte, signature *bls.Signature) bool { - // 1. R = signature_to_point(signature) - R := (*kbls.PointG2)(signature) - // 2. If R is INVALID, return INVALID - // 3. If signature_subgroup_check(R) is INVALID, return INVALID - // 4. If KeyValidate(PK) is INVALID, return INVALID - // steps 2-4 are part of bytes -> *Signature deserialization - if (*kbls.G2)(nil).IsZero(R) { - // KeyValidate is assumed through deserialization of Pubkey and Signature, - // but the identity pubkey/signature case is not part of that, thus verify here. - fmt.Print("Identity signature") - return false - } - - // 5. xP = pubkey_to_point(PK) - xP := (*kbls.PointG1)(pk) - // 6. Q = hash_to_point(message) - Q, err := kbls.NewG2().HashToCurve(message, domain) - if err != nil { - // e.g. when the domain is too long. Maybe change to panic if never due to a usage error? - fmt.Print("Failed to hash message to point") - return false - } - - // 7. C1 = pairing(Q, xP) - eng := kbls.NewEngine() - eng.AddPair(xP, Q) - // 8. C2 = pairing(R, P) - P := &kbls.G1One - eng.AddPairInv(P, R) - // 9. If C1 != C2, return INVALID - return !eng.Check() -} -