Skip to content

Commit b4944fa

Browse files
committed
Clean up.
1 parent 85a8bfc commit b4944fa

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

examples/builder/main.go

+22-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"encoding/json"
56
"log"
67
"math/big"
@@ -12,29 +13,12 @@ import (
1213
)
1314

1415
var (
15-
// // testKey is a private key to use for funding a tester account.
16-
// testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
17-
18-
// // testAddr is the Ethereum address of the tester account.
19-
// testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
20-
21-
/* precompiles */
22-
// isConfidentialAddress = common.HexToAddress("0x42010000")
23-
// fetchBidsAddress = common.HexToAddress("0x42030001")
24-
// fillMevShareBundleAddress = common.HexToAddress("0x43200001")
25-
26-
// signEthTransaction = common.HexToAddress("0x40100001")
27-
// signMessage = common.HexToAddress("0x40100003")
28-
29-
// simulateBundleAddress = common.HexToAddress("0x42100000")
16+
// precompiles
3017
buildEthBlockAddress = common.HexToAddress("0x42100001")
3118

32-
// privateKeyGen = common.HexToAddress("0x53200003")
33-
34-
/* contracts */
19+
// contracts
3520
newBundleBidAddress = common.HexToAddress("0x642300000")
3621
newBlockBidAddress = common.HexToAddress("0x642310000")
37-
// mevShareAddress = common.HexToAddress("0x642100073")
3822
)
3923

4024
func main() {
@@ -65,15 +49,16 @@ func main() {
6549
bundleContract := fr.Suave.DeployContract("builder.sol/BundleContract.json")
6650
ethBlockContract := fr.Suave.DeployContract("builder.sol/EthBlockContract.json")
6751

68-
targetBlock := uint64(1)
52+
targetBlock := currentBlock(fr).Time()
53+
6954
{ // Send a bundle to the builder
7055
decryptionCondition := targetBlock + 1
7156
allowedPeekers := []common.Address{
7257
newBlockBidAddress,
7358
newBundleBidAddress,
7459
buildEthBlockAddress,
7560
bundleContract.Address(),
76-
ethBlockContract.Address()} // XXX: added this in response to initial error
61+
ethBlockContract.Address()}
7762
allowedStores := []common.Address{}
7863
newBundleArgs := []any{
7964
decryptionCondition,
@@ -86,19 +71,24 @@ func main() {
8671
_ = bundleContract.SendTransaction("newBundle", newBundleArgs, confidentialDataBytes)
8772
}
8873

89-
// { // Signal to the builder that it's time to build a new block
90-
// ethHead, err := fr.L1.RPC().BlockNumber(context.TODO())
91-
// maybe(err)
74+
{ // Signal to the builder that it's time to build a new block
75+
payloadArgsTuple := types.BuildBlockArgs{
76+
ProposerPubkey: []byte{0x42},
77+
Timestamp: targetBlock + 12, // ethHead + uint64(12),
78+
FeeRecipient: common.Address{0x42},
79+
}
9280

93-
// payloadArgsTuple := types.BuildBlockArgs{
94-
// ProposerPubkey: []byte{0x42},
95-
// Timestamp: ethHead + uint64(12),
96-
// FeeRecipient: common.Address{0x42},
97-
// }
81+
_ = ethBlockContract.SendTransaction("buildFromPool", []any{payloadArgsTuple, targetBlock + 1}, nil)
82+
maybe(err)
83+
}
84+
}
9885

99-
// _ = ethBlockContract.SendTransaction("buildFromPool", []any{payloadArgsTuple, targetBlock + 1}, nil)
100-
// maybe(err)
101-
// }
86+
func currentBlock(fr *framework.Framework) *types.Block {
87+
n, err := fr.L1.RPC().BlockNumber(context.TODO())
88+
maybe(err)
89+
b, err := fr.L1.RPC().BlockByNumber(context.TODO(), new(big.Int).SetUint64(n))
90+
maybe(err)
91+
return b
10292
}
10393

10494
func maybe(err error) {

0 commit comments

Comments
 (0)