From e20c0f34060e9cffa4a756be3ef2a1d4f5015ea9 Mon Sep 17 00:00:00 2001 From: p30629751 Date: Sun, 21 May 2023 17:32:45 +0800 Subject: [PATCH] ADD file via upload --- RootVerifier.sol | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 RootVerifier.sol diff --git a/RootVerifier.sol b/RootVerifier.sol new file mode 100644 index 0000000..87dc8d8 --- /dev/null +++ b/RootVerifier.sol @@ -0,0 +1,16 @@ +pragma solidity ^0.8.0; + +contract StateRootVerifier { + bytes32 private currentRoot; + + function verifyAndUpdate(bytes32 oldRoot, bytes32 newRoot) external { + require(oldRoot == currentRoot, "Invalid old state root"); + + // 更新链上状态树根 + currentRoot = newRoot; + } + + function getCurrentRoot() external view returns (bytes32) { + return currentRoot; + } +}