Skip to content

Commit

Permalink
turn off registry bridge and start new chain (#10036)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsavvy authored Oct 14, 2024
1 parent 7d7008c commit f4ebc7d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 80 deletions.
2 changes: 1 addition & 1 deletion pkg/core/config/genesis/prod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"genesis_time": "2024-09-05T00:00:00.0000Z",
"chain_id": "audius-mainnet-test2",
"chain_id": "audius-mainnet-test3",
"initial_height": "0",
"consensus_params": {
"block": {
Expand Down
79 changes: 0 additions & 79 deletions pkg/core/registry_bridge/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ import (
"time"

"github.com/AudiusProject/audius-protocol/pkg/core/accounts"
"github.com/AudiusProject/audius-protocol/pkg/core/common"
"github.com/AudiusProject/audius-protocol/pkg/core/contracts"
gen_proto "github.com/AudiusProject/audius-protocol/pkg/core/gen/proto"
"github.com/AudiusProject/audius-protocol/pkg/core/grpc"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/crypto"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"google.golang.org/protobuf/proto"
)

// checks mainnet eth for itself, if registered and not
Expand All @@ -31,7 +26,6 @@ func (r *Registry) RegisterSelf() error {
logger := r.logger

web3 := r.contracts
queries := r.queries

privKey := r.config.EthereumKey
nodeAddress := crypto.PubkeyToAddress(privKey.PublicKey)
Expand Down Expand Up @@ -61,79 +55,6 @@ func (r *Registry) RegisterSelf() error {
return nil
}

serviceType, err := contracts.ServiceType(r.config.NodeType)
if err != nil {
return fmt.Errorf("invalid node type: %v", err)
}

info, err := spf.GetServiceEndpointInfo(nil, serviceType, spID)
if err != nil {
return fmt.Errorf("could not get service endpoint info: %v", err)
}

if info.DelegateOwnerWallet != nodeAddress {
return fmt.Errorf("node %s is claiming to be %s but that endpoint is owned by %s", nodeAddress.Hex(), nodeEndpoint, info.DelegateOwnerWallet.Hex())
}

ethBlock := info.BlockNumber.String()

nodeRecord, err := queries.GetNodeByEndpoint(ctx, nodeEndpoint)
if err != nil {
logger.Infof("node %s not found on comet but found on eth, registering", nodeEndpoint)
if err := r.registerSelfOnComet(ethBlock, spID.String()); err != nil {
return fmt.Errorf("could not register on comet: %v", err)
}
return r.RegisterSelf()
}

logger.Infof("node %s : %s registered on network %s", nodeRecord.EthAddress, nodeRecord.Endpoint, r.config.Environment)
return nil
}

func (r *Registry) registerSelfOnComet(ethBlock, spID string) error {
privKey, err := accounts.EthToEthKey(r.config.DelegatePrivateKey)
if err != nil {
return fmt.Errorf("invalid privkey: %v", err)
}

serviceType, err := contracts.ServiceType(r.config.NodeType)
if err != nil {
return fmt.Errorf("invalid node type: %v", err)
}

registrationTx := &gen_proto.ValidatorRegistration{
Endpoint: r.config.NodeEndpoint,
CometAddress: r.config.ProposerAddress,
EthBlock: ethBlock,
NodeType: common.HexToUtf8(serviceType),
SpId: spID,
}

eventBytes, err := proto.Marshal(registrationTx)
if err != nil {
return fmt.Errorf("failure to marshal register event: %v", err)
}

sig, err := accounts.EthSign(privKey, eventBytes)
if err != nil {
return fmt.Errorf("could not sign register event: %v", err)
}

event := &gen_proto.SignedTransaction{
Signature: sig,
RequestId: uuid.NewString(),
Transaction: &gen_proto.SignedTransaction_ValidatorRegistration{
ValidatorRegistration: registrationTx,
},
}

txhash, err := grpc.SendTx(r.logger, r.rpc, event)
if err != nil {
return fmt.Errorf("send register tx failed: %v", err)
}

r.logger.Infof("registered node %s in tx %s", r.config.NodeEndpoint, txhash)

return nil
}

Expand Down

0 comments on commit f4ebc7d

Please sign in to comment.