Skip to content

Commit

Permalink
fix(purity): modify _submit to check both initcode and runtime (#21)
Browse files Browse the repository at this point in the history
* fix: check runtime in _submit

* fix: add back initcode check
  • Loading branch information
Sabnock01 authored Jan 19, 2024
1 parent 7d61639 commit 68ea826
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/CurtaGolf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ contract CurtaGolf is ICurtaGolf, KingERC721, Owned {
// Revert if the course does not exist.
if (address(courseData.course) == address(0)) revert CourseDoesNotExist(_courseId);

// Revert if the solution contains invalid opcodes.
// Revert if the initcode contains invalid opcodes.
if (!purityChecker.check(_solution, getAllowedOpcodes[_courseId])) {
revert PollutedSolution();
}
Expand All @@ -194,6 +194,11 @@ contract CurtaGolf is ICurtaGolf, KingERC721, Owned {
target := create(0, add(_solution, 0x20), mload(_solution))
}

// Revert if the runtime contains invalid opcodes.
if (!purityChecker.check(target.code, getAllowedOpcodes[_courseId])) {
revert PollutedSolution();
}

// Run solution and mint NFT if it beats the leading score.
uint32 gasUsed = courseData.course.run(target, block.prevrandao);
if (courseData.gasUsed == 0 || gasUsed < courseData.gasUsed) {
Expand Down

0 comments on commit 68ea826

Please sign in to comment.