-
Notifications
You must be signed in to change notification settings - Fork 2
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
poc: Receive trait for receiving coins #206
base: main
Are you sure you want to change the base?
Conversation
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.
Great start. As part of this PR I think we should also implement this part of the design:
If there's no receive and no fallback method, a CALL or inbound tx with > 0 amount should fail.
Basically, a spend to a spawned account with no receive method should fail.
We can debate whether to fail txs with a method selector to a method that's not marked payable
until we have #202
interface/src/lib.rs
Outdated
let recipient_account = if let Some(account) = self.programs.get(&msg.recipient) { | ||
account.clone() | ||
} else { | ||
return ExecutionResult::failed(0); |
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 don't think this should fail if the recipient doesn't exist. We still allow a coin transfer to a "stub" account that hasn't been spawned yet.
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.
How should it find the recipient's program code to call it? If the recipient
isn't spawned yet, the host cannot know its program code.
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.
Program code doesn't matter. In this case the host just moves the coins. See https://github.com/spacemeshos/go-spacemesh/blob/cabff437876e665e2f77ae458c578f7067aa5c7e/vm/host/host.go#L224-L241.
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.
As should be clear from the code snippet, it's only okay for a CALL without data. If there are args, and the recipient account hasn't been spawned, the tx will fail.
e253708
to
fb8dce5
Compare
🚧
Related issue: #204