Skip to content

Commit

Permalink
Use non-zero nonce for attestations (#74)
Browse files Browse the repository at this point in the history
Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
Co-authored-by: ChiTimesChi <88190723+ChiTimesChi@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 10, 2022
1 parent c539298 commit ef918bf
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ jobs:
# Path to your GolangCI-Lint config within the repo (optional)
config: ${{ env.GITHUB_WORKSPACE }}/.golangci.yml
# see: https://github.com/golangci/golangci-lint/issues/2654
args: --timeout=10m
args: --timeout=15m
env:
# GitHub token for annotations (optional)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
32 changes: 16 additions & 16 deletions core/contracts/home/home.abigen.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/contracts/home/home.contractinfo.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions core/contracts/test/headerharness/headerharness.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions core/contracts/test/homeharness/homeharness.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions core/contracts/test/messageharness/messageharness.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions core/contracts/test/tipsharness/tipsharness.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions core/contracts/updatermanager/updatemanager.abigen.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/contracts/contracts/Home.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ contract Home is Version0, MerkleTreeManager, UpdaterStorage, AuthManager {
_setUpdaterManager(_updaterManager);
__SynapseBase_initialize(updaterManager.updater());
state = States.Active;
// insert a historical root so nonces start at 1 rather then 0
historicalRoots.push(bytes32(""));
// insert a historical root so nonces start at 1 rather then 0. Here we insert the default root of a sparse merkle tree
historicalRoots.push(hex"27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757");
}

// ============ Modifiers ============
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/test/Home.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ contract HomeTest is SynapseTestWithUpdaterManager {
assertEq(home.owner(), address(this));
assertEq(uint256(home.state()), 1);
assertEq(home.updater(), updater);
// Root of an empty sparse Merkle tree should be stored with nonce=0
assertEq(home.historicalRoots(0), home.root());
}

function test_cannotInitializeTwice() public {
Expand Down Expand Up @@ -166,7 +168,7 @@ contract HomeTest is SynapseTestWithUpdaterManager {
uint32 nonce = 0;
bytes32 root = home.root();
// This root exists, but with nonce = 1
// nonce = 0 exists, with a different Merkle root
// nonce = 2 exists, with a different Merkle root
_checkImproperUpdate(nonce, root);
}

Expand Down

0 comments on commit ef918bf

Please sign in to comment.