Skip to content

hardhat: give unsigned targets a fixed version - #97

Open
martinpitt wants to merge 1 commit into
amutable:mainfrom
martinpitt:hardhat-unsigned-version
Open

martinpitt wants to merge 1 commit into
amutable:mainfrom
martinpitt:hardhat-unsigned-version

Conversation

@martinpitt

Copy link
Copy Markdown
Member

A build that writes its targets with --unsigned wants them to be reproducible. But the version came from the wall-clock time, so every build wrote a different file.

The version is as meaningless as the expiry there: a repository imports the file with --include-from, takes only its targets, and versions its own targets file when it signs it.

Write version "1" (the lowest TUF allows), the same way the expiry is zero.


Spotted in an attempt in amutable/tine#382 to make the file reproducible. I added a --ref-time SOURCE_DATE_EPOCH workaround for that in the meantime, but it doesn't feel quite right. It works though, just in case this is wrong/unwanted.

A build that writes its targets with `--unsigned` wants them to be
reproducible. But the version came from the wall-clock time, so every
build wrote a different file.

The version is as meaningless as the expiry there: a repository imports
the file with `--include-from`, takes only its targets, and versions its
own targets file when it signs it.

Write version "1" (the lowest TUF allows), the same way the expiry is
zero.

Signed-off-by: Martin Pitt <martin@amutable.com>
martinpitt added a commit to amutable/tine that referenced this pull request Nov 3, 2026
hardhat versions the targets by the wall-clock time, so every build of a
release wrote a different file. It shouldn't do that with `--unsigned`,
see <amutable/quarry#97>.

Until that lands, let's hand it SOURCE_DATE_EPOCH as its reference time
instead. Importing the targets into a repository keeps only their
entries, so their version does not matter.

Signed-off-by: Martin Pitt <martin@amutable.com>
@martinpitt
martinpitt requested a review from cyphar November 3, 2026 16:41
@cyphar

cyphar commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

No that is exactly what --ref-time is for, though we should probably obey SOURCE_DATE_EPOCH automatically (I guess tine auto-sets that?).

The reason we don't use monotonic counters for version numbers is that it would mean we cannot do releases without looking at the existing releases, and I'm a little worried that using --unsigned with some fixed version like 1 in this PR would result in people publishing a new snapshot with older versions (which clients would reject). In practice they do get bumped but I'd like to avoid that risk if possible -- once we have #90 it will probably be easier to shoot yourself in the foot like that.

@cyphar

cyphar commented Nov 3, 2026

Copy link
Copy Markdown
Member

Maybe take a look at #98?

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.

2 participants