-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(PE-7196): add msg.reply to all apis #72
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -90,6 +90,7 @@ function ant.init() | |||||
local recipient = msg.Tags.Recipient | ||||||
if msg.From ~= Owner then | ||||||
utils.Send(msg, { | ||||||
Target = msg.From, | ||||||
Action = "Transfer-Error", | ||||||
["Message-Id"] = msg.Id, | ||||||
Error = "Insufficient Balance!", | ||||||
|
@@ -108,6 +109,7 @@ function ant.init() | |||||
local balRes = balances.balance(addressToCheck, msg.Tags["Allow-Unsafe-Addresses"]) | ||||||
|
||||||
utils.Send(msg, { | ||||||
Target = msg.From, | ||||||
Action = "Balance-Notice", | ||||||
Balance = tostring(balRes), | ||||||
Ticker = Ticker, | ||||||
|
@@ -123,13 +125,14 @@ function ant.init() | |||||
bals[k] = tostring(v) | ||||||
end | ||||||
|
||||||
utils.Send(msg, { Data = json.encode(bals) }) | ||||||
utils.Send(msg, { Target = msg.From, Data = json.encode(bals) }) | ||||||
end) | ||||||
|
||||||
createActionHandler(TokenSpecActionMap.TotalSupply, function(msg) | ||||||
assert(msg.From ~= ao.id, "Cannot call Total-Supply from the same process!") | ||||||
|
||||||
utils.Send(msg, { | ||||||
Target = msg.From, | ||||||
Action = "Total-Supply", | ||||||
Data = tostring(TotalSupply), | ||||||
Ticker = Ticker, | ||||||
|
@@ -149,6 +152,7 @@ function ant.init() | |||||
Handlers = utils.getHandlerNames(Handlers), | ||||||
} | ||||||
utils.Send(msg, { | ||||||
Target = msg.From, | ||||||
Action = "Info-Notice", | ||||||
Tags = info, | ||||||
Data = json.encode(info), | ||||||
|
@@ -225,8 +229,8 @@ function ant.init() | |||||
return initialize.initializeANTState(msg.Data) | ||||||
end) | ||||||
|
||||||
createActionHandler(ActionMap.State, function(msg) | ||||||
notices.notifyState(msg, msg.From) | ||||||
createActionHandler(ActionMap.State, function() | ||||||
return utils.getState() | ||||||
end) | ||||||
|
||||||
-- IO Network Contract Handlers | ||||||
|
@@ -248,7 +252,7 @@ function ant.init() | |||||
Name = name, | ||||||
}) | ||||||
|
||||||
ao.send({ | ||||||
utils.Send(msg, { | ||||||
Target = msg.From, | ||||||
Action = "Release-Name-Notice", | ||||||
Initiator = msg.From, | ||||||
|
@@ -275,7 +279,7 @@ function ant.init() | |||||
["Process-Id"] = antProcessIdToReassign, | ||||||
}) | ||||||
|
||||||
ao.send({ | ||||||
utils.Send(msg, { | ||||||
Target = msg.From, | ||||||
Action = "Reassign-Name-Notice", | ||||||
Initiator = msg.From, | ||||||
|
@@ -329,6 +333,7 @@ function ant.init() | |||||
AOS provides a _boot handler that is designed to load Lua code on boot. | ||||||
This handler OVERRIDES this and replaces it with our ANT state initialization handler. | ||||||
|
||||||
NOTE: if we use utils.Send here memory blows up for some reason | ||||||
]] | ||||||
Handlers.once("_boot", function(msg) | ||||||
return msg.Tags.Type == "Process" and Owner == msg.From | ||||||
|
@@ -339,28 +344,22 @@ function ant.init() | |||||
initialize.initializeANTState(msg.Data) | ||||||
end, utils.errorHandler) | ||||||
if not status then | ||||||
utils.Send( | ||||||
msg, | ||||||
notices.addForwardedTags(msg, { | ||||||
Target = Owner, | ||||||
Error = res or "", | ||||||
Data = res or "", | ||||||
Action = "Invalid-Boot-Notice", | ||||||
["Message-Id"] = msg.Id, | ||||||
}) | ||||||
) | ||||||
ao.send(notices.addForwardedTags(msg, { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is ao.send? and does it have the wrapper logic for using msg.reply? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be clear, this memory blowup happens not during compile time or at any other message, but rather on I did investigate as to why, and it seems that adding utils.Send increases the complexity of the function call, expanding the memory it uses on the stack, causing the stack to give a memory out of bounds error - thats my theory, anyway. I think for the moment we should leave utils.Send out of this call and further investigate in another PR/SPIKE as to what options are available to us here. The main solution - apart from not including the util - is to simply raise the stack memory. However I don't want to create a lua script that can be eval'd into one module and not another, especially since thats how our current evolve workflow works on the arns portal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As for where ao.send is, its from AOS - ao is available as a global. Its actually what utils.Send uses internally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Target = Owner, | ||||||
Error = res or "", | ||||||
Data = res or "", | ||||||
Action = "Invalid-Boot-Notice", | ||||||
["Message-Id"] = msg.Id, | ||||||
})) | ||||||
end | ||||||
end | ||||||
|
||||||
if Owner then | ||||||
utils.Send( | ||||||
msg, | ||||||
notices.credit({ | ||||||
From = msg.From, | ||||||
Sender = Owner, | ||||||
Recipient = Owner, | ||||||
}) | ||||||
) | ||||||
ao.send(notices.credit({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
From = msg.From, | ||||||
Sender = Owner, | ||||||
Recipient = Owner, | ||||||
})) | ||||||
end | ||||||
|
||||||
if AntRegistryId then | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// TODO: make this an auto generated file | ||
|
||
export default '12'; | ||
export default '13'; |
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.
Would it make sense to set this in utils.Send automatically if not present rather than making it the responsibility of the caller?
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.
Yes it would make sense to add it there - technically its not needed for msg.reply, and we only add this because of ao.send
If we don't, we actually send an invalid message if msg.reply is not present.
Im actually wondering if we even need to wrap ao.send like this, because we KNOW what AOS module we are building. This wrapping pattern is only for backwards compatibility with older AOS process, and with our reassign-to-evolve pattern it will be a new module of our choice anyways.
Also we may not always want to "reply". Sometimes we just want to send. Using reply probably doesnt hurt, but IDK what future integrations may be influenced with these extra tags.
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.
and in fact if my suspicions are correct, in that adding function calls is messing with stack memory, then we wanna be careful about that.