FaultException can be non-empty even in Halt state when there were
problems with stack marshaling to JSON.
Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
This is not the way intended in https://github.com/neo-project/proposals/pull/156.
-511 covers _both_ cases because users hardly can distinguish one from another,
it's just that our mempool implementation has error codes for both..
Signed-off-by: Roman Khimov <roman@nspcc.ru>
mempool.ErrInsufficientFunds is used when sender doesn't have enough
balance to pay the submitted transaction fees (-511 code according to
https://github.com/neo-project/proposals/pull/156). mempool.ErrConflict is
used when sender is not able to pay the overall transactions fee sum in
the pool (generic -500 error according to the proposal).
This bugfix is kind of breaking change for those users who relied on the
old -511 code previously returning "insufficient funds" error.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
If we're withdrawing funds to contract that has onNEP17Payment method,
then it may call Notary's withdraw one more time, but the account's
state is not yet updated by this moment.
The problem is similar to https://github.com/neo-project/neo/pull/2734.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Shouldn't affect things much, yet at the same time we no longer need any
connection after we're done with the request.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Add waiting for startSending to ensure that the client is ready before
the server starts sending messages.
Close#3005Close#3312
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
The theory is:
* we add a block
* it triggers notary
* which can process the fallback before we're to setFinalizeWithError
* it'll fail and require an additional block to enter, but it's never added
* FAIL
The solution is:
* always add an additional block, but treat the first fb specially
Signed-off-by: Roman Khimov <roman@nspcc.ru>
And refactor some code a bit, don't use bytes.Clone where type-specific
helpers may be used instead.
Close#2907.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
It's a bug since Prefix is shared between all iterator items and
appending is not enough. If prefix has enough capacity, then new slice
won't be created and the previous item's prefix will be changed.
This commit fixes the following test failure caused by moving from
bytes.Clone to slice.Copy:
```
--- FAIL: TestComlileAndInvokeFunction/test_Storage.Find (0.02s)
--- FAIL: TestComlileAndInvokeFunction/test_Storage.Find/keys_only (0.01s)
contract_test.go:866:
Error Trace: /home/anna/Documents/GitProjects/nspcc-dev/neo-go/cli/smartcontract/contract_test.go:866
Error: Not equal:
expected: []stackitem.Item{(*stackitem.ByteArray)(0xc000a1cdf8), (*stackitem.ByteArray)(0xc000a1ce10)}
actual : []stackitem.Item{(*stackitem.ByteArray)(0xc000a1cdb0), (*stackitem.ByteArray)(0xc000a1cdc8)}
Diff:
--- Expected
+++ Actual
@@ -2,3 +2,3 @@
(*stackitem.ByteArray)((len=8) {
- 00000000 66 69 6e 64 6b 65 79 31 |findkey1|
+ 00000000 66 69 6e 64 6b 65 79 32 |findkey2|
}),
Test: TestComlileAndInvokeFunction/test_Storage.Find/keys_only
--- FAIL: TestComlileAndInvokeFunction/test_Storage.Find/both (0.01s)
contract_test.go:881:
Error Trace: /home/anna/Documents/GitProjects/nspcc-dev/neo-go/cli/smartcontract/contract_test.go:881
Error: Not equal:
expected: []stackitem.Item{(*stackitem.ByteArray)(0xc000515920), (*stackitem.ByteArray)(0xc000515938)}
actual : []stackitem.Item{(*stackitem.ByteArray)(0xc000515848), (*stackitem.ByteArray)(0xc000515860)}
Diff:
--- Expected
+++ Actual
@@ -2,3 +2,3 @@
(*stackitem.ByteArray)((len=8) {
- 00000000 66 69 6e 64 6b 65 79 31 |findkey1|
+ 00000000 66 69 6e 64 6b 65 79 32 |findkey2|
}),
Test: TestComlileAndInvokeFunction/test_Storage.Find/both
```
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Revert 5f6c01336c, remove all multierror
related nolint comments and use multierror wrapping instead.
Close#2906.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
It contains several simple signature accounts that are not related to
network committee or validators. Needed for tests, existing
`testwallet.json` can't de reused since some tests need testing wallet
with a single account.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
We have smartcontract.ParameterPair structure that can be properly
marshalled and passed to RPC server as an element of smartcontract.Map
structure. However, RPC server can't unmarshal map values properly
without this change.
This change is compatible with C# node.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
s.Shutdown() does not wait for all goroutines of the node server to
finish normally just because the server exits without dependent
goroutines awaiting. Which causes logs to attempt to write after the
test has ended. The consequence of this bug fix is that corresponding
tests are fixed.
Close#2973Close#2974
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Added sync logs for every service separately to provide the ability to
have a custom logger for each service. This commit makes the code follow
the zap usages rules: `Sync calls the underlying Core's Sync method,
flushing any buffered log entries. Applications should take care to
call Sync before exiting.`
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Start of some services is bound to blockchain subscriptions, and thus,
can't be run before the blockchain notifications dispatcher.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Previously user should Start server in a separate goroutine. Now
separate goroutine is created inside the Start(). For normal server
operation, the caller should wait for Start to finish. Also, fixed
TestTryInitStateSync test which was exiting earlier than logs are
called.
Close#3112
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This one doesn't really work now, it's Legacy. Replace with something N3-ish.
Thanks @lock9 for reporting.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Scenario:
1. Two messages were read from the connection `p.conn`
2. The first message has started to be processed
3. The second message was queued to be added to the channel `p.incoming`
4. Processing of the first message failed with an error
5. TCP peer is closed, but processing of the second message continues
Signed-off-by: Dmitrii Stepanov <dima-stepan@yandex.ru>
We have a full list of public keys in the import-multisig command, so if
we have a key in the wallet that corresponds to one of these keys
(simple sig), just reuse it for the account automatically
Closes#3266
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Autogenerated RPC wrapper used underscores to differentiate between
methods/event overloads. Now it adds increasing suffices instead.
Close#3296
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
ProtocolConfiguration section must include stand by committee and the
number of validators or committee/validators history.
Close#3247
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Let the user know whether it's main or fallback transaction that failed
to be relayed to the network.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Try to subscribe for headers firstly, and then if RPC server doesn't
have this ability, fallback to block subscriptions to manage transaction
awaiting.
Close#3260.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Adjust names of all used structures, no need to duplicate `Waiter` everywhere,
we already in the `waiter` package. Also, adjust comments to Actor so that links
to Waiter are properly described in docs.
Ref. #3265.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
It can be used to work with the results of
CreateCallAndPrefetchIteratorScript() execution. The first item must be
an array and the optional second item must be an iterator, containing
remaining elements.
Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
There is CreateCallAndUnwrapIteratorScript() which can traverse
iterator for nodes with sessions disabled. For other nodes this may
still be beneficial: if there is a small number of items, we might read
(or prefetch) all of them in one request. However, this script continues
to work even for large collections, returning both accumulated array and
remaining iterator.
Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
There are use-cases when not only Actor, but also Invoker and even
simple RPC client must wait (e.g. sendtx or dumptx CLI commands). Actor
requires optional signers in constructor, and it's not always
appropriate to create Actor only to be able to use Waiter, sometimes
it's needed to use only Waiter without Actor.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
Change first argument of NewWaiter to be able to directly accept RPC
Client and export for external usage.
Refs #3244.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
BlockFilter has PrinaryIndex of int type while block.Block structure
itself has PrimaryIndex of byte. It's needed to prevent changing
filters field type and all associated subscriptions logic on
server side.
Refs #3241.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
The text must appear as the first line of a properly formatted Go //
comment, and that comment must appear before but not be attached to the
package clause and before any /* */ comment.
Closes#3254
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
New event is to notify the user about header's content by the moment
when block is stored (which happens after block's processing). This is
needed for proper Waiter work.
Closes#2751.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
dBFT doesn't use validators got from this call to GetValidators callback,
because NeoGo doesn't properly set WithGetConsensusAddress, and thus
this call can be safely skipped. Instead, NeoGo fills NextConsensus field
by itself in NewBlockFromContext callback.
This commit technically doesn't perform any functional changes and doesn't
affect the problem described in #3253 in any way. This commit is just a
removal of the code that was never used by NeoGo library.
This commit is a direct consequence of https://github.com/nspcc-dev/dbft/issues/84.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
We have cache update mechanism (Neo's cache votesChanged flag), it must
be used for current epoch and new epoch cached values update. And the
cached current/new epoch values themselves must always contain valid
information for the current/new epoch. These cached values must only be
changed once per epoch, never set them to nil.
This commit prevents CN node panic described in #3253 when dBFT tries
to retrieve new epoch validators with some votes modifications made
before at the same dBFT epoch.
Close#3253.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This was recently added in neotest, but working with the real RPC is
still not enjoyable. This commit extends `wallet.Account` with
invocation script builder to aid network fee calculations and signing.
Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com>
Add new filter NotaryRequestFilter, support for filtering
NotaryRequestEvents by mempoolevent.Type
(added or removed).
Closes#2425.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
StateRootInHeader depends on it, so we better immediately return error
if client is not initialised.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
I had some reason to suspect something is wrong here (but it's all OK). Even
though this is kinda tested in TestDeployGetUpdateDestroyContract, it uses
internal APIs and with neotest we can ensure it work OK for a complete tx/block
environment. So, won't hurt having these tests as well.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
No functional changes, just moved a part of emit.Array to a separate
exported method. It may be useful for contract-based witness invocation
scripts construction and not only. Ref.
https://github.com/nspcc-dev/neo-go/pull/3233#discussion_r1407786333.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Users of NeoGo interop package may have a demand to use these limits
for custom purposes, it would be nice to have them as constants.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Perform initialisation of StateRoot service with designated
StateValidator's node list in the service constructor. There's no need
to wait until the next role update event, and it may lead to inaccuraces
in service work on SIGHUP/server restart.
A part of #3228.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Initialise services dependant on roles designation based on N+1
block so that Genesis roles extension work properly. There's not
much sence to fetch node roles information for the latest persisted
block because Designation contract itself makes designated nodes
responsible since the next subsequent block.
A part of #3228.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
To be able running the node from any working directory by simply
pointing the relative-path as prefix for relative parameters set in
config.
Closes#3179.
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
It affects both Debug data and bindings, otherwise two unnamed structures can
get any of unnamed/unnamedx names depending on particular invocation.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Manifest will be a part of the state.Contract which will be checked on its
way to the storage. Tiny optimisation which allows not to serialize manifest
twice. Ref. https://github.com/nspcc-dev/neo-go/pull/3218#discussion_r1402374232.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Unfortunately, when import cycle happens somewhere deep in the import chain we
dont't get an error from packages.Load(). But it leaves some imports
uninitialized, so at least we can check for them.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Otherwise it's undertermined which of two unnamed structures will get "Unnamed"
and "UnnamedX" which can break the test from time to time.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
Type data is added while walking through function ins/outs even if we're to
throw this function away. But we don't need it, these types are not used, so
we can deal with the main part of #3071 by optimizing this out.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
This method returns persisted block height and doesn't take into account
persisting block height. Some of the callers of this method relay on
the wrong assumption that BlockHeight() returns persisting block index.
Fix improper usages of this method and adjust tests. Ref.
61a066583e/src/Neo/SmartContract/ApplicationEngine.cs (L634).
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
We already have tests for Permission deserialisation, so port the first
part of https://github.com/neo-project/neo/pull/2948.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
We have this log on the network server side, but it would also be
useful in case of failed blockchain initialization.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Refactored native NeoToken cache scheme introduced in #3110 sometimes requires
validators list recalculation during native cache initialization process (when
initializing with the existing storage from the block that is preceded each N-th block).
To recalculate validators from candidates, native NeoToken needs an access to
cached native Policy blocked accounts. By the moment of native Neo initialization,
the cache of native Policy is not yet initialized, thus we need a direct DAO access
for Policy to handle blocked account check.
Close#3181.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
Disable the following linter warning:
```
superfluous-else: if block ends with call to panic function, so drop this else and outdent its block (revive)
```
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>