Code Monkey home page Code Monkey logo

atm's Introduction

mt-mods github organization

About

This organization is a dedicated place for minetest mods and tools

Modders can place their projects under this umbrella to collaborate or hand off maintainership (see Guidelines)

NOTE: mt-mods isn't affiliated with the "official" minetest-mods organization

Community

Join the mt-mods community here:

Guidelines

Projects can be hosted here under the following conditions:

  • It must have at least one maintainer or be adopted by a member of this organization
  • PR's should be at least allowed for bugfixing
  • Changes should always be made with backwards-compatibility in mind
  • Choose an open license (https://opensource.org/licenses)

General notes:

  • This isn't a mod-graveyard, be open about new features/refactorings and discussions
  • Modding/Coding should be fun, be nice to each other and keep in mind that we are all doing this as a hobby
  • PR's should be created for any changes and approved by one mt-mods member (not yourself)
    • The following are exempted from the above and can be directly commited: simple bugfixes, trival changes, etc
  • Squashing and merging PR's is prefered unless there is an explicit reason not to

Links

Code snippets

atm's People

Contributors

6r1d avatar dennisjenkins75 avatar el-naso avatar gpcf avatar h-v-smacker avatar naturefreshmilk avatar niklp09 avatar ogelgames avatar swissalps avatar wsor4035 avatar wuzzy2 avatar

Watchers

 avatar  avatar  avatar

atm's Issues

[BUG] Player-triggerable resource leak in mod can crash the server

in atm/common.lua is the function atm.read_transactions(), which is called in the formspec handler, and leaks the opened file descriptor (there is no io.close(file)). Note that atm.write_transactions() does close the file.

This is a 1-line fix (I can have a PR ready in a few minutes).

Examining the code in atm/receive_fields_wt.lua shows that atm.read_transactions() is called when processing the form. One can crash a server by doing the following:

  1. Right click on a Wire-Transfer ATM node atm:wtt.
  2. Click on transactions.
  3. Repeatedly click Clear transactions. This is tedious, but an auto-mouse could easily do it.
  4. Each click leaks 1 file descriptor. Verified with while sleep 1; do ls -l /proc/$(pgrep minetest)/fd | grep _wt | wc -l; done.
  5. Once the process hits its max limit for file descriptors, sqlite cannot open its journal file when flushing updates to map.sqlite, so the server crashes. This might not affect a server using the postresql backend, but its still not good to leak file descriptors.

It seems that the server cleans up these file descriptors on its own, every few minutes. I suspect Lua garbage collection, but have no proof of this. So it is a race to click that button ~1000 times within 1 Lua GC interval.

I discovered this while writing a mod that THOROUGHLY removes a player's data from a server. This mod does way more than just invoke minetest.remove_player() and minetest.remove_player_auth(). The server kept crashing after removing ~1300 players. Suspecting a resource leak, I checked the open file descriptors while the mod was running and found this:

$ ls -l /proc/1342/fd
total 0
lr-x------ 1 user user 64 Jan  7 22:35 0 -> /dev/null
lrwx------ 1 user user 64 Jan  7 22:35 1 -> 'socket:[104300]'
lrwx------ 1 user user 64 Jan  7 22:35 10 -> 'socket:[124810]'
lrwx------ 1 user user 64 Jan  7 22:35 11 -> 'socket:[124814]'
lr-x------ 1 user user 64 Jan  7 22:35 12 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 13 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 14 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 15 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 16 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 17 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 18 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 19 -> /home/user/worlds/world/atm_wt_transactions
lr-x------ 1 user user 64 Jan  7 22:35 20 -> /home/user/worlds/world/atm_wt_transactions
...

atm initsalization takes much cpu time

no atm's placed in the world

 instrumentation                                       | min µs |   max µs | avg µs | min % | max % | avg %
 atm:                                                         |         0 |     53129 |         1 |      0.0 |  99.8 |   1.1
  - globalstep[1] .....................................  |         1 |     53129 |         2 |      0.0 |  99.8 |   1.8
  - on_player_receive_fields[2] ............... |         1 |        68    |         1 |      0.0 |  17.2 |   0.2
  - on_player_receive_fields[1] ............... |         1 |       192   |         1 |      0.0 |  11.9 |   0.2
  - on_joinplayer[1] ..................................|   2575 |    4848    |   3165 |      4.2 |   9.5 |   6.3

pipeworks money injection bug

not sure how to reproduce this yet but i found this in the crashlogs:

2023-04-18 01:09:12: ERROR[Server]: suspiciously large amount of objects detected: 868 in (-68,-1,20); removing all of them.
2023-04-18 01:09:45: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'pipeworks' in callback environment_Step(): /data/world//worldmods/atm/nodes.lua:60: attempt to perform arithmetic on a nil value
2023-04-18 01:09:45: ERROR[Main]: stack traceback:
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/atm/nodes.lua:60: in function 'insert_object'
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/pipeworks/item_transport.lua:341: in function 'on_step'
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/pipeworks/luaentity.lua:379: in function 'move_entities_globalstep_part2'
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/pipeworks/luaentity.lua:409: in function 'f'
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/monitoring/metrictypes/counter.lua:43: in function 'wrappedFn'
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/monitoring_pipeworks/globalsteps.lua:28: in function 'globalstep'
2023-04-18 01:09:45: ERROR[Main]: 	/data/world//worldmods/monitoring/builtin/globalstep.lua:33: in function </data/world//worldmods/monitoring/builtin/globalstep.lua:25>
2023-04-18 01:09:45: ERROR[Main]: 	/usr/local/share/minetest/builtin/game/register.lua:431: in function </usr/local/share/minetest/builtin/game/register.lua:417>

Improving ATM interface

ATMs currently require way too much clicking to deposit and withdraw money, especially when you want to exchange denominations.

I'd like it to include:

  • An inventory slot to deposit money. The items would never actually enter the inventory, but instead be immediately deposited.
  • A button to deposit all money in a player's inventory.
  • A field to specify exactly how much MG you want to withdraw. Could also include an "all" button.
  • Buttons to select the preferred denomination for withdraws.

When withdrawing the money would be split as needed, beginning with the preferred denomination. For example, if withdrawing 379MG with 10MG notes preferred, it would output 37x 10MG, 1x 5MG, and 4x 1MG.

Example formspec: (created with formspec_editor)

image

Not sure if this is the best way to do it, but it's the best idea I could come up with :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.