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

cmd: Improve logicsig with signer support for goal clerk send #6180

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nullun
Copy link
Contributor

@nullun nullun commented Nov 26, 2024

I was attempting to submit a payment transaction from an account that was rekeyed to a logic sig address, but I experienced two issues.

  1. The logic sig address would constantly replace my sender address when I included the logic sig, despite supplying a specific sender address I wanted to use.
  2. The signer address was being completely ignored.

This PR fixes those two points by firstly only setting the sender address as the logic sig address if a sender address hasn't been provided, then secondly setting the transactions AuthAddr if a signer is set.

I pieced together an expect test that simulates my scenario by first rekeying a normal account to a logic sig, then submitting a second transaction removing that rekey by including the logic sig and a signer on the transaction.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 51.88%. Comparing base (0bc3d7e) to head (984f9d8).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
cmd/goal/clerk.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6180      +/-   ##
==========================================
+ Coverage   51.86%   51.88%   +0.01%     
==========================================
  Files         639      639              
  Lines       85492    85501       +9     
==========================================
+ Hits        44344    44359      +15     
+ Misses      38331    38329       -2     
+ Partials     2817     2813       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

We could merge as-is, but I think it can be simplified.

Comment on lines +386 to +390
if account == "" {
fromAddressResolved = pha.String()
} else {
fromAddressResolved = accountList.getAddressByName(account)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The else of the program != nil test has some similar logic. It seems like each arm could assign to account if account is currently empty (in the lsig case, by hashing and such, in the non-lsig case by looking up the default), and then after the if/else we can unconditionally do fromAddressResolved = accountList.getAddressByName(account), just like the assignment to toAddressResolved is done unconditionally.

Comment on lines +480 to +487
var authAddr basics.Address
if signerAddress != "" {
authAddr, err = basics.UnmarshalChecksumAddress(signerAddress)
if err != nil {
reportErrorf("Signer invalid (%s): %v", signerAddress, err)
}
stx.AuthAddr = basics.Address(authAddr)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here again, I'm hoping we can remove some conditional logic, rather than add code to the program != nil case. But here I'm less confident.

Here it seems like the code that set authAddr could be unconditionally run before the whole if/else if/else. Then the authAddr could be used here and below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants