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

Non-integer spec and multi-sig edits #837

Closed
wants to merge 98 commits into from
Closed

Non-integer spec and multi-sig edits #837

wants to merge 98 commits into from

Conversation

kevinhammond
Copy link
Contributor

Suggested changes to the non-integer spec document.

exact way using rational numbers and arbitrary precision integers which are
available in most programming languages or via external libraries.~\footnote{The
The Shelley ledger specification~\cite{shelley_spec}\khcomment{I'd prefer a reference format that was shorter e.g. [G\"ud19], and made it clearer what were internal, public, published etc. documents} and the Ouroboros
protocol~\cite{ouroboros} use non-integral calculations in a few places. Most of these can be
Copy link
Contributor

Choose a reason for hiding this comment

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

could that be achieved by changing the bibstyle and resorting to a standardized way to format bibentries ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think so. Best with the alpha or similar style. Custom labels are probably the easy way. They could conceivably be auto-generated (e.g. on a per-biblio basis), but this might need some bibstyle hacking. http://www.math.cmu.edu/~gautam/sj/blog/20171208-bibtex-custom-label.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd also suggested cross-referencing to @polinavino, where we are e.g. referring to a section/subsection of a document. Easier for the reader, but needs to be kept in sync (maybe using imported LaTeX refs using toc entries - I've done this before on a complex document).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've applied a suggested format. Needs @kantp to agree on it or something else.

Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
@kevinhammond kevinhammond changed the title Khedits Non-integer spec edits Sep 5, 2019
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
@kevinhammond kevinhammond changed the title Non-integer spec edits Non-integer spec and multi-sig edits Sep 11, 2019
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
Signed-off-by: Kevin Hammond <12563287+kevinhammond@users.noreply.github.com>
and~\ref{sec:native-script-interp} for details.
sub-types $\AddrVKey$ and $\AddrScr$. Key addresses, of type $\AddrVKey$, are
used as in the original specification; script addresses contain the hash\khcomment{Is this enough - two scripts could conceivably have the same hash, couldn't they?}
of the validator script, and are used to lookup the script.
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, just like hash keys

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're using a hash, then equivalent hashes do not mean equivalent scripts (unless you have a unique hash [which I would consider a signature]). For the keys you presumably accept a low probability of clashing. Here you accept some possibility of incorrect validation (which could perhaps cause a runtime error).

shelley/chain-and-ledger/formal-spec/multi-sig.tex Outdated Show resolved Hide resolved
(Figure~\ref{fig:types-scripts}) sub-type of $\Addr$ carries the necessary
information and can therefore be part of a transaction output that consists of a
corresponding validator script. The output can only be spent if the matching script is
provided\khcomment{?} and validates its input. The necessary information is carried by the
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the question here? Effectively, if an output requires a script, then one has to provide a script that hashes to the value in the address and validates the input it receives (in the case of MSig the set of signatures)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the word "provided" correct

of a script address. The domain of the accessor function $\fun{paymentHK}$ is
changed to pubkey addresses. The domains of the accessor functions
changed to public key\khcomment{?} addresses. The domains of the accessor functions
Copy link
Contributor

Choose a reason for hiding this comment

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

the return value of paymentHK is the key hash, so we either need to restrict the function domain or make the codomain an option type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question was whether pubkey should expand to "public key"

as defined in the formal ledger specification~\cite{shelley_spec} to carry an additional witness
type. This is achieved by explicitly defining $\TxWitness$ to be
a pair of a public key witness and a script witness.\khcomment{I don't understand the difference between a tuple and a $\times$ type.}
The accessor function
Copy link
Contributor

Choose a reason for hiding this comment

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

this is meant to be a product type. Should we make this TxWitness = VKey |-> Sig x ScriptHash |-> Script ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something to check notationally across all the docs

\begin{enumerate}
\item equality of the hashed script with the hash that is stored in the output to spent;
\item that the script validates the transaction; and
\item that it is precisely\khcomment{or includes? - made a change in the figure} the set of the scripts required for the transaction (as
Copy link
Contributor

Choose a reason for hiding this comment

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

here we do not allow more script witnesses than necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that part of the design?

shelley/chain-and-ledger/formal-spec/multi-sig.tex Outdated Show resolved Hide resolved
Figure~\ref{fig:functions-witnesses}. Figure~\ref{fig:functions-witnesses} also shows the function
$\fun{scriptNeeded}$ that computes the required script hashes from the set of
spent inputs that are locked by scripts and the consumed withdrawals that are locked by scripts.
\khcomment{witsVKeyNeeded is identical to the original, presumably?}\khcomment{Figure overflows to the left}
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, done

can be added to the transaction fees or as gas cost. The scripts can be realized
with only limited requirements on functionality on the script language.

can be added to the transaction fees or as gas cost. \khcomment{Assumes transactions are independent.}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this. The creator of the transaction knows how many signatures are present and knows the script, which means that the creator can statically check for how long the script can run (actually for MSig, how many reduction steps are required for False / True). How is this influenced by other transactions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there was a dependency between transactions. It may be that by design this can't happen.

shelley/chain-and-ledger/formal-spec/multi-sig.tex Outdated Show resolved Hide resolved
Remove todo notes where comment is taken care of.
This broke the `inference` rules rendering for whatever reason
mgudemann added a commit that referenced this pull request Sep 17, 2019
mgudemann added a commit that referenced this pull request Sep 17, 2019
range of \emph{real numbers}.
These include the exponential function
$e^{x}, x \in \mathbb{R}$, which is used to calculate how refunds decay over time, and general non-integral exponentiation
$x^{y}, x, y \in \mathbb{R}$, which is used to \khcomment{MG, please fix!}.
Copy link
Contributor

Choose a reason for hiding this comment

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

@kevinhammond what is here to fix ? In a commit, you removed " ... calculate how refunds decay over time, and general non-integral exponentiation" why ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make it clear to the reader why these are needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can expand if you think this is needed.


There exist two main approaches for approximation: Taylor / MacLaurin series and
Other than basic arithmetic (addition, multiplication, subtraction, and division\khcomment{check for uses of division in the algorithms -- I spotted some
uses, but it might be possible to remove them using e.g. rotation/scaling.}),
Copy link
Contributor

Choose a reason for hiding this comment

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

any further ideas here? I think the divisions we are talking about here are mostly tied to the rewards scheme and more or less fixed in the design spec. So we would need equivalent calculations with fewer divisions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should discuss this. If division is not needed, then this can either make things more efficient, or sometimes simplify proof/error checks (by avoiding divide-by-zero, for example). But I'd be inclined to think we've done enough for now in terms of optimisation.

convergence speed, in particular for the natural logarithm.
Our experimental results have shown that continued fractions converge faster, in particular for the natural logarithm.

\khcomment{Give captions for the plots. Combine the plots from Figs. 1 and 2 into a single figure (one above the other?). Do the same for Figs. 3 and 4.}
Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with this is that the vastly different y-axis will make one almost invisible, visually close to indistinguishable from the x-axis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant one figure, with two plots... Keep the actual plots as-is :)
subfigure sometimes works for this, but you may not need that.

@mgudemann
Copy link
Contributor

cleaned up and done in #858 and #859

@mgudemann mgudemann closed this Oct 4, 2019
kevinhammond pushed a commit that referenced this pull request Oct 28, 2019
kevinhammond pushed a commit that referenced this pull request Oct 28, 2019
@kevinhammond kevinhammond deleted the khedits branch October 30, 2019 12:18
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.

None yet

2 participants