-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support slashing & simply data structure for phase 2 #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor comments nothing blocking.
Though I would strongly consider naming adjustments in slashing transactions building functions.
src/staking/index.ts
Outdated
} = delegation; | ||
public createUnbondingTransaction( | ||
stakingTx: Transaction, | ||
stakingOutputIndex: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KonradStaniec @gitferry do we actually need this outputIndex?
It seems that i could rebuild the stakingOutput by doing below
// Build outputs
const scriptTree: Taptree = [
{
output: scripts.slashingScript,
},
[{ output: scripts.unbondingScript }, { output: scripts.timelockScript }],
];
// Create an pay-2-taproot (p2tr) output using the staking script
const stakingOutput = payments.p2tr({
internalPubkey,
scriptTree,
network,
});
then grab the stakingOutput.address
and check each of the stakingTx output, see if it matches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in theory you could do that, thought isn't it simpler to use stakingOutputIndex
if you already have it ? I think we already store it in Babylon node database and return it in queries to avoid such re-creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KonradStaniec
In phase-1, yes, but No in phase-2 as i don't have it at the time of EOI creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, nice work! Did not check the tests due to bandwidth constraints, let me know if there's something specific there you would like me to take a look at.
stakerPkNoCoordHex | ||
} = delegation; | ||
public createUnbondingTransaction( | ||
stakingTx: Transaction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for a future development. It would be interesting to see this class be able to identify the staking transaction by itself for unbonding/withdrawal transactions in order to avoid having the transactions passed as parameters and risking having a transaction that does not correspond to the params passed in the constructor.
i.e. the class always has access to all the information to build all transactions by default, and each instance of this class corresponds to all the staking paths starting from a unique staking transaction.
public createStakingOutputSlashingTransaction( | ||
stakingTx: Transaction, | ||
) : PsbtTransactionResult { | ||
if (!this.params.slashing) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have the option to avoid setting the slashing parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backwards compatibility with Observable, there is no slashing params in phase-1
What’s changed in this PR: