-
Notifications
You must be signed in to change notification settings - Fork 93
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
New Feature: Removes logic dependency #1363
New Feature: Removes logic dependency #1363
Conversation
* Update submodule, oapi-codegen * Migrate lint from golint to golangci-lint * Fix golangci-lint version in circleCI config * Fix postgres key type checks
48e5709
to
5daadb4
Compare
@@ -216,6 +216,7 @@ func MakeCreateAppTxn(sender basics.Address) transactions.SignedTxnWithAD { | |||
// MakeComplexCreateAppTxn makes a transaction that creates an arbitrary app. When assemblerVersion is set to 0, use the AssemblerDefaultVersion. | |||
func MakeComplexCreateAppTxn(sender basics.Address, approval, clear string, assemblerVersion uint64) (transactions.SignedTxnWithAD, error) { | |||
// Create a transaction with ExtraProgramPages field set to 1 | |||
// TODO how to handle this? |
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.
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.
I think this method needs to use the new logic package which should include methods like AssembleStringWithVersion
and AssembleString
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.
it's not ideal to change this method to take raw teal bytes since this would require users to first compile their teal program using something like goal then copy the bytes to the tests.
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.
Wouldn't that would require copying the entire teal assembler into this program?
I'm generally expecting that all of these Make*Txn
functions need to be replaced with Make*StateDelta
(or Add*ToStateDelta
) to accommodate the new interfaces. So this may end up being a non-issue with some of the followup work.
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.
AFAIK we need the following functions, not the entire logic package:
// MakeBoxKey creates the key that a box named `name` under app `appIdx` should use.
func MakeBoxKey(appIdx basics.AppIndex, name string) string {
/* This format is chosen so that a simple indexing scheme on the key would
allow for quick lookups of all the boxes of a certain app, or even all
the boxes of a certain app with a certain prefix.
The "bx:" prefix is so that the kvstore might be usable for things
besides boxes.
*/
key := make([]byte, boxNameIndex+len(name))
copy(key, boxPrefix)
binary.BigEndian.PutUint64(key[boxPrefixLength:], uint64(appIdx))
copy(key[boxNameIndex:], name)
return string(key)
}
// SplitBoxKey extracts an appid and box name from a string that was created by MakeBoxKey()
func SplitBoxKey(key string) (basics.AppIndex, string, error) {
if len(key) < boxNameIndex {
return 0, "", fmt.Errorf("SplitBoxKey() cannot extract AppIndex as key (%s) too short (length=%d)", key, len(key))
}
if key[:boxPrefixLength] != boxPrefix {
return 0, "", fmt.Errorf("SplitBoxKey() illegal app box prefix in key (%s). Expected prefix '%s'", key, boxPrefix)
}
keyBytes := []byte(key)
app := basics.AppIndex(binary.BigEndian.Uint64(keyBytes[boxPrefixLength:boxNameIndex]))
return app, key[boxNameIndex:], nil
}
// AppCallBytes represents an encoding and a value of an app call argument.
type AppCallBytes struct {
Encoding string `codec:"encoding"`
Value string `codec:"value"`
}
// NewAppCallBytes parses an argument of the form "encoding:value" to AppCallBytes.
func NewAppCallBytes(arg string) (AppCallBytes, error) {
parts := strings.SplitN(arg, ":", 2)
if len(parts) != 2 {
return AppCallBytes{}, fmt.Errorf("all arguments and box names should be of the form 'encoding:value'")
}
return AppCallBytes{
Encoding: parts[0],
Value: parts[1],
}, nil
}
The AppCallBytes struct requires the I also pulled out the basics package to try and remove more dependencies with these functions but we can curtail that if you want. |
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.
We do not need any of the abi/
code redefined since this package was already pulled into a separate repo which should be usable as a dependency.
Should these go in |
api/app_boxes_fixtures_test.go
Outdated
@@ -96,7 +97,7 @@ func setupLiveBoxes(t *testing.T, proc func(cert *rpcs.EncodedBlockCert) error, | |||
newBoxValue := "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" | |||
boxTxns := make([]*transactions.SignedTxnWithAD, 0) | |||
for _, boxName := range boxNames { | |||
expectedAppBoxes[firstAppid][logic.MakeBoxKey(firstAppid, boxName)] = newBoxValue | |||
expectedAppBoxes[firstAppid][logic.MakeBoxKey(indexerBasics.AppIndex(firstAppid), boxName)] = newBoxValue |
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.
sdk has AppIndex. reuse types from sdk whenever possible.
Resolves #1328 Removes the logic dependency from the indexer with the exception of AssembleStringWithVersion in account_testutil.go
58f3dd8
to
bac6824
Compare
Resolves #1328
Removes the logic dependency from the indexer with the exception of AssembleStringWithVersion in account_testutil.go
Summary
Explain the goal of this change and what problem it is solving. Format this cleanly so that it may be used for a commit message, as your changes will be squash-merged.
Test Plan
How did you test these changes? Please provide the exact scenarios you tested in as much detail as possible including commands, output and rationale.