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

Qi Address Scope Check #1604

Conversation

jdowning100
Copy link
Contributor

@dominant-strategies/core-dev
I am quite sure the check is redundant, but check if an address is in Qi ledger scope and internal shard scope before adding new utxo to set.
#1400

wizeguyy
wizeguyy previously approved these changes Apr 15, 2024
@@ -309,7 +309,9 @@ func (p *StateProcessor) Process(block *types.WorkObject, etxSet *types.EtxSet)
return nil, nil, nil, nil, 0, fmt.Errorf("etx %032x emits UTXO with value %d greater than max denomination", tx.Hash(), tx.Value().Int64())
}
// There are no more checks to be made as the ETX is worked so add it to the set
statedb.CreateUTXO(tx.OriginatingTxHash(), tx.ETXIndex(), types.NewUtxoEntry(types.NewTxOut(uint8(tx.Value().Int64()), tx.To().Bytes())))
if err := statedb.CreateUTXO(tx.OriginatingTxHash(), tx.ETXIndex(), types.NewUtxoEntry(types.NewTxOut(uint8(tx.Value().Int64()), tx.To().Bytes()))); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Going from big.Int to Int64 to uint8 seems sus. Can you confirm our values never exceed uint8?

Copy link
Contributor Author

@jdowning100 jdowning100 Apr 17, 2024

Choose a reason for hiding this comment

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

The check for this is above:

if tx.Value().Int64() > types.MaxDenomination { // sanity check
					return nil, nil, nil, nil, 0, fmt.Errorf("etx %032x emits UTXO with value %d greater than max denomination", tx.Hash(), tx.Value().Int64())

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok since we do the overflow sanity check is there anywhere we check that the value is strictly above 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

Making it a uint64 would fix it too. That would simultaneously check that the value is below the max denomination and that it was positive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@jdowning100 jdowning100 Apr 18, 2024

Choose a reason for hiding this comment

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

Updated the conversion PR to use big.Int.Uint64(). Please review that PR instead of this one as that PR includes this one.

@jdowning100
Copy link
Contributor Author

Closed in favor of #1559

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