Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 31 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,25 @@ cp env.sample .env
Then, provide correct values for the following env vars, which all the forge scripts below will use:

- ETHERSCAN_API_KEY
- UNICHAIN_SEPOLIA_RPC_URL
- RPC_URL

### Unichain Sepolia
### DeployAll

#### FlashtestationsRegistry
Deploys both the FlashtestationsRegistry and the BlockBuilderPolicy. This is the simplest and best way to deploy the necessary contracts in the flashtestations repository

```bash
# add the RPC_URL and ETHERSCAN_API_KEY's to your environment. Make sure RPC_URL is set to the intended network (e.g. unichain sepolia)
source .env

# Deploy script/DeployAll.s.sol:DeployAllScript expects run(address owner, address automataAttestationContract)
# See https://github.com/automata-network/automata-dcap-attestation/tree/4c579aff71562afe254de4009f5235873fdcc953?tab=readme-ov-file#deployment
# for the appropriate `AutomataDcapAttestationFee.sol` contract that matches your $RPC_URL's network
forge script script/DeployAll.s.sol:DeployAllScript \
--sig "run(address,address)" <FLASHTESTATIONS CONTRACT OWNER ADDRESS> <AutomataDcapAttestationFee CONTRACT ADDRESS> \
--rpc-url $RPC_URL --interactives 1 -vvvv --broadcast --verify
```

### FlashtestationsRegistry

This is the primary contract of this repository. It allows TDX v4 devices to register themselves onchain with an Ethereum address/public key, such that later transactions from that address can be trusted to originate from a TEE.

Expand All @@ -106,10 +120,10 @@ FLASHTESTATION_REGISTRY_OWNER=0x0000000000000000000000000000000000000042
Then, to deploy, run:

```
forge script --chain 1301 script/FlashtestationRegistry.s.sol:FlashtestationRegistryScript --rpc-url $UNICHAIN_SEPOLIA_RPC_URL --broadcast --verify --interactives 1 -vvvv
forge script --chain 1301 script/FlashtestationRegistry.s.sol:FlashtestationRegistryScript --rpc-url $RPC_URL --broadcast --verify --interactives 1 -vvvv
```

#### BlockBuilderPolicy
### BlockBuilderPolicy

A simple contract that allows your organization (e.g. Flashbots) to permission TEE's and their registered Ethereum addresses + workloadIds

Expand All @@ -126,12 +140,12 @@ OWNER_BLOCK_BUILDER_POLICY=0x0000000000000000000000000000000000000042
Then, to deploy, run:

```
forge script --chain 1301 script/BlockBuilderPolicy.s.sol:BlockBuilderPolicyScript --rpc-url $UNICHAIN_SEPOLIA_RPC_URL --broadcast --verify --interactives 1 -vvvv
forge script --chain 1301 script/BlockBuilderPolicy.s.sol:BlockBuilderPolicyScript --rpc-url $RPC_URL --broadcast --verify --interactives 1 -vvvv
```

#### MockQuotes
### MockQuotes

**FetchRemoteQuote**
#### FetchRemoteQuote

Create a raw attestation quote and store it in `script/raw_tdx_quotes/`. This is needed for the `RegisterTEEScript` script for its $PATH_TO_ATTESTATION_QUOTE argument

Expand All @@ -149,12 +163,12 @@ TEE_ADDRESS=0x0000000000000000000000000000000000000042
Then, to fetch the quote, run:

```
forge script script/MockQuotes.s.sol:FetchRemoteQuote --rpc-url $UNICHAIN_SEPOLIA_RPC_URL -vvvv
forge script script/MockQuotes.s.sol:FetchRemoteQuote --rpc-url $RPC_URL -vvvv
```

#### Interactions
### Interactions

**RegisterTEEScript**
#### RegisterTEEScript

This registers a TEE-controlled address using a quote generated by a v4 TDX device

Expand All @@ -175,15 +189,15 @@ Then, to execute, run:
# Note: we pass '--skip-simulation' because of a bug where the forge EVM does not contain the precompiles necessary
# to execute the FlashtestationRegistry.registerTEEService, and so we need to skip simulating it locally
#
# Note: we need to use a RPC provider like Alchemy for the $UNICHAIN_SEPOLIA_RPC_URL argument, and we can't
# Note: we need to use a RPC provider like Alchemy for the $RPC_URL argument, and we can't
# use https://sepolia.unichain.org, because this script makes so many gas-heavy calls that it will last
# longer than 128 blocks worth of time, at which point the full nodes at sepolia.unichain.org will start
# to return errors. We must use RPC provider like Alchemy because they can service calls to archive nodes,
# which get around this problem.
forge script --chain 1301 script/Interactions.s.sol:RegisterTEEScript --rpc-url $UNICHAIN_SEPOLIA_RPC_URL --broadcast --verify --interactives 1 -vvvv --skip-simulation
forge script --chain 1301 script/Interactions.s.sol:RegisterTEEScript --rpc-url $RPC_URL --broadcast --verify --interactives 1 -vvvv --skip-simulation
```

**ComputeWorkloadIdScript**
#### ComputeWorkloadIdScript

Prints out the WorkloadId for a TEE registered by TEE-controlled address (like in the `RegisterTEEScript` above).

Expand All @@ -207,10 +221,10 @@ ADDRESS_BLOCK_BUILDER_POLICY=0x0000000000000000000000000000000000000042
Then, to execute, run:

```
forge script --chain 1301 script/Interactions.s.sol:ComputeWorkloadIdScript --rpc-url $UNICHAIN_SEPOLIA_RPC_URL
forge script --chain 1301 script/Interactions.s.sol:ComputeWorkloadIdScript --rpc-url $RPC_URL
```

**AddWorkloadToPolicyScript**
#### AddWorkloadToPolicyScript

Add a workloadId computed from the `ComputeWorkloadIdScript` script above

Expand Down Expand Up @@ -243,5 +257,5 @@ RECORD_LOCATORS="https://github.com/flashbots/flashbots-images/commit/a5aa6c75fb
Then, to execute, run:

```
forge script --chain 1301 script/Interactions.s.sol:AddWorkloadToPolicyScript --rpc-url $UNICHAIN_SEPOLIA_RPC_URL --broadcast --verify --interactives 1 -vvvv
forge script --chain 1301 script/Interactions.s.sol:AddWorkloadToPolicyScript --rpc-url $RPC_URL --broadcast --verify --interactives 1 -vvvv
```
285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/130/run-1762274713527.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/130/run-latest.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/22444422/run-1760032999004.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/22444422/run-1760033446530.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/22444422/run-latest.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/33611633/run-1759352610667.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/33611633/run-1759437215954.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/33611633/run-1759503120019.json

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions broadcast/DeployAll.s.sol/33611633/run-latest.json

Large diffs are not rendered by default.

68 changes: 35 additions & 33 deletions broadcast/Interactions.s.sol/1301/run-latest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"transactions": [
{
"hash": "0xa2a85913b852db9c012fa706e3305ba4805daed64bccd587f930ff10fc74b089",
"hash": "0xc3e7ff298041fa96dc8b6c0f34fb100a535b3d636ffdcef108e731033c9954ff",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x3b03b3caabd49ca12de9eba46a6a2950700b1db4",
"contractAddress": "0x37715fab70940307bfff97e16ac036b2e2ff651a",
"function": "addWorkloadToPolicy(bytes32,string,string[])",
"arguments": [
"0xf724e7d117f5655cf33beefdfc7d31e930278fcb65cf6d1de632595e97ca82b2",
"1234567890abcdef1234567890abcdef12345678",
"[https://github.com/flashbots/flashbots-images/commit/a5aa6c75fbecc4b88faf4886cbd3cb2c667f4a8c, https://ipfs.io/ipfs/bafybeihkoviema7g3gxyt6la7vd5ho32ictqbilu3wnlo3rs7ewhnp7lly]"
"0x306ab4fe782dde50a97584b6d4cad9375f7b5d02199c4c78821ad6622670c6b7",
"7fc2ea1295130ca050b1170e51f9efd67768711a",
"[https://github.com/flashbots/flashbots-images/commit/7fc2ea1295130ca050b1170e51f9efd67768711a]"
],
"transaction": {
"from": "0x9654a3786f960db19a64dff16fdc34ed6090a760",
"to": "0x3b03b3caabd49ca12de9eba46a6a2950700b1db4",
"gas": "0x6c8f3",
"from": "0x6e934f0b23db097d12a9a37a4b564aef15332ca5",
"to": "0x37715fab70940307bfff97e16ac036b2e2ff651a",
"gas": "0x47d19",
"value": "0x0",
"input": "0x4f3a415af724e7d117f5655cf33beefdfc7d31e930278fcb65cf6d1de632595e97ca82b2000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000028313233343536373839306162636465663132333435363738393061626364656631323334353637380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000005d68747470733a2f2f6769746875622e636f6d2f666c617368626f74732f666c617368626f74732d696d616765732f636f6d6d69742f61356161366337356662656363346238386661663438383663626433636232633636376634613863000000000000000000000000000000000000000000000000000000000000000000005068747470733a2f2f697066732e696f2f697066732f62616679626569686b6f7669656d6137673367787974366c6137766435686f33326963747162696c7533776e6c6f337273376577686e70376c6c7900000000000000000000000000000000",
"nonce": "0xe93",
"input": "0x4f3a415a306ab4fe782dde50a97584b6d4cad9375f7b5d02199c4c78821ad6622670c6b7000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000283766633265613132393531333063613035306231313730653531663965666436373736383731316100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005d68747470733a2f2f6769746875622e636f6d2f666c617368626f74732f666c617368626f74732d696d616765732f636f6d6d69742f37666332656131323935313330636130353062313137306535316639656664363737363837313161000000",
"nonce": "0x0",
"chainId": "0x515"
},
"additionalContracts": [],
Expand All @@ -27,45 +27,47 @@
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x5ad55",
"cumulativeGasUsed": "0x55554",
"logs": [
{
"address": "0x3b03b3caabd49ca12de9eba46a6a2950700b1db4",
"address": "0x37715fab70940307bfff97e16ac036b2e2ff651a",
"topics": [
"0xcbb92e241e191fed6d0b0da0a918c7dcf595e77d868e2e3bf9e6b0b91589c7ad"
"0xcbb92e241e191fed6d0b0da0a918c7dcf595e77d868e2e3bf9e6b0b91589c7ad",
"0x306ab4fe782dde50a97584b6d4cad9375f7b5d02199c4c78821ad6622670c6b7"
],
"data": "0xf724e7d117f5655cf33beefdfc7d31e930278fcb65cf6d1de632595e97ca82b2",
"blockHash": "0x64f0f9475c046860e4f2372ce14ecea8cad0a3e7cf56364006b818ffa884bb79",
"blockNumber": "0x19e10a8",
"transactionHash": "0xa2a85913b852db9c012fa706e3305ba4805daed64bccd587f930ff10fc74b089",
"transactionIndex": "0x2",
"logIndex": "0x0",
"data": "0x",
"blockHash": "0x7eaa1ff9b222dfc91d8e277954e528b833db4a48169dfd53bb60a319b74abe7b",
"blockNumber": "0x214b123",
"blockTimestamp": "0x69025e6f",
"transactionHash": "0xc3e7ff298041fa96dc8b6c0f34fb100a535b3d636ffdcef108e731033c9954ff",
"transactionIndex": "0x4",
"logIndex": "0x2",
"removed": false
}
],
"logsBloom": "0x00000000000000000000000000000000000000000002000000000000000000000000000002000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000020000000000000000000000002000000000200000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000",
"type": "0x2",
"transactionHash": "0xa2a85913b852db9c012fa706e3305ba4805daed64bccd587f930ff10fc74b089",
"transactionIndex": "0x2",
"blockHash": "0x64f0f9475c046860e4f2372ce14ecea8cad0a3e7cf56364006b818ffa884bb79",
"blockNumber": "0x19e10a8",
"gasUsed": "0x4a3a9",
"effectiveGasPrice": "0xfd",
"from": "0x9654a3786f960db19a64dff16fdc34ed6090a760",
"to": "0x3b03b3caabd49ca12de9eba46a6a2950700b1db4",
"transactionHash": "0xc3e7ff298041fa96dc8b6c0f34fb100a535b3d636ffdcef108e731033c9954ff",
"transactionIndex": "0x4",
"blockHash": "0x7eaa1ff9b222dfc91d8e277954e528b833db4a48169dfd53bb60a319b74abe7b",
"blockNumber": "0x214b123",
"gasUsed": "0x33fee",
"effectiveGasPrice": "0x34",
"from": "0x6e934f0b23db097d12a9a37a4b564aef15332ca5",
"to": "0x37715fab70940307bfff97e16ac036b2e2ff651a",
"contractAddress": null,
"l1BaseFeeScalar": "0x7d0",
"l1BlobBaseFee": "0x1",
"l1BlobBaseFeeScalar": "0xdbba0",
"l1Fee": "0x71036d",
"l1GasPrice": "0xc734d",
"l1GasUsed": "0x11ba"
"l1Fee": "0xe4",
"l1GasPrice": "0x9",
"l1GasUsed": "0xc07"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1753988596,
"timestamp": 1761762927893,
"chain": 1301,
"commit": "49dcb19"
"commit": "3a725a3"
}
72 changes: 72 additions & 0 deletions broadcast/Interactions.s.sol/33611633/run-1759515912305.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"transactions": [
{
"hash": "0xf048859497dee8878985936ab63b5918175f87b1f2095f66af87ba7bcebd31f4",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x2e41cb0d68d8db7ebd16cef81d7ed82e7e1fba40",
"function": "addWorkloadToPolicy(bytes32,string,string[])",
"arguments": [
"0x50338c32fb84eba53e8e7c1ad62e29bd1c1631154ca2a8ec4c7b6ff55f439f0c",
"53d431f58a0d1a76f6711518ef8d876ce8181fc2",
"[https://github.com/flashbots/flashbots-images/commit/53d431f58a0d1a76f6711518ef8d876ce8181fc2]"
],
"transaction": {
"from": "0x9654a3786f960db19a64dff16fdc34ed6090a760",
"to": "0x2e41cb0d68d8db7ebd16cef81d7ed82e7e1fba40",
"value": "0x0",
"input": "0x4f3a415a50338c32fb84eba53e8e7c1ad62e29bd1c1631154ca2a8ec4c7b6ff55f439f0c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000283533643433316635386130643161373666363731313531386566386438373663653831383166633200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005d68747470733a2f2f6769746875622e636f6d2f666c617368626f74732f666c617368626f74732d696d616765732f636f6d6d69742f35336434333166353861306431613736663637313135313865663864383736636538313831666332000000",
"nonce": "0x6e3",
"chainId": "0x200df71"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x5d053",
"logs": [
{
"address": "0x2e41cb0d68d8db7ebd16cef81d7ed82e7e1fba40",
"topics": [
"0xcbb92e241e191fed6d0b0da0a918c7dcf595e77d868e2e3bf9e6b0b91589c7ad",
"0x50338c32fb84eba53e8e7c1ad62e29bd1c1631154ca2a8ec4c7b6ff55f439f0c"
],
"data": "0x",
"blockHash": "0x48fd2b41a3c49237efe49bb8bd0792509c0163ed9e2bc9e5cf2b8c588c7974ef",
"blockNumber": "0x128b80b",
"blockTimestamp": "0x68e01507",
"transactionHash": "0xf048859497dee8878985936ab63b5918175f87b1f2095f66af87ba7bcebd31f4",
"transactionIndex": "0x5",
"logIndex": "0x3",
"removed": false
}
],
"logsBloom": "0x00000000000000000000000000000000000000000000000100000000040000000000000002000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000",
"type": "0x2",
"transactionHash": "0xf048859497dee8878985936ab63b5918175f87b1f2095f66af87ba7bcebd31f4",
"transactionIndex": "0x5",
"blockHash": "0x48fd2b41a3c49237efe49bb8bd0792509c0163ed9e2bc9e5cf2b8c588c7974ef",
"blockNumber": "0x128b80b",
"gasUsed": "0x33fee",
"effectiveGasPrice": "0xfc",
"from": "0x9654a3786f960db19a64dff16fdc34ed6090a760",
"to": "0x2e41cb0d68d8db7ebd16cef81d7ed82e7e1fba40",
"contractAddress": null,
"l1BaseFeeScalar": "0x558",
"l1BlobBaseFee": "0x1",
"l1BlobBaseFeeScalar": "0xc5fc5",
"l1Fee": "0xdc",
"l1GasPrice": "0xe",
"l1GasUsed": "0xc57"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1759515912305,
"chain": 33611633,
"commit": "d1f2483"
}
Loading