Skip to content

Commit

Permalink
solidity -> js
Browse files Browse the repository at this point in the history
  • Loading branch information
mimoo committed Dec 21, 2023
1 parent 94f74b9 commit d66d09b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/starkex/facts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ A fact is represented (or authenticated) by a hash of it. As such, it is importa

Let's introduce the smart contract in charge of these facts, [FactRegistry.sol](https://github.com/starkware-libs/starkex-contracts/blob/aecf37f2278b2df233edd13b686d0aa9462ada02/scalable-dex/contracts/src/components/FactRegistry.sol):

```solidity
```js
contract FactRegistry is IQueryableFactRegistry {
// Mapping: fact hash -> true.
mapping(bytes32 => bool) private verifiedFact
```
As you can see, facts are just tracked via a hashmap. Registering a fact is such straightfoward:
```solidity
```js
function registerFact(bytes32 factHash) internal {
// This function stores the fact hash in the mapping.
verifiedFact[factHash] = true;
```
As well as checking if a fact has been registered:
```solidity
```js
function isValid(bytes32 fact) external view override returns (bool) {
return _factCheck(fact);
}
Expand All @@ -39,7 +39,7 @@ As well as checking if a fact has been registered:
An example of registering a fact can be seen, for example at the end of a proof verification. In [GpsStatementVerifier.sol:verifyProofAndRegister()](https://github.com/starkware-libs/starkex-contracts/blob/aecf37f2278b2df233edd13b686d0aa9462ada02/evm-verifier/solidity/contracts/gps/GpsStatementVerifier.sol#L71):
```solidity
```js
function verifyProofAndRegister(
uint256[] calldata proofParams,
uint256[] calldata proof,
Expand All @@ -55,7 +55,7 @@ An example of registering a fact can be seen, for example at the end of a proof
where `registerGpsFacts` is defined as:
```solidity
```js
function registerGpsFacts(
uint256[] calldata taskMetadata,
uint256[] memory publicMemoryPages,
Expand Down Expand Up @@ -85,15 +85,15 @@ where `registerGpsFacts` is defined as:
The main function of Starknet is [`updateState()`](https://github.com/mimoo/starknet-contracts/blob/main/contracts/Starknet.sol#L176) which updates the state based on proofs that have been verified:
```solidity
```js
function updateState(
int256 sequenceNumber,
uint256[] calldata programOutput,
uint256 onchainDataHash,
uint256 onchainDataSize
) external onlyOperator {
// TRUNCATED...

bytes32 sharpFact = keccak256(
abi.encode(programHash(), stateTransitionFact)
);
Expand Down

0 comments on commit d66d09b

Please sign in to comment.