NethermindEth / NethermindEth/juno

Introduce new `TransactionWithSignature` interface

Open
#2,175 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

no-stale Refactor
Dominant language
Go
Stars
444
Forks
244
Avg merge
2d 15h
Merged PRs (30d)
78

Description

Right now all transactions implement Signature() method, but we don't need it for L1Handler and Deploy transactions (right now they return empty slice).
We already faced some issues with it, here is an example:

if txSignature := transaction.Signature(); len(txSignature) > 0 {
   digest.Update(txSignature...)
} else {
   digest.Update(&felt.Zero)
}

it was rewritten as:

switch transaction.(type) {
  case *DeployTransaction, *L1HandlerTransaction:
     digest.Update(&felt.Zero)
  default:
    digest.Update(transaction.Signature()...)
}

but code above may lead to more questions: why we're specifying exactly these transactions? is it specific to this function only or applicable to entire codebase?

It can be solved by introducing new interface type TransactionWithSignature (name only for example, I'm pretty sure there is a better naming):

type TransactionWithSignature interface {
   Signature() []*felt.Felt
}

which can be used in example above as:

switch transaction.(type) {
case TransactionWithSignature:
     digest.Update(transaction.Signature()...)
default:
     digest.Update(&felt.Zero)
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the transaction implementations and the call sites that invoke Signature(), especially the digest-update example in the issue. Confirm which transaction types provide signatures and define the interface boundary; done means callers no longer need to special-case concrete transaction types.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.