-
Notifications
You must be signed in to change notification settings - Fork 79
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
*: implement System.Blockchain.GetTransaction and System.Blockchain.GetBlock interops #1034
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1034 +/- ##
==========================================
+ Coverage 65.64% 65.95% +0.31%
==========================================
Files 190 187 -3
Lines 15993 15945 -48
==========================================
+ Hits 10498 10517 +19
+ Misses 4981 4909 -72
- Partials 514 519 +5
Continue to review full report at Codecov.
|
pkg/core/interop_system.go
Outdated
if index > height { | ||
return false | ||
} | ||
return index+MaxTraceableBlocks > height |
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.
return index <= height && index + MaxTraceableBlocks > height
?
pkg/interop/block/block.go
Outdated
func GetTransactions(b Block) []transaction.Transaction { | ||
return []transaction.Transaction{} | ||
func GetTransactions(b Block) []blockchain.Transaction { | ||
return []blockchain.Transaction{} |
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.
Implementation of this and next interop should also be changed.
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.
Oh, I see they were removed later. Probably worth removing before.
pkg/core/interop_system.go
Outdated
@@ -145,6 +145,10 @@ func bcGetTransactionHeight(ic *interop.Context, v *vm.VM) error { | |||
if err != nil { | |||
return err |
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.
Should we return -1
here now?
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.
For ErrKeyNotFound
sure, we may have dropped it already and it's perfectly fine.
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.
Changed to -1.
} | ||
block, err := ic.Chain.GetBlock(hash) | ||
if err != nil || !isTraceableBlock(ic, block.Index) { | ||
v.Estack().PushVal(stackitem.Null{}) |
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 should return after this.
v.Estack().PushVal(stackitem.Null{}) | ||
} | ||
index := v.Estack().Pop().BigInt().Int64() | ||
if index < 0 || index >= int64(len(block.Transactions)) { |
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.
C# implementation uses len-1
(and index+1
below). Probably 1st tx shouldn't be taken into account.
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.
That's just to compensate for consensusDataHash
, we don't have this problem.
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.
That's true.
v.Estack().PushVal(stackitem.Null{}) | ||
} | ||
index := v.Estack().Pop().BigInt().Int64() | ||
if index < 0 || index >= int64(len(block.Transactions)) { |
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.
That's just to compensate for consensusDataHash
, we don't have this problem.
pkg/core/interop_system.go
Outdated
return errors.New("wrong transaction index") | ||
} | ||
tx := block.Transactions[index] | ||
v.Estack().PushVal(tx.ToStackItem()) |
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 should put tx's hash here, not tx itself. And we should have a test for this interop also.
We don't need them anymore.
closes #1023 Now we put on stack stackitem.Array instead of Interop, so we don't need old transaction-related interops anymore. Removed the following interops: System.Transaction.GetHash Neo.Transaction.GetAttributes Neo.Transaction.GetHash Neo.Transaction.GetWitnesses Neo.Attribute.GetData Neo.Attribute.GetUsage Also removed the following duplicated NEO interop: Neo.Blockchain.GetTransaction
Update System.Blockchain.GetTransactionHeight and removed Neo.Blockchain.GetTransactionHeight interop as we don't need it.
Removed Neo.Block.GetTransaction and System.Block.GetTransaction interops. These interops were replaced by new System.Blockchain.GetTransactionFromBlock interop.
9df8300
to
61d81f7
Compare
closes #1025 Now we put on stack stackitem.Array instead of Interop, so we're able to use all available block properties without extra interop getters. Removed Neo.Blockchain.GetBlock interop as we don't need it anymore.
Updated System.Blockchain.GetBlock interop replaced the functionality of the following interops: System.Block.GetTransactions System.Block.GetTransactionCount Neo.Block.GetTransactions Neo.Block.GetTransactionsCount
61d81f7
to
8b7abd3
Compare
closes #1023 and #1025