planetarium / lib9c

Lib9c is a library that contains key implementations of Nine Chronicles, a decentralized RPG developed with Libplanet. Lib9c includes Nine Chronicle's key features like in-game decisions and data models, which can be used to implement game core capabilities.
https://nine-chronicles.com/
GNU General Public License v3.0
26 stars 39 forks source link

Update `ActionObsolete` attribute indices if possible #1763

Open greymistcube opened 1 year ago

greymistcube commented 1 year ago

See #1745 for context.

Due to bad implementation, ActionObsolete attribute isn't working as intended. šŸ˜•

For example, if an IAction named SomeAction is decorated with

[ActionObsolete(1_000)]
public class SomeAction

although the attribute would suggest that SomeAction would be prohibited from being included in any Block<T> with index $1,000$ or higher, it is possible for a Block<T> of index $1,000$ or $1,001$ to include SomeAction. The actual current behavior for the network is to prevent SomeAction to be included starting from index $1,002$ and onwards. šŸ™„

As the policy has already been enforced, to resolve this issue, we might need to update all constants used for ActionObsolete attributes together with IsObsolete() logic so that we can use

[ActionObsolete(1_002)]
public class SomeAction

instead to make the network behave as intended.

Seems like there shouldn't be any dependency between the constants and game logic/design, but I'm not sure of there being a possible leakage somewhere (possibly undocumented hidden dependency by re-using the same constant's value with a different name somewhere else). šŸ˜

Probably someone each from @planetarium/9c-backend and @planetarium/nine-chronicles-engineers should confirm that this is a safe path to resolving the issue before being worked on.

boscohyun commented 1 year ago

All actions which has the ActionObsolete attribute also use some methods below.

And these methods have a similar problematic nature. #1507