Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Feb 11, 2024
1 parent fe4eda7 commit 216b565
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/libs/LibVerifying.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ library LibVerifying {
// This also means if we verified more than one block, only the last one's stateRoot
// is sent as a signal and verifiable with merkle proofs, all other blocks'
// stateRoot are not.
ISignalService(resolver.resolve("signal_service", false)).relayChainStateRoot(
ISignalService(resolver.resolve("signal_service", false)).relayStateRoot(
config.chainId, stateRoot
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ contract TaikoL2 is CrossChainOwned, ICrossChainSync {

// Store the L1's state root as a signal to the local signal service to
// allow for multi-hop bridging.
ISignalService(resolve("signal_service", false)).relayChainStateRoot(
ISignalService(resolve("signal_service", false)).relayStateRoot(
ownerChainId, l1StateRoot
);

Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/contracts/signal/ISignalService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ interface ISignalService {
/// @return True if the signal has been sent, otherwise false.
function isSignalSent(address app, bytes32 signal) external view returns (bool);

function relayChainStateRoot(
function relayStateRoot(
uint64 chainId,
bytes32 stateRoot
)
external
returns (bytes32 slot);

function relaySignalServiceStorageRoot(
function relaySignalRoot(
uint64 chainId,
bytes32 storageRoot
bytes32 signalRoot
)
external
returns (bytes32 slot);
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/signal/LibSignals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ library LibSignals {
return keccak256(abi.encode("STATE_ROOT", chainId, stateRoot));
}

function signalForStorageRoot(
function signalForSignalRoot(
uint64 chainId,
bytes32 storageRoot
)
internal
pure
returns (bytes32)
{
return keccak256(abi.encode("SIGNAL_SERVICE_STORAGE_ROOT", chainId, storageRoot));
return keccak256(abi.encode("SIGNAL_ROOT", chainId, storageRoot));
}
}
18 changes: 9 additions & 9 deletions packages/protocol/contracts/signal/SignalService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract SignalService is EssentialContract, ISignalService {
return _sendSignal(signal);
}

function relayChainStateRoot(
function relayStateRoot(
uint64 chainId,
bytes32 stateRoot
)
Expand All @@ -91,16 +91,16 @@ contract SignalService is EssentialContract, ISignalService {
// TODO: emit an event
}

function relaySignalServiceStorageRoot(
function relaySignalRoot(
uint64 chainId,
bytes32 storageRoot
bytes32 signalRoot
)
public
onlyFromNamed("taiko")
returns (bytes32 slot)
{
if (chainId == block.chainid) revert SS_INVALID_PARAMS();
return _sendSignal(LibSignals.signalForStorageRoot(chainId, storageRoot));
return _sendSignal(LibSignals.signalForSignalRoot(chainId, signalRoot));
// TODO: emit an event
}

Expand Down Expand Up @@ -166,13 +166,13 @@ contract SignalService is EssentialContract, ISignalService {
);

if (hop.cacheRootHash) {
if (hop.isStateRoot) relayChainStateRoot(_chainId, hop.rootHash);
else relaySignalServiceStorageRoot(_chainId, hop.rootHash);
if (hop.isStateRoot) relayStateRoot(_chainId, hop.rootHash);
else relaySignalRoot(_chainId, hop.rootHash);
}

_signal = hop.isStateRoot
? LibSignals.signalForStateRoot(_chainId, hop.rootHash)
: LibSignals.signalForStorageRoot(_chainId, hop.rootHash);
: LibSignals.signalForSignalRoot(_chainId, hop.rootHash);

_chainId = hop.chainId;
_app = hop.relay;
Expand All @@ -182,7 +182,7 @@ contract SignalService is EssentialContract, ISignalService {
// relayed as a signal.
bytes32 lastSignal = p.isStateRoot
? LibSignals.signalForStateRoot(_chainId, p.rootHash)
: LibSignals.signalForStorageRoot(_chainId, p.rootHash);
: LibSignals.signalForSignalRoot(_chainId, p.rootHash);

bool lastSignalRelayed = isSignalSent(resolve("taiko", false), lastSignal);
if (!lastSignalRelayed) revert SS_INVALID_ROOT_HASH();
Expand All @@ -191,7 +191,7 @@ contract SignalService is EssentialContract, ISignalService {
verifyMerkleProof(_chainId, _app, _signal, p.rootHash, p.isStateRoot, p.merkleProof);

if (p.isStateRoot && p.cacheSignalServiceStorageRoot) {
relaySignalServiceStorageRoot(_chainId, storageRoot);
relaySignalRoot(_chainId, storageRoot);
}
return true;
}
Expand Down

0 comments on commit 216b565

Please sign in to comment.