Print name of invoked method in transaction #3
Labels
No labels
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/monza#3
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "AndrewDanilin/monza:print_name_of_invoked_method_in_transacation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Signed-off-by: AndrewDanilin andnilin@gmail.com
I created an ExtractUtilites.go file that has an ExtractCalls function that parses the bytecode and returns the SYSCALL opcode.
Also I add methods that cache SYSCALL parameters into bbolt DB.
[#2] print name of invoked method in transactionto кrint name of invoked method in transactionкrint name of invoked method in transactionto Print name of invoked method in transaction@ -0,0 +1,138 @@
package internal
Internal package usually is an aggregation of packages, which cannot be imported from external repositories. So I suggest to move this file in a separate internal package (see
/internal/chain
) and use lowercase name for the file, e.g.@ -0,0 +16,4 @@
}
// ExtractCalls Extract parameters of SYSCALL opcode from bytecode of transaction
func ExtractCalls(script []byte) ([]SyscallParameters, error) {
Let's write some unit tests for this function. Use correct and incorrect bytecodes. Also you can try a bytecode with multiple contract method invocations.
@ -0,0 +49,4 @@
offset1 += 4
}
src := script[offset1 : offset1+n]
nameOfMethod, _ := hex.DecodeString(hex.EncodeToString(src))
Are we 100% sure these decoding errors never happen?
ExtractCalls
returns error anyway so it is cheap to return error here in case of something bad happens with the byte code. Same forUint160DecodeBytesBE
.@ -0,0 +75,4 @@
// Skip n bytes (params of current opcode) to next opcode
err := skipBytes(&i, script)
if err != nil {
return nil, fmt.Errorf("%s%v", "Error while parsing bytecode:", err)
This error formatting is a bit odd:
@ -5,2 +5,4 @@
"encoding/binary"
"encoding/json"
"fmt"
"git.frostfs.info/TrueCloudLab/monza/internal"
Don't forget to set up your IDE to group import dependencies or use something like goimports.
We are trying to use two groups as it stated in uber style guide.
Sorry for a long time inactive, my laptop was tired and wanted to break down :(
I added some tests for checking correct behaviour of ExtractCalls function.
Looks good! Please, take your time to update commit messages. At TrueCloudLab, we try to use recommendations from this article.
In short: start commit headers with upper-case. Optionally add
[#2]
prefix so it will be easier to track commits from issue #2.71829af56a
toaca2229ab7