-
Notifications
You must be signed in to change notification settings - Fork 627
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
Linkdrop locust workload #11782
Linkdrop locust workload #11782
Conversation
While I try to run this I came across this error below:
This happens in InitLinkdrop while deploying the contract. I thought it was a problem with my code but then I tried to run the ft load and saw the same problem. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #11782 +/- ##
=======================================
Coverage 71.77% 71.77%
=======================================
Files 796 796
Lines 162939 162939
Branches 162939 162939
=======================================
+ Hits 116951 116953 +2
Misses 40934 40934
+ Partials 5054 5052 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
be00fa3
to
3fa4b31
Compare
return transaction.sign_function_call_transaction( | ||
self.sender.key, self.receiver_id, self.method, | ||
json.dumps(self.args()).encode('utf-8'), 100 * TGAS, self.balance, | ||
self.sender.get_nonce_for_pk(self.node, self.sender.key.account_id, |
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.
Is there any reason why you can't use self.sender.use_nonce()
here instead of get_nonce_for_pk
?
It is supposed to be a simpler and more scalable way because it caches the nonce betweek calls.
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.
Also, if we find a way to use the standard use_nonce()
here, we'll be able to use FunctionCall
as a base class, removing a lot of boilerplate.
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.
The way the linkdrop contract works is that it exposes an add_key function which lets drop creator call it and add a new access key to the contract.
The drop claimer then calls the contract function claim using this limited access key. So the contract is calling itself now basically.
use_nonce gave you the nonce for the full key for the smart contract currently in the runner. I needed nonce for the newly added access key which is limited and can only call claim function.
For every claim, you use a new access key hence caching old nonce won't 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.
I see, In this case I suggest inlining the call to mocknet_helpers.get_nonce_for_pk
here directly and removing the method Account::get_nonce_for_pk(self, ...)
, as the self
is not used in that method.
self.node = node | ||
|
||
#Create a new key pair, which would be a full access key to your account | ||
private_key, public_key = ed25519.create_keypair() |
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 have a helper class for this in pytest/lib/key.py:Key
.
You should be able to do something like:
key = Key.implicit_account()
# Use `key.sk` and `key.pk` as before.
|
||
from configured_logger import new_logger | ||
from locust import constant_throughput, task | ||
#from common.base import NearUser |
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.
nit: Remove commented out line
@task | ||
def create_and_claim_drop(self): | ||
# Generate a random key pair | ||
private_key, public_key = ed25519.create_keypair() |
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.
Same observation as above about using Key
class to get sk
and pk
instead
|
||
|
||
@events.init.add_listener | ||
def on_locust_init(environment, **kwargs): |
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 consistency, can you please move on_locust_init
and a parser method below into "common/linkdrop.py"?
This is how we do it for other workloads and it makes it easier to reuse multiple different workloads in a single locustfile.
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.
Can you please add instructions on how to download this file into https://github.com/near/nearcore/blob/master/pytest/tests/loadtest/locust/download_contracts.sh?
This will help us to refresh it in the future if it ever changes.
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.
Thanks for contributing a new Locust workload! I've left some comments, but I think it should be good to go very soon.
Thanks @Akashin for the review. I will work on all the comments immediately. Do you have any ideas why this is happening? |
This indicates that something is wrong with the deployed WASM for this smart contract.
But I agree that the error is quite cryptic. Maybe @Ekleog or @nagisa know how to debug this further? The FT smart contract is definitely well-formed, so I would double-check that you are testing this with the latest version of neard binary. The Apple M1 can definitely be the issue here, I'm not entirely sure about the status of support for this hardware. A few ways around this would be either running the workload in a VM or use Docker. |
re link error - not sure if this helps but I got the same error when specifying wrong function signature in the near test contracts. For me it was when I used u32 instead of u64 but it seems like you have a larger mismatch: It would be cool to provide some extra info in the error, most notably the method name.
|
For me it seems like it occurs while calling the init function after deploying the contract. |
The answer to this is a debugger attached to neard (ideally Due to the protocol requirements and such, having a quality insight into what's going wrong was not really a major goal for a long time and a project of building up a contract developer dev tool which would have helped with this never materialized. |
…s, adding contract download instructions.
An update on this. I tried to run the workload on the statelessnet instead of localnet and everything worked smoothly like before. |
def create_and_claim_drop(self): | ||
# Generate a random key pair | ||
keypair = key.Key.implicit_account() | ||
public_keys = [] |
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.
Nit: can just define this as public_keys = [keypair.pk]
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.
Or even inlining it in AddKey
constructor, as this variable it not used anywhere else.
…m base and used mocknet helpers directly.
I created a linkdrop workload as a part of statelessnet traffic generation program.
The load deploys a keypom contract and then try to create and claim linkdrop on it.