|
|
@@ -71,7 +71,7 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
|
|
|
|
|
|
function verifyUpdate(
|
|
|
bytes calldata update
|
|
|
- ) external payable returns (bytes calldata payload, address signer) {
|
|
|
+ ) public payable returns (bytes calldata payload, address signer) {
|
|
|
// Require fee and refund excess
|
|
|
require(msg.value >= verification_fee, "Insufficient fee provided");
|
|
|
if (msg.value > verification_fee) {
|
|
|
@@ -120,45 +120,13 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
|
|
|
address signer,
|
|
|
PythLazerStructs.Update memory parsedUpdate
|
|
|
) {
|
|
|
- // Require fee and refund excess
|
|
|
- require(msg.value >= verification_fee, "Insufficient fee provided");
|
|
|
- if (msg.value > verification_fee) {
|
|
|
- payable(msg.sender).transfer(msg.value - verification_fee);
|
|
|
- }
|
|
|
-
|
|
|
- if (update.length < 71) {
|
|
|
- revert("input too short");
|
|
|
- }
|
|
|
- uint32 EVM_FORMAT_MAGIC = 706910618;
|
|
|
-
|
|
|
- uint32 evm_magic = uint32(bytes4(update[0:4]));
|
|
|
- if (evm_magic != EVM_FORMAT_MAGIC) {
|
|
|
- revert("invalid evm magic");
|
|
|
- }
|
|
|
- uint16 payload_len = uint16(bytes2(update[69:71]));
|
|
|
- if (update.length < 71 + payload_len) {
|
|
|
- revert("input too short");
|
|
|
- }
|
|
|
- payload = update[71:71 + payload_len];
|
|
|
- bytes32 hash = keccak256(payload);
|
|
|
- (signer, , ) = ECDSA.tryRecover(
|
|
|
- hash,
|
|
|
- uint8(update[68]) + 27,
|
|
|
- bytes32(update[4:36]),
|
|
|
- bytes32(update[36:68])
|
|
|
- );
|
|
|
- if (signer == address(0)) {
|
|
|
- revert("invalid signature");
|
|
|
- }
|
|
|
- if (!isValidSigner(signer)) {
|
|
|
- revert("invalid signer");
|
|
|
- }
|
|
|
+ (payload, signer) = verifyUpdate(update);
|
|
|
|
|
|
// Parse the verified payload
|
|
|
parsedUpdate = PythLazerLib.parseUpdateFromPayload(payload);
|
|
|
}
|
|
|
|
|
|
function version() public pure returns (string memory) {
|
|
|
- return "0.1.1";
|
|
|
+ return "0.2.0";
|
|
|
}
|
|
|
}
|