AI Arena - lrivo's results

In AI Arena you train an AI character to battle in a platform fighting game. Imagine a cross between Pokémon and Super Smash Bros, but the characters are AIs, and you can train them to learn almost any skill in preparation for battle.

General Information

Platform: Code4rena

Start Date: 09/02/2024

Pot Size: $60,500 USDC

Total HM: 17

Participants: 283

Period: 12 days

Judge:

Id: 328

League: ETH

AI Arena

Findings Distribution

Researcher Performance

Rank: 155/283

Findings: 1

Award: $13.63

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

13.6293 USDC - $13.63

Labels

bug
G (Gas Optimization)
grade-b
sufficient quality report
G-20

External Links

[G-1] Consider caching roundId in a memory variable inside RankedBattle::_addResultPoints() to avoid storage reads

https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/RankedBattle.sol#L416

Description

RankedBattle::_addResultPoints() makes use of this variable multiple times inside his logic so, caching it in a memory variable, could help saving some gas.

[G-2] Useless storage read when emitting VoltageManager::VoltageRemaining event inside VoltageManager::useVoltageBattery

https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/VoltageManager.sol#L98

Description

The value of the voltage parameter will always be 100 in this case so it is a waste of gas to read that from storage.

Either make the literal 100 a constant variable (like FULL_VOLTAGE_CAPACITY) and emit that in the event, otherwise just emit the literal 100 instead of reading it from the ownerVoltage mapping.

ownerVoltage[msg.sender] = 100; // this can become a constant variable
emit VoltageRemaining(msg.sender, ownerVoltage[msg.sender]);

[G-3] Avoid reading the supposedly same array length multiple times

https://github.com/code-423n4/2024-02-ai-arena/blob/cd1a0e6d1b40168657d1aaee8223dc050e15f8cc/src/FighterFarm.sol#L243

Cache the length of the first array and use it to compare with the rest.

uint256 len = mintpassIdsToBurn; require( mintPassDnas.length == len && fighterTypes.length == len && modelHashes.length == len && modelTypes.length == len )

#0 - raymondfam

2024-02-25T21:48:01Z

3G

#1 - c4-pre-sort

2024-02-25T21:48:07Z

raymondfam marked the issue as sufficient quality report

#2 - c4-judge

2024-03-19T07:50:10Z

HickupHH3 marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter