Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async replicas updating #55

Merged
merged 28 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d057337
feat: AuthManager to authenticate signed messages
ChiTimesChi Jul 5, 2022
7036800
feat: store all historical merkle roots
ChiTimesChi Jul 6, 2022
d2896bb
feat: change update scheme on Home
ChiTimesChi Jul 6, 2022
91faa41
tests: check new update signing on Home
ChiTimesChi Jul 6, 2022
72b407f
tests: ignore fraud reports from other chains
ChiTimesChi Jul 6, 2022
8b098b3
fix: move "home update" domain check
ChiTimesChi Jul 7, 2022
0462830
fix: unique library function names
ChiTimesChi Jul 7, 2022
df96ff3
feat: apply new update scheme to Replicas
ChiTimesChi Jul 7, 2022
bc6e4a6
tests: new update scheme in ReplicaManager
ChiTimesChi Jul 7, 2022
6f368dc
fix: dont accept updates from local chain
ChiTimesChi Jul 8, 2022
3e07637
tests: local domain on ReplicaManager
ChiTimesChi Jul 8, 2022
04a9736
chore: more explicit test comments
ChiTimesChi Jul 8, 2022
08c43b0
chore: formatting
ChiTimesChi Jul 8, 2022
1c6d92b
chore: remove old signing scheme from tests
ChiTimesChi Jul 8, 2022
2380a58
tests: new libs
ChiTimesChi Jul 8, 2022
ccc2408
Merge branch 'master' into feat/async-replicas-updating
trajan0x Jul 13, 2022
980b89a
tests: remove outdated isUpdaterSignature
ChiTimesChi Jul 14, 2022
c4dda2d
fix: rename HomeUpdate into RootUpdate
ChiTimesChi Jul 14, 2022
2d03947
chore: prettify contracts
ChiTimesChi Jul 14, 2022
a4abc24
chore: RootUpdate -> Attestation
ChiTimesChi Jul 14, 2022
b8eec3b
feat: attestation collector
ChiTimesChi Jul 14, 2022
3f20a9c
tests: asstestation collector
ChiTimesChi Jul 14, 2022
cac81bc
fix two flaky tests (#64)
trajan0x Jul 13, 2022
587c4fc
feat: embed signature into attestation payload
ChiTimesChi Jul 16, 2022
d43a81b
tests: adjust tests for new attestation scheme
ChiTimesChi Jul 16, 2022
68078fc
Merge branch 'master' into feat/async-replicas-updating
ChiTimesChi Jul 18, 2022
fdb992f
Merge branch 'feat/async-replicas-updating' into feat/attestation-mvp
ChiTimesChi Jul 18, 2022
09b4882
Merge pull request #65 from synapsecns/feat/attestation-mvp
aureliusbtc Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions packages/contracts/contracts/AttestationCollector.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import { AuthManager } from "./auth/AuthManager.sol";
import { Attestation } from "./libs/Attestation.sol";
import { TypedMemView } from "./libs/TypedMemView.sol";

import {
OwnableUpgradeable
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

contract AttestationCollector is AuthManager, OwnableUpgradeable {
using Attestation for bytes29;
using TypedMemView for bytes;
using TypedMemView for bytes29;

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ EVENTS ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

event AttestationSubmitted(address indexed updater, bytes attestation);

event UpdaterAdded(uint32 indexed domain, address updater);

event UpdaterRemoved(uint32 indexed domain, address updater);

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ STORAGE ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

// [homeDomain => [updater => isUpdater]]
mapping(uint32 => mapping(address => bool)) public isUpdater;

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ UPGRADE GAP ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

uint256[49] private __GAP;

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ INITIALIZER ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

function initialize() external initializer {
__Ownable_init_unchained();
}

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ OWNER ONLY ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

// TODO: add/remove updaters upon bonding/unbonding

function addUpdater(uint32 _domain, address _updater) external onlyOwner {
_addUpdater(_domain, _updater);
}

function removeUpdater(uint32 _domain, address _updater) external onlyOwner {
_removeUpdater(_domain, _updater);
}

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ EXTERNAL FUNCTIONS ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

function submitAttestation(address _updater, bytes memory _attestation) external {
bytes29 _view = _checkUpdaterAuth(_updater, _attestation);
_storeAttestation(_view);
emit AttestationSubmitted(_updater, _attestation);
}

/*╔══════════════════════════════════════════════════════════════════════╗*\
▏*║ INTERNAL FUNCTIONS ║*▕
\*╚══════════════════════════════════════════════════════════════════════╝*/

function _isUpdater(uint32 _homeDomain, address _updater)
internal
view
override
returns (bool)
{
return isUpdater[_homeDomain][_updater];
}

function _isWatchtower(address _watchtower) internal view override returns (bool) {}

function _addUpdater(uint32 _domain, address _updater) internal {
if (!isUpdater[_domain][_updater]) {
isUpdater[_domain][_updater] = true;
emit UpdaterAdded(_domain, _updater);
}
}

function _removeUpdater(uint32 _domain, address _updater) internal {
if (isUpdater[_domain][_updater]) {
isUpdater[_domain][_updater] = false;
emit UpdaterRemoved(_domain, _updater);
}
}

function _storeAttestation(bytes29 _view) internal {
// TODO: implement storing logic for easy retrieval
}
}
Loading