From 76a3b6c5e9fe77e4679fe320bb32eec0178efed8 Mon Sep 17 00:00:00 2001 From: Sabnock01 <24715302+Sabnock01@users.noreply.github.com> Date: Tue, 19 Dec 2023 05:10:09 -0600 Subject: [PATCH] fix: check runtime in _submit --- src/CurtaGolf.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CurtaGolf.sol b/src/CurtaGolf.sol index 5a65000..3d36184 100644 --- a/src/CurtaGolf.sol +++ b/src/CurtaGolf.sol @@ -191,17 +191,17 @@ 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. - if (!purityChecker.check(_solution, getAllowedOpcodes[_courseId])) { - revert PollutedSolution(); - } - // Deploy the solution. address target; assembly { target := create(0, add(_solution, 0x20), mload(_solution)) } + // Revert if the solution 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) {