Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Registering script stake keys doesn't seem to do anything #1757

Open
twwu123 opened this issue Dec 5, 2024 · 5 comments
Open

Registering script stake keys doesn't seem to do anything #1757

twwu123 opened this issue Dec 5, 2024 · 5 comments
Labels
bug 🐛 Something isn't working

Comments

@twwu123
Copy link

twwu123 commented Dec 5, 2024

Context & versions

Hydra version: 0.19.0
Cardano node version: 10.1.2

I am also using custom protocol params

{
  txFeePerByte: 0,
  txFeeFixed: 0,
  maxBlockBodySize: 98304000,
  maxTxSize: 4294967295,
  maxBlockHeaderSize: 1100,
  stakeAddressDeposit: 0,
  stakePoolDeposit: 0,
  poolRetireMaxEpoch: 18,
  stakePoolTargetNum: 500,
  poolPledgeInfluence: 0.3,
  monetaryExpansion: 0.003,
  treasuryCut: 0.2,
  minPoolCost: 170000000,
  executionUnitPrices: { priceMemory: 0, priceSteps: 0 },
  maxTxExecutionUnits: { memory: 16000000000, steps: 10000000000000 },
  maxBlockExecutionUnits: { memory: 80000000000, steps: 40000000000000 },
  maxValueSize: 5000,
  collateralPercentage: 150,
  maxCollateralInputs: 3,
  utxoCostPerByte: 0,
  poolVotingThresholds: {
    committeeNoConfidence: 0.51,
    committeeNormal: 0.51,
    hardForkInitiation: 0.51,
    motionNoConfidence: 0.51,
    ppSecurityGroup: 0.51
  },
  dRepVotingThresholds: {
    committeeNoConfidence: 0.6,
    committeeNormal: 0.67,
    hardForkInitiation: 0.6,
    motionNoConfidence: 0.67,
    ppEconomicGroup: 0.67,
    ppGovGroup: 0.75,
    ppNetworkGroup: 0.67,
    ppTechnicalGroup: 0.67,
    treasuryWithdrawal: 0.67,
    updateToConstitution: 0.75
  },
  committeeMinSize: 7,
  committeeMaxTermLength: 146,
  govActionLifetime: 6,
  govActionDeposit: 100000000000,
  dRepDeposit: 500000000,
  dRepActivity: 20,
  minFeeRefScriptCostPerByte: 0,
  protocolVersion: { major: 10, minor: 0 }
}

Steps to reproduce

  1. Start and commit some UTxOs into a hydra head
  2. Register a Script Hash credential via the "StakeRegistration" certificate
  3. Attempt to withdraw 0 lovelaces using the registered Script credential.

Actual behavior

  "validationError": {
    "reason": "ApplyTxError (ConwayCertsFailure (WithdrawalsNotInRewardsCERTS (fromList [(RewardAccount {raNetwork = Testnet, raCredential = ScriptHashObj (ScriptHash \"f4bc4c9ff5918fdf98a0a7926b51764ab1350dcdf4ac18cf89afebb2\")},Coin 0)])) :| [])"
  }

This validation error is seen in the withdrawal transaction. This occurs in the cases where, a credential has not been registered, OR an incomplete withdrawal has been attempted.

It is also possible to register the credential again (which shouldn't be possible if the credential has already been registered).

Expected behavior

A successful withdrawal, or at least an error that comes from running the script in the Script Hash credential.

I'm actually quite curious about how hydra nodes handle staking and reward calculations in general.

@twwu123 twwu123 added the bug 🐛 Something isn't working label Dec 5, 2024
@v0d1ch
Copy link
Contributor

v0d1ch commented Dec 6, 2024

Hey @twwu123 thanks for reporting this!
Could you give us more details on steps 1 and 2? How exactly did you register a stake certificate ( how did you construct the transaction? Using cardano-cli? Something else?) Also how does the transaction to withdraw 0 look like? The more details the better for us to figure out what happened. Thanks!

@HinsonSIDAN
Copy link

HinsonSIDAN commented Dec 6, 2024

We are building the transaction in Mesh, the same registering process works fine in preprod testnet. Txbuilding part should have no issue as we testing with hydra minting and unlocking tx, which are working fine.

In detail, it is how it looks like:

Registering

const registerCert = async (
  rewardAddress: string, // Reward address of an always succeed script (stakexxxxxxxxx)
  ownerUtxo: UTxO,
  collateralUtxo: UTxO
) => {
  const txBuilder = new MeshTxBuilder();
  const txHex = await txBuilder
    .protocolParams(HYDRA_PROTOCOL_PARAMETER)
    .setNetwork(HYDRA_COST_MODELS)
    .txInCollateral(
      collateralUtxo.input.txHash,
      collateralUtxo.input.outputIndex,
      collateralUtxo.output.amount,
      collateralUtxo.output.address
    )
    .txIn(
      ownerUtxo.input.txHash,
      ownerUtxo.input.outputIndex,
      ownerUtxo.output.amount,
      ownerUtxo.output.address,
      0
    )
    .txOut(ownerUtxo.output.address, ownerUtxo.output.amount)
    .registerStakeCertificate(rewardAddress)
    .changeAddress(ownerUtxo.output.address)
    .complete();

  return txHex;
};

Withdrawal

const withdrawZero = async (
  rewardAddress: string, // Reward address of an always succeed script (stakexxxxxxxxx)
  scriptCbor: string, // Always succeed script
  ownerUtxo: UTxO,
  collateralUtxo: UTxO
) => {
  const txBuilder = new MeshTxBuilder();
  const txHex = await txBuilder
    .protocolParams(HYDRA_PROTOCOL_PARAMETER)
    .setNetwork(HYDRA_COST_MODELS)
    .withdrawalPlutusScriptV3()
    .withdrawal(rewardAddress, "0")
    .withdrawalScript(scriptCbor)
    .withdrawalRedeemerValue("")
    .changeAddress(ownerUtxo.output.address)
    .txInCollateral(
      collateralUtxo.input.txHash,
      collateralUtxo.input.outputIndex,
      collateralUtxo.output.amount,
      collateralUtxo.output.address
    )
    .complete();

  return txHex;
};

Protocol Params

export const HYDRA_PROTOCOL_PARAMETER: Protocol = {
  epoch: 0,
  coinsPerUtxoSize: 0, // changed
  priceMem: 0.0, // changed
  priceStep: 0.0, // changed
  minFeeA: 0, // changed
  minFeeB: 0, // changed
  keyDeposit: 0, // changed
  // maxTxSize: 16_384_000, // changed
  // maxTxSize: 16_384_000_000, // changed
  maxTxSize: 4_294_967_295, // changed
  maxValSize: 5000,
  poolDeposit: 0,
  maxCollateralInputs: 3,
  decentralisation: 0,
  // maxBlockSize: 98304,
  maxBlockSize: 98_304_000, // changed
  collateralPercent: 150,
  maxBlockHeaderSize: 1100,
  minPoolCost: "170000000",
  // maxTxExMem: "16000000",
  // maxTxExSteps: "10000000000",
  // maxBlockExMem: "80000000",
  // maxBlockExSteps: "40000000000",
  maxTxExMem: "16000000000", // changed
  maxTxExSteps: "10000000000000", // changed
  maxBlockExMem: "80000000000", // changed
  maxBlockExSteps: "40000000000000", // changed
  minFeeRefScriptCostPerByte: 0,
};

export const HYDRA_COST_MODELS = [
  [
    100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305,
    8356, 4, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000,
    100, 100, 100, 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0,
    1, 22151, 32, 91189, 769, 4, 2, 85848, 228465, 122, 0, 1, 1, 1000, 42921, 4,
    2, 24548, 29498, 38, 1, 898148, 27279, 1, 51775, 558, 1, 39184, 1000, 60594,
    1, 141895, 32, 83150, 32, 15299, 32, 76049, 1, 13169, 4, 22100, 10, 28999,
    74, 1, 28999, 74, 1, 43285, 552, 1, 44749, 541, 1, 33852, 32, 68246, 32,
    72362, 32, 7243, 32, 7391, 32, 11546, 32, 85848, 228465, 122, 0, 1, 1,
    90434, 519, 0, 1, 74433, 32, 85848, 228465, 122, 0, 1, 1, 85848, 228465,
    122, 0, 1, 1, 270652, 22588, 4, 1457325, 64566, 4, 20467, 1, 4, 0, 141992,
    32, 100788, 420, 1, 1, 81663, 32, 59498, 32, 20142, 32, 24588, 32, 20744,
    32, 25933, 32, 24623, 32, 53384111, 14333, 10,
  ],
  [
    100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305,
    8356, 4, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000,
    100, 100, 100, 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0,
    1, 22151, 32, 91189, 769, 4, 2, 85848, 228465, 122, 0, 1, 1, 1000, 42921, 4,
    2, 24548, 29498, 38, 1, 898148, 27279, 1, 51775, 558, 1, 39184, 1000, 60594,
    1, 141895, 32, 83150, 32, 15299, 32, 76049, 1, 13169, 4, 22100, 10, 28999,
    74, 1, 28999, 74, 1, 43285, 552, 1, 44749, 541, 1, 33852, 32, 68246, 32,
    72362, 32, 7243, 32, 7391, 32, 11546, 32, 85848, 228465, 122, 0, 1, 1,
    90434, 519, 0, 1, 74433, 32, 85848, 228465, 122, 0, 1, 1, 85848, 228465,
    122, 0, 1, 1, 955506, 213312, 0, 2, 270652, 22588, 4, 1457325, 64566, 4,
    20467, 1, 4, 0, 141992, 32, 100788, 420, 1, 1, 81663, 32, 59498, 32, 20142,
    32, 24588, 32, 20744, 32, 25933, 32, 24623, 32, 43053543, 10, 53384111,
    14333, 10, 43574283, 26308, 10,
  ],
  [
    100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305,
    8356, 4, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000,
    100, 100, 100, 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0,
    1, 22151, 32, 91189, 769, 4, 2, 85848, 123203, 7305, -900, 1716, 549, 57,
    85848, 0, 1, 1, 1000, 42921, 4, 2, 24548, 29498, 38, 1, 898148, 27279, 1,
    51775, 558, 1, 39184, 1000, 60594, 1, 141895, 32, 83150, 32, 15299, 32,
    76049, 1, 13169, 4, 22100, 10, 28999, 74, 1, 28999, 74, 1, 43285, 552, 1,
    44749, 541, 1, 33852, 32, 68246, 32, 72362, 32, 7243, 32, 7391, 32, 11546,
    32, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 90434, 519, 0, 1,
    74433, 32, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 1, 85848,
    123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 955506, 213312, 0, 2,
    270652, 22588, 4, 1457325, 64566, 4, 20467, 1, 4, 0, 141992, 32, 100788,
    420, 1, 1, 81663, 32, 59498, 32, 20142, 32, 24588, 32, 20744, 32, 25933, 32,
    24623, 32, 43053543, 10, 53384111, 14333, 10, 43574283, 26308, 10, 16000,
    100, 16000, 100, 962335, 18, 2780678, 6, 442008, 1, 52538055, 3756, 18,
    267929, 18, 76433006, 8868, 18, 52948122, 18, 1995836, 36, 3227919, 12,
    901022, 1, 166917843, 4307, 36, 284546, 36, 158221314, 26549, 36, 74698472,
    36, 333849714, 1, 254006273, 72, 2174038, 72, 2261318, 64571, 4, 207616,
    8310, 4, 1293828, 28716, 63, 0, 1, 1006041, 43623, 251, 0, 1, 100181, 726,
    719, 0, 1, 100181, 726, 719, 0, 1, 100181, 726, 719, 0, 1, 107878, 680, 0,
    1, 95336, 1, 281145, 18848, 0, 1, 180194, 159, 1, 1, 158519, 8942, 0, 1,
    159378, 8813, 0, 1, 107490, 3298, 1, 106057, 655, 1, 1964219, 24520, 3,
  ],
];

@twwu123
Copy link
Author

twwu123 commented Dec 6, 2024

Just to give more context here in case it is the reason. Mesh currently still uses the soon to be deprecated stake_registration certificate for registering stake keys.

But it hasn't actually been deprecated yet, so I assume it should still work.

@twwu123
Copy link
Author

twwu123 commented Dec 6, 2024

Step 1 was also done using Mesh to build a scaffold for spending script inputs, then completed using the commit endpoint of the hydra-nodes. It does commit and open the head successfully, so I assume that step wasn't the issue.

@twwu123
Copy link
Author

twwu123 commented Dec 9, 2024

For further context, here is the txHex of a StakeRegistration (this transaction is accepted, and updates the snapshot)

84a600d9010281825820e6a625dfa8f9fd16f2a043da5c692257c809c6c99da14c6cd1a35f68c6abb5a51864018182581d60fa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c1a00989680020004d901028182008201581c1417bc6826853c78fe74b911e0f8ce3d280440d9d2f925338b55a5150dd9010281825820e6a625dfa8f9fd16f2a043da5c692257c809c6c99da14c6cd1a35f68c6abb5a518640ed9010281581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525ca10081825820e92691f912f86ac35a7540ffd5d8b65902b8bfad21d26ffe1a8c37aff1f84a385840cf8b46329758b7f8bc6046bacd5909a8d2bee700de2632a9b330d0b3de10b7c1adeab6f1ad864cf661486a0d4290d7349f98f9d0e6aa5b74ce57c80a97113e06f5f6

And then the txHex of a subsequent withdrawal (that doesn't work)

84a700d9010281825820e6a625dfa8f9fd16f2a043da5c692257c809c6c99da14c6cd1a35f68c6abb5a518630180020005a1581df01417bc6826853c78fe74b911e0f8ce3d280440d9d2f925338b55a515000b582075e3ddd00fd933d11169fbfea99e3c57c362d35a3298ba7de73891ea5048d8ae0dd9010281825820e6a625dfa8f9fd16f2a043da5c692257c809c6c99da14c6cd1a35f68c6abb5a518630ed9010281581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525ca207d901028158bb58b9010100333232323232232225333005323232323232330010013758601c601e601e601e601e601e601e601e601e60186ea8c038c030dd50039129998070008a50132533300d3371e6eb8c04000802c52889980180180098080009806180680118058009805801180480098031baa00114984d958dd7000ab9a5573caae7d5d0aba24c011e581cfa5136e9e9ecbc9071da73eeb6c9a4ff73cbf436105cf8380d1c525c004c011150372d73706c69742d7769746864726177000105a18203008240821a006acfc01ab2d05e00f5f6

And given this validationError

  "validationError": {
    "reason": "ApplyTxError (ConwayCertsFailure (WithdrawalsNotInRewardsCERTS (fromList [(RewardAccount {raNetwork = Testnet, raCredential = ScriptHashObj (ScriptHash \"1417bc6826853c78fe74b911e0f8ce3d280440d9d2f925338b55a515\")},Coin 0)])) :| [])"
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants