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

Ridvan batch finish #47

Merged
merged 19 commits into from
Feb 19, 2021
Merged

Ridvan batch finish #47

merged 19 commits into from
Feb 19, 2021

Conversation

rozaydin
Copy link

Batch Finish hsd implementation

Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Copy link

@RevCBH RevCBH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style/typo notes and 1 question, but generally LGTM.

The only thing blocking this PR is getting a more stable ID into the package.json for namebase-hs-client

package.json Outdated Show resolved Hide resolved
lib/wallet/http.js Outdated Show resolved Hide resolved
lib/wallet/http.js Outdated Show resolved Hide resolved
lib/wallet/wallet.js Outdated Show resolved Hide resolved
lib/wallet/wallet.js Outdated Show resolved Hide resolved
continue;

const output = new Output();
output.address = coin.address;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure I understand: we are sending REDEEM and REGISTER transactions to the same address that sent the REVEAL, correct?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a consensus requirement for REGISTER (see lib/covenants/rules.js:1282) but not for REDEEMs. @rozaydin can you confirm that the previous behavior for normal REDEEMs was to send the REDEEM output to the same address and not to a new address? I can imagine wanting to send the coins to a different address since REDEEMs are spendable. In any case not a blocking change

Copy link

@turbomaze turbomaze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good thanks Ridvan

package.json Outdated Show resolved Hide resolved
});

assert.deepStrictEqual(wallet2Finish.errorMessages, []);
assert.equal(wallet2Finish.processedFinishes.length, 2); // one redeem one finish

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like these tests check if the correct bids were redeemed/regsitered, what do you think? Blockchain consensus will prevent actual errors, but if we have a problem in transaction construction and mess up which was the redeem and which was the register, then our REVEAL outputs will be locked in the bad, pending transaction and we might get a "could not resolve preferred inputs" error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good catch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the tests to assert for REDEEM and REGISTER values, please let me know if this would be enough or should we add additional checks ?

test/wallet-http-test.js Show resolved Hide resolved
// Create Batch Finish (Redeem or Register)
this.post('/wallet/:id/batch/finish', async (req, res) => {
const valid = Validator.fromRequest(req);
let names = valid.array('names');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

names seems misleading to me because it's not the same as the names variable in batch opens/reveals. Maybe const finishRequests = valid.array('finishRequests')?

let errorMessages = [];
const uniqueNames = [];

names.forEach(({name, data}) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth abstracting this common logic from the batch bids code?

lib/wallet/http.js Outdated Show resolved Hide resolved
lib/wallet/http.js Outdated Show resolved Hide resolved
continue;

const output = new Output();
output.address = coin.address;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a consensus requirement for REGISTER (see lib/covenants/rules.js:1282) but not for REDEEMs. @rozaydin can you confirm that the previous behavior for normal REDEEMs was to send the REDEEM output to the same address and not to a new address? I can imagine wanting to send the coins to a different address since REDEEMs are spendable. In any case not a blocking change

output.covenant.pushHash(nameHash);
output.covenant.pushU32(ns.height);

if (prevout.equals(ns.owner)) { // Winner, does REGISTER

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does ns.owner get set?

  1. Are we sure that ns is not set on every tree interval, when the name tree gets committed? Or is it up to date with every block?
  2. What happens if there is a redeem/register right on the exact close_block of an auction? Will ns.owner already point to the correct output?


finishes.forEach((element) => {
const {output, outpoint} = element;
mtx.addOutpoint(outpoint);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, what is the difference between this line and the one below it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outpoint contains the previous output (prevout) (which forms the inputs i believe) where as the output is the outputs that we are creating with this transaction... per my understanding

Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
rozaydin and others added 2 commits February 19, 2021 10:55
Signed-off-by: rozaydin <ridvan@namebase.io>
@turbomaze turbomaze merged commit 1cd33c9 into production-namebase Feb 19, 2021
@turbomaze turbomaze deleted the ridvan-batch-finish branch February 19, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants