CityOfZion / neon-js

Javascript libraries that allow the applications to interact with NEO blockchain
https://docs.coz.io/neo3/neon-js/index.html
MIT License
183 stars 166 forks source link

CommonConfig's prioritisationFee is not used and might lead to confusion #864

Closed melanke closed 2 years ago

melanke commented 2 years ago

https://github.com/CityOfZion/neon-js/blob/804b20a34872be3d6ae70bc036bdf367fc50b280/packages/neon-js/src/experimental/types.ts#L5

ixje commented 2 years ago

Yeah that's odd. I swear that it was used in the past, but there seems to be some history missing on where it came from.

Anyway; here are the rules for transaction prioritisation (ref)

public int CompareTo(Transaction otherTx)
        {
            if (otherTx == null) return 1;
            int ret = (Tx.GetAttribute<HighPriorityAttribute>() != null).CompareTo(otherTx.GetAttribute<HighPriorityAttribute>() != null);
            if (ret != 0) return ret;
            // Fees sorted ascending
            ret = Tx.FeePerByte.CompareTo(otherTx.FeePerByte);
            if (ret != 0) return ret;
            ret = Tx.NetworkFee.CompareTo(otherTx.NetworkFee);
            if (ret != 0) return ret;
            // Transaction hash sorted descending
            return otherTx.Hash.CompareTo(Tx.Hash);
        }

So for implementing the feature; when prioritisationFee is used we should at least also set the HighPriority attribute. It has no cost but is the first thing checked. Then secondly we must increase networkFee with the value of prioritisationFee. -edit- correction. the high HighPriority attribute can only be set on transactions signed by the committee. This TX is validated in the VerifyStateDependent() routine in C#

ixje commented 2 years ago

completed in v5.2.0 release