-
Notifications
You must be signed in to change notification settings - Fork 6
{integrationtests, services, sorobanauth}: Support contract account invocation #165
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
Conversation
148d290
to
78541e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for contract account invocation by integrating Soroban operations along with updates to tests, error handling, and configuration. Key changes include:
- New tests and helper functions for identifying and processing Soroban-specific operations.
- Adjustments in transaction service logic to handle Soroban transactions (e.g. manual sequence incrementation and base fee reduction).
- Updates to error messages and configuration defaults regarding channel account usage and signature validation.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
pkg/utils/utils_test.go | Added tests for Soroban operation type detection and conversion. |
pkg/utils/utils.go | Introduced SorobanOpTypes and helper functions (IsSorobanXDROp, etc.). |
pkg/sorobanauth/sorobanauth.go & _test.go | Updated authorization logic and tests to handle forbidden signers. |
internal/tss/utils/operation_builder*.go | Refined source account enforcement for Stellar Classic vs Soroban ops. |
internal/tss/services/transaction_service.go | Modified transaction construction and fee handling for Soroban flows. |
internal/integrationtests/* | Updated integration tests and fixture functions for Soroban operations. |
cmd/utils/global_options.go | Adjusted default base fee configuration for transactions. |
internal/serve/serve.go & httphandler/tss_handler.go | Updated server routing and error handling for TSS endpoints. |
internal/signing/*.go | Amended signature client mocks and channel account error handling. |
Comments suppressed due to low confidence (3)
internal/serve/serve.go:38
- The removal of OperationTypeInvokeHostFunction from the blockedOperationTypes list should be reviewed to ensure it aligns with the intended security model for allowed operations.
xdr.OperationTypeInvokeHostFunction,
cmd/utils/global_options.go:65
- The default flag value for the base fee was increased significantly from 100 * txnbuild.MinBaseFee to 10000 * txnbuild.MinBaseFee. Please confirm that this change is intentional and aligns with the required fee scaling for transactions.
FlagDefault: 10000 * txnbuild.MinBaseFee,
internal/tss/services/transaction_service.go:132
- Manually incrementing the sequence number while disabling IncrementSequenceNum may lead to subtle concurrency issues. It is recommended to double-check that this approach consistently maintains correct transaction ordering in all cases.
Sequence: channelAccountSeq + 1,
5e75b67
to
34f7716
Compare
… the SourceAccount to be empty for Soroban ops.
…pts` variadic parameter.
…ll Soroban operations by adding support for ExtendFootprintTtl and RestoreFootprint.
…sSourceAccount, as long as the operation source account is set to something different from the channel account address.
…robanCredentialsTypeSorobanCredentialsSourceAccount
…the buildTx endpoint.
fb8ac20
to
461f24a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few small comments.
Also, can you please add some more comments in the important functions for someone new to understand.
} | ||
|
||
return opXDR, string(simResBytes), nil | ||
op.Auth = simulateResults[0].Auth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we using only the 0th index here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question!
SimulateResults is a slice because the original design aimed to support multiple contract invocations within a single transaction. That plan was later dropped, and now only one contract invocation is allowed per transaction.
I asked around, and it seems the slice structure is just a leftover from that earlier design that never fully landed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include more comments explaining this and other parts of the code:
} | ||
|
||
switch sorobanOp := operations[0].(type) { | ||
case *txnbuild.InvokeHostFunction: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can actually combine the switch-case conditions into a single line:
case *txnbuild.InvokeHostFunction, *txnbuild.ExtendFootprintTtl, *txnbuild.RestoreFootprint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. The reason for doing 3 cases with the same (apparent) inner code is because we have an interface at operations[0]
but we need to set a parameter not exposed by that interface. The .Ext
parameter is only available at the concrete types *txnbuild.InvokeHostFunction
, txnbuild.ExtendFootprintTtl
, and txnbuild.RestoreFootprint
and we need to parse the interface to the individual type in order to set that parameter.
Go doesn't have the concept of union types (common in typescript), so there's no way around it AFAIK.
wallet-backend/internal/tss/services/transaction_service.go
Lines 207 to 216 in 461f24a
switch sorobanOp := operations[0].(type) { | |
case *txnbuild.InvokeHostFunction: | |
sorobanOp.Ext = transactionExt | |
case *txnbuild.ExtendFootprintTtl: | |
sorobanOp.Ext = transactionExt | |
case *txnbuild.RestoreFootprint: | |
sorobanOp.Ext = transactionExt | |
default: | |
return txnbuild.TransactionParams{}, fmt.Errorf("%w: operation type %T is not a supported soroban operation", ErrInvalidArguments, operations[0]) | |
} |
Done in 0848476. |
What
Support contract account invocation.
Why
To make the wallet-backend production ready.
Known limitations
We'll enable the remaining operations in:
Issue that this PR addresses
#147
Checklist
PR Structure
all
if the changes are broad or impact many packages.Thoroughness
Release