Skip to content
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

disable some lua functions #306

Merged
merged 18 commits into from
May 17, 2024
Merged

Conversation

kroggen
Copy link
Member

@kroggen kroggen commented Oct 31, 2023

This PR removes some Lua functions, starting on hardfork 4:

  • package module
  • require
  • getfenv
  • setfenv
  • getmetatable
  • setmetatable
  • rawget
  • rawset
  • rawequal
  • string.dump

They continue existing for previous hardforks for compatibility with gas computations. The first 4 are also available when Aergo is build in debug mode

This PR also does not build some disabled packages (os, io, jit, debug) and so the code cannot be accessed in any way

It includes tests to make sure the disabled modules and functions are not available

@kroggen kroggen added the V4 To be released on hardfork V4 label Oct 31, 2023
@kroggen kroggen added the check hardfork Run sync test with the PR label Oct 31, 2023
@kroggen kroggen changed the title disable the require statement disable some lua functions Nov 2, 2023
@kslee8282
Copy link
Member

sync success

@kslee8282
Copy link
Member

Nov 1 05:18:42.040 INF ../go/aergo/cmd/aergosvr/aergosvr.go:100 > AERGO SVR STARTED branch=topic/disable-lua-require module=asvr revision=b9d3bb50

@kroggen
Copy link
Member Author

kroggen commented Nov 9, 2023

@kslee8282
OK, but a new sync test will be needed later. But probably not just for this PR.
We can merge many into one branch to make a sync test for V4 later

@kroggen kroggen removed the check hardfork Run sync test with the PR label Nov 9, 2023
getmetatable(bignum.number(0)).__add = function(x,y) return x-y end
if getmetatable ~= nil then
-- override the __add metamethod on bignum module
getmetatable(bignum.number(0)).__add = function(x,y) return x-y end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't review deeper code about getmemtable, but it doesn't look like addtion rather substraction. Anyway, if this code did not cause any problem, we can leave this as is, since this commit don't change the code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this test overrides the add (+) operator with a subtraction (-) to check if that feature of overriding functions is possible. the feature is disabled by this PR

Copy link
Member

@hayarobi hayarobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kroggen kroggen merged commit eeb403d into topic/hardfork-v4 May 17, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V4 To be released on hardfork V4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants