Skip to content

Commit

Permalink
refactor(protocol): remove staticRefs (#13709)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored May 5, 2023
1 parent 2ce8787 commit bd256e2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
3 changes: 1 addition & 2 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ library TaikoData {
mapping(address account => uint256 balance) taikoTokenBalances;
mapping(bytes32 txListHash => TxListInfo) txListInfo;
EthDeposit[] ethDeposits;
bytes32 staticRefs;
// Never or rarely changed
// Slot 7: never or rarely changed
uint64 genesisHeight;
Expand All @@ -147,6 +146,6 @@ library TaikoData {
uint64 lastVerifiedBlockId;
uint64 __reserved91;
// Reserved
uint256[41] __gap;
uint256[42] __gap;
}
}
3 changes: 2 additions & 1 deletion packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ contract TaikoL1 is
* @param _addressManager The AddressManager address.
* @param _genesisBlockHash The block hash of the genesis block.
* @param _initBlockFee Initial (reasonable) block fee value.
* @param _initProofTimeIssued Initial proof time issued corresponding with the initial block fee.
* @param _initProofTimeIssued Initial proof time issued corresponding
* with the initial block fee.
*/
function init(
address _addressManager,
Expand Down
58 changes: 30 additions & 28 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,39 +147,41 @@ library LibProving {
fc.prover = evidence.prover;

if (evidence.prover != address(0)) {
bytes32 instance;

// Set state.staticRefs
if (state.staticRefs == 0) {
address[3] memory addresses;
addresses[0] = resolver.resolve("signal_service", false);
addresses[1] = resolver.resolve(
config.chainId,
"signal_service",
false
);
addresses[2] = resolver.resolve(config.chainId, "taiko", false);
bytes32 staticRefs;
assembly {
staticRefs := keccak256(addresses, mul(32, 3))
}
state.staticRefs = staticRefs;
}

uint256[7] memory inputs;
inputs[0] = uint256(state.staticRefs);
inputs[1] = uint256(blk.metaHash);
inputs[2] = uint256(evidence.parentHash);
inputs[3] = uint256(evidence.blockHash);
inputs[4] = uint256(evidence.signalRoot);
inputs[5] = uint256(evidence.graffiti);
inputs[6] =
uint256[9] memory inputs;

inputs[0] = uint256(
uint160(address(resolver.resolve("signal_service", false)))
);
inputs[1] = uint256(
uint160(
address(
resolver.resolve(
config.chainId,
"signal_service",
false
)
)
)
);
inputs[2] = uint256(
uint160(
address(resolver.resolve(config.chainId, "taiko", false))
)
);

inputs[3] = uint256(blk.metaHash);
inputs[4] = uint256(evidence.parentHash);
inputs[5] = uint256(evidence.blockHash);
inputs[6] = uint256(evidence.signalRoot);
inputs[7] = uint256(evidence.graffiti);
inputs[8] =
(uint256(uint160(evidence.prover)) << 96) |
(uint256(evidence.parentGasUsed) << 64) |
(uint256(evidence.gasUsed) << 32);

bytes32 instance;
assembly {
instance := keccak256(inputs, mul(32, 7))
instance := keccak256(inputs, mul(32, 9))
}

(bool verified, bytes memory ret) = resolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ struct State {
mapping(address => uint256) taikoTokenBalances;
mapping(bytes32 => struct TaikoData.TxListInfo) txListInfo;
struct TaikoData.EthDeposit[] ethDeposits;
bytes32 staticRefs;
uint64 genesisHeight;
uint64 genesisTimestamp;
uint64 __reserved71;
Expand All @@ -166,6 +165,6 @@ struct State {
uint64 proofTimeIssued;
uint64 lastVerifiedBlockId;
uint64 __reserved91;
uint256[41] __gap;
uint256[42] __gap;
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ event BlockProposed(uint256 id, struct TaikoData.BlockMetadata meta)
### BlockProven

```solidity
event BlockProven(uint256 id, bytes32 parentHash, bytes32 blockHash, bytes32 signalRoot, address prover)
event BlockProven(uint256 id, bytes32 parentHash, bytes32 blockHash, bytes32 signalRoot, address prover, uint32 parentGasUsed)
```

### BlockVerified
Expand Down

0 comments on commit bd256e2

Please sign in to comment.