Skip to main content

Batch SDK Proposer Registration

This guide will walk through how to register one or more proposers in the single sign on proposer registry using the Proof of Neutrality Software Development Kit.

Firstly, let’s install the SDK:

npm i @blockswaplab/pon-sdk

Once installed, parameters need to be prepared:

  • Keystore files
  • Passwords for unlocking the key store files
  • Payout recipient ECDSA addresses
  • Representative ECDSA addresses

Note on keystores: The process of registering a proposer in the Proposer registry requires swapping the BLS12-381 signatures associated with the BLS credentials of a proposer to an ECDSA signature that can be used to prove to the Proposer registry that indeed the representative registering the proposer is in possession of the BLS signing key in order to stop impersonation attacks. The password will be used to unlock the keystore locally in the SDK, sign a message and transmit the signed message for swapping.

Notes on payout recipient versus representative: The payout recipient is the account that will receive ETH from the payout pool if the proposer has not opted out of the payout pool. The representative account is the one that can manage the proposer registration in the proposer registry including rage quitting from the registry.

Notes on opting out of the payout pool: Representatives may register proposers and by default will be opted into the payout pool. This means that they will get continuous 7 day payouts regardless if the specific proposer they registered produced a block or not. Alternatively during registration, proposers may opt out of the pay out pool in order to keep their earnings when they produce a block themselves.

With the core notes out of the way, the PoN SDK has the following registration functions:

  • batchRegisterProposer(blsKeys, payoutRecipients, representatives, blsSigningKeys, openClaims)
  • registerProposer(blsKey, payoutRecipient, representative, blsSigningKey, openClaim = false)
  • registerProposerWithoutPayoutPoolRegistration(blsKey, alternativeFeeRecipient, payoutRecipient, representative, blsSigningKey, openClaim = false)
  • batchRegisterProposerWithoutPayoutPoolRegistration(blsKeys, alternativeFeeRecipients, payoutRecipients, representatives, blsSigningKeys, openClaims)

batchRegisterProposer is pretty much the same as registerProposer except with arrays of params. Both of these functions will opt the proposer INTO the payout pool.

batchRegisterProposerWithoutPayoutPoolRegistration is a similar concept when compared with registerProposerWithoutPayoutPoolRegistration but as the function suggests, the proposers will NOT opt into the payout pool.

Params explained registerProposer(blsPublicKey, payoutRecipient, representative, blsSigningKey, openClaim = false)

  • blsPublicKey - the BLS public key of the proposer on the consensus layer being registered
  • payoutRecipient - the ECDSA address that would be the recipient of earnings from the payout pool
  • Representative - The ECDSA address that can manage the proposer registration
  • blsSigningKey - The signing key that will be used for signing the registration message
  • openClaim - Whether anyone can trigger the payment from the payout pool to the payout recipient. Note they can only trigger the transaction, they do not have the ability to claim the funds to their own account.

registerProposerWithoutPayoutPoolRegistration will also request the alternative fee recipient parameter when registering outside of the payout pool.

The above registration functions in PoN SDK take the BLS signing key as a param but if only the keystore and passwords mentioned at the start are present, then there is the need to unlock the keystore files. There are various tools to do this. Additionally, the Stakehouse SDK can be used as follows:

Install the Stakehouse SDK:

npm i @blockswaplab/stakehouse-sdk

Then:

const {StakehouseSDK} = require('@blockswaplab/stakehouse-sdk');
const sdk = new StakehouseSDK(ethersSigner);
const { publicKey, privateKey } = await sdk.cip.unlockBLSKeystore(keystore, password);

Example:

const unlock = await sdk.cip.unlockBLSKeystore(
keystore,
'password'
)

const pSDK = new PoNSdk(ethersSigner)
const tx = await pSDK.proposerRegistry.batchRegisterProposer(
[
`0x${keystore.pubkey}`,
],
[
ethersSigner.address,
],
[
ethersSigner.address,
],
[
Buffer.from(unlock.privateKey, 'hex')
],
[
true
]
)
console.log('tx.hash', tx.hash)

Once completed and transaction(s) included in the chain, the registration can be seen either in the smart contracts or the subgraph: https://github.com/pon-network/contract-deployments