From 49c70d8d4644a8dd2b4d2b9eb7442ace37ae8f3c Mon Sep 17 00:00:00 2001 From: halo3mic Date: Sun, 3 Dec 2023 01:21:42 +0000 Subject: [PATCH 1/3] rebase: use pending txs to build blocks --- core/types/suave_structs.go | 1 + miner/worker.go | 22 ++++++++++++++++++++++ suave/artifacts/SuaveLib.json | 2 +- suave/gen/suave_spec.yaml | 2 ++ suave/sol/libraries/Suave.sol | 1 + 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/types/suave_structs.go b/core/types/suave_structs.go index b6b6f2b8d..6dd7e9b17 100755 --- a/core/types/suave_structs.go +++ b/core/types/suave_structs.go @@ -18,6 +18,7 @@ type BuildBlockArgs struct { Random common.Hash Withdrawals []*Withdrawal Extra []byte + UsePending bool } type DataRecord struct { diff --git a/miner/worker.go b/miner/worker.go index 25701ee28..97a6e3775 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1272,6 +1272,11 @@ func (w *worker) buildBlockFromTxs(ctx context.Context, args *types.BuildBlockAr if err := w.rawCommitTransactions(work, txs); err != nil { return nil, nil, err } + if args.UsePending { + if err := w.commitPendingTxs(work); err != nil { + return nil, nil, err + } + } profitPost := work.state.GetBalance(args.FeeRecipient) block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, work.txs, work.unclelist(), work.receipts, params.withdrawals) @@ -1363,6 +1368,11 @@ func (w *worker) buildBlockFromBundles(ctx context.Context, args *types.BuildBlo } } } + if args.UsePending { + if err := w.commitPendingTxs(work); err != nil { + return nil, nil, err + } + } profitPost := work.state.GetBalance(params.coinbase) proposerProfit := new(big.Int).Set(profitPost) // = post-pre-transfer_cost @@ -1394,6 +1404,18 @@ func (w *worker) buildBlockFromBundles(ctx context.Context, args *types.BuildBlo return block, proposerProfit, nil } +func (w *worker) commitPendingTxs(work *environment) error { + interrupt := new(atomic.Int32) + timer := time.AfterFunc(w.newpayloadTimeout, func() { + interrupt.Store(commitInterruptTimeout) + }) + defer timer.Stop() + if err := w.fillTransactions(nil, work); err != nil { + return err + } + return nil +} + func (w *worker) rawCommitTransactions(env *environment, txs types.Transactions) error { gasLimit := env.header.GasLimit if env.gasPool == nil { diff --git a/suave/artifacts/SuaveLib.json b/suave/artifacts/SuaveLib.json index 2588f6f93..b9374d714 100644 --- a/suave/artifacts/SuaveLib.json +++ b/suave/artifacts/SuaveLib.json @@ -1 +1 @@ -[{"type":"error","name":"PeekerReverted","inputs":[{"name":"addr","type":"address"},{"name":"err","type":"bytes"}]},{"type":"function","name":"buildEthBlock","inputs":[{"name":"blockArgs","type":"tuple","internalType":"struct Suave.BuildBlockArgs","components":[{"name":"slot","type":"uint64","internalType":"uint64"},{"name":"proposerPubkey","type":"bytes","internalType":"bytes"},{"name":"parent","type":"bytes32","internalType":"bytes32"},{"name":"timestamp","type":"uint64","internalType":"uint64"},{"name":"feeRecipient","type":"address","internalType":"address"},{"name":"gasLimit","type":"uint64","internalType":"uint64"},{"name":"random","type":"bytes32","internalType":"bytes32"},{"name":"withdrawals","type":"tuple[]","internalType":"struct Suave.Withdrawal[]","components":[{"name":"index","type":"uint64","internalType":"uint64"},{"name":"validator","type":"uint64","internalType":"uint64"},{"name":"Address","type":"address","internalType":"address"},{"name":"amount","type":"uint64","internalType":"uint64"}]},{"name":"extra","type":"bytes","internalType":"bytes"}]},{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"namespace","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"},{"name":"output2","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"confidentialInputs","outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"confidentialRetrieve","inputs":[{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"key","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"confidentialStore","inputs":[{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"key","type":"string","internalType":"string"},{"name":"data1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"doHTTPRequest","inputs":[{"name":"request","type":"tuple","internalType":"struct Suave.HttpRequest","components":[{"name":"url","type":"string","internalType":"string"},{"name":"method","type":"string","internalType":"string"},{"name":"headers","type":"string[]","internalType":"string[]"},{"name":"body","type":"bytes","internalType":"bytes"}]}],"outputs":[{"name":"response","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"ethcall","inputs":[{"name":"contractAddr","type":"address","internalType":"address"},{"name":"input1","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"extractHint","inputs":[{"name":"bundleData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"fetchDataRecords","inputs":[{"name":"cond","type":"uint64","internalType":"uint64"},{"name":"namespace","type":"string","internalType":"string"}],"outputs":[{"name":"dataRecords","type":"tuple[]","internalType":"struct Suave.DataRecord[]","components":[{"name":"id","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"salt","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"decryptionCondition","type":"uint64","internalType":"uint64"},{"name":"allowedPeekers","type":"address[]","internalType":"address[]"},{"name":"allowedStores","type":"address[]","internalType":"address[]"},{"name":"version","type":"string","internalType":"string"}]}]},{"type":"function","name":"fillMevShareBundle","inputs":[{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"}],"outputs":[{"name":"encodedBundle","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"newBuilder","outputs":[{"name":"id","type":"string","internalType":"string"}]},{"type":"function","name":"newDataRecord","inputs":[{"name":"decryptionCondition","type":"uint64","internalType":"uint64"},{"name":"allowedPeekers","type":"address[]","internalType":"address[]"},{"name":"allowedStores","type":"address[]","internalType":"address[]"},{"name":"dataType","type":"string","internalType":"string"}],"outputs":[{"name":"dataRecord","type":"tuple","internalType":"struct Suave.DataRecord","components":[{"name":"id","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"salt","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"decryptionCondition","type":"uint64","internalType":"uint64"},{"name":"allowedPeekers","type":"address[]","internalType":"address[]"},{"name":"allowedStores","type":"address[]","internalType":"address[]"},{"name":"version","type":"string","internalType":"string"}]}]},{"type":"function","name":"signEthTransaction","inputs":[{"name":"txn","type":"bytes","internalType":"bytes"},{"name":"chainId","type":"string","internalType":"string"},{"name":"signingKey","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"signMessage","inputs":[{"name":"digest","type":"bytes","internalType":"bytes"},{"name":"signingKey","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"simulateBundle","inputs":[{"name":"bundleData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"uint64","internalType":"uint64"}]},{"type":"function","name":"simulateTransaction","inputs":[{"name":"session","type":"string","internalType":"string"},{"name":"txn","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"tuple","internalType":"struct Suave.SimulateTransactionResult","components":[{"name":"egp","type":"uint64","internalType":"uint64"},{"name":"logs","type":"tuple[]","internalType":"struct Suave.SimulatedLog[]","components":[{"name":"data","type":"bytes","internalType":"bytes"},{"name":"addr","type":"address","internalType":"address"},{"name":"topics","type":"bytes32[]","internalType":"bytes32[]"}]},{"name":"success","type":"bool","internalType":"bool"},{"name":"error","type":"string","internalType":"string"}]}]},{"type":"function","name":"submitBundleJsonRPC","inputs":[{"name":"url","type":"string","internalType":"string"},{"name":"method","type":"string","internalType":"string"},{"name":"params","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"submitEthBlockToRelay","inputs":[{"name":"relayUrl","type":"string","internalType":"string"},{"name":"builderBid","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]}] \ No newline at end of file +[{"type":"error","name":"PeekerReverted","inputs":[{"name":"addr","type":"address"},{"name":"err","type":"bytes"}]},{"type":"function","name":"buildEthBlock","inputs":[{"name":"blockArgs","type":"tuple","internalType":"struct Suave.BuildBlockArgs","components":[{"name":"slot","type":"uint64","internalType":"uint64"},{"name":"proposerPubkey","type":"bytes","internalType":"bytes"},{"name":"parent","type":"bytes32","internalType":"bytes32"},{"name":"timestamp","type":"uint64","internalType":"uint64"},{"name":"feeRecipient","type":"address","internalType":"address"},{"name":"gasLimit","type":"uint64","internalType":"uint64"},{"name":"random","type":"bytes32","internalType":"bytes32"},{"name":"withdrawals","type":"tuple[]","internalType":"struct Suave.Withdrawal[]","components":[{"name":"index","type":"uint64","internalType":"uint64"},{"name":"validator","type":"uint64","internalType":"uint64"},{"name":"Address","type":"address","internalType":"address"},{"name":"amount","type":"uint64","internalType":"uint64"}]},{"name":"extra","type":"bytes","internalType":"bytes"}]},{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"namespace","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"},{"name":"output2","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"confidentialInputs","outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"confidentialRetrieve","inputs":[{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"key","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"confidentialStore","inputs":[{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"key","type":"string","internalType":"string"},{"name":"data1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"doHTTPRequest","inputs":[{"name":"request","type":"tuple","internalType":"struct Suave.HttpRequest","components":[{"name":"url","type":"string","internalType":"string"},{"name":"method","type":"string","internalType":"string"},{"name":"headers","type":"string[]","internalType":"string[]"},{"name":"body","type":"bytes","internalType":"bytes"}]}],"outputs":[{"name":"response","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"ethcall","inputs":[{"name":"contractAddr","type":"address","internalType":"address"},{"name":"input1","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"extractHint","inputs":[{"name":"bundleData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"fetchDataRecords","inputs":[{"name":"cond","type":"uint64","internalType":"uint64"},{"name":"namespace","type":"string","internalType":"string"}],"outputs":[{"name":"dataRecords","type":"tuple[]","internalType":"struct Suave.DataRecord[]","components":[{"name":"id","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"salt","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"decryptionCondition","type":"uint64","internalType":"uint64"},{"name":"allowedPeekers","type":"address[]","internalType":"address[]"},{"name":"allowedStores","type":"address[]","internalType":"address[]"},{"name":"version","type":"string","internalType":"string"}]}]},{"type":"function","name":"fillMevShareBundle","inputs":[{"name":"dataId","type":"bytes16","internalType":"struct Suave.DataId"}],"outputs":[{"name":"encodedBundle","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"newBuilder","outputs":[{"name":"id","type":"string","internalType":"string"}]},{"type":"function","name":"newDataRecord","inputs":[{"name":"decryptionCondition","type":"uint64","internalType":"uint64"},{"name":"allowedPeekers","type":"address[]","internalType":"address[]"},{"name":"allowedStores","type":"address[]","internalType":"address[]"},{"name":"dataType","type":"string","internalType":"string"}],"outputs":[{"name":"dataRecord","type":"tuple","internalType":"struct Suave.DataRecord","components":[{"name":"id","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"salt","type":"bytes16","internalType":"struct Suave.DataId"},{"name":"decryptionCondition","type":"uint64","internalType":"uint64"},{"name":"allowedPeekers","type":"address[]","internalType":"address[]"},{"name":"allowedStores","type":"address[]","internalType":"address[]"},{"name":"version","type":"string","internalType":"string"}]}]},{"type":"function","name":"signEthTransaction","inputs":[{"name":"txn","type":"bytes","internalType":"bytes"},{"name":"chainId","type":"string","internalType":"string"},{"name":"signingKey","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"signMessage","inputs":[{"name":"digest","type":"bytes","internalType":"bytes"},{"name":"signingKey","type":"string","internalType":"string"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"simulateBundle","inputs":[{"name":"bundleData","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"uint64","internalType":"uint64"}]},{"type":"function","name":"simulateTransaction","inputs":[{"name":"session","type":"string","internalType":"string"},{"name":"txn","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"tuple","internalType":"struct Suave.SimulateTransactionResult","components":[{"name":"egp","type":"uint64","internalType":"uint64"},{"name":"logs","type":"tuple[]","internalType":"struct Suave.SimulatedLog[]","components":[{"name":"data","type":"bytes","internalType":"bytes"},{"name":"addr","type":"address","internalType":"address"},{"name":"topics","type":"bytes32[]","internalType":"bytes32[]"}]},{"name":"success","type":"bool","internalType":"bool"},{"name":"error","type":"string","internalType":"string"}]}]},{"type":"function","name":"submitBundleJsonRPC","inputs":[{"name":"url","type":"string","internalType":"string"},{"name":"method","type":"string","internalType":"string"},{"name":"params","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]},{"type":"function","name":"submitEthBlockToRelay","inputs":[{"name":"relayUrl","type":"string","internalType":"string"},{"name":"builderBid","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"output1","type":"bytes","internalType":"bytes"}]}] diff --git a/suave/gen/suave_spec.yaml b/suave/gen/suave_spec.yaml index d0394f796..112420872 100644 --- a/suave/gen/suave_spec.yaml +++ b/suave/gen/suave_spec.yaml @@ -46,6 +46,8 @@ structs: type: Withdrawal[] - name: extra type: bytes + - name: usePending + type: bool - name: HttpRequest fields: - name: url diff --git a/suave/sol/libraries/Suave.sol b/suave/sol/libraries/Suave.sol index 0a0235a76..4b5e0b016 100644 --- a/suave/sol/libraries/Suave.sol +++ b/suave/sol/libraries/Suave.sol @@ -16,6 +16,7 @@ library Suave { bytes32 random; Withdrawal[] withdrawals; bytes extra; + bool usePending; } struct DataRecord { From ff2758c32f305bed72241168f7df468678e59299 Mon Sep 17 00:00:00 2001 From: halo3mic Date: Mon, 4 Dec 2023 15:10:56 +0000 Subject: [PATCH 2/3] rebase: rename usePending -> fillPending --- core/types/suave_structs.go | 2 +- miner/worker.go | 4 ++-- suave/gen/suave_spec.yaml | 2 +- suave/sol/libraries/Suave.sol | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/types/suave_structs.go b/core/types/suave_structs.go index 6dd7e9b17..e7ba27c70 100755 --- a/core/types/suave_structs.go +++ b/core/types/suave_structs.go @@ -18,7 +18,7 @@ type BuildBlockArgs struct { Random common.Hash Withdrawals []*Withdrawal Extra []byte - UsePending bool + FillPending bool } type DataRecord struct { diff --git a/miner/worker.go b/miner/worker.go index 97a6e3775..3f8d98eac 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1272,7 +1272,7 @@ func (w *worker) buildBlockFromTxs(ctx context.Context, args *types.BuildBlockAr if err := w.rawCommitTransactions(work, txs); err != nil { return nil, nil, err } - if args.UsePending { + if args.FillPending { if err := w.commitPendingTxs(work); err != nil { return nil, nil, err } @@ -1368,7 +1368,7 @@ func (w *worker) buildBlockFromBundles(ctx context.Context, args *types.BuildBlo } } } - if args.UsePending { + if args.FillPending { if err := w.commitPendingTxs(work); err != nil { return nil, nil, err } diff --git a/suave/gen/suave_spec.yaml b/suave/gen/suave_spec.yaml index 112420872..28c076ec2 100644 --- a/suave/gen/suave_spec.yaml +++ b/suave/gen/suave_spec.yaml @@ -46,7 +46,7 @@ structs: type: Withdrawal[] - name: extra type: bytes - - name: usePending + - name: fillPending type: bool - name: HttpRequest fields: diff --git a/suave/sol/libraries/Suave.sol b/suave/sol/libraries/Suave.sol index 4b5e0b016..217b0e6b7 100644 --- a/suave/sol/libraries/Suave.sol +++ b/suave/sol/libraries/Suave.sol @@ -16,7 +16,7 @@ library Suave { bytes32 random; Withdrawal[] withdrawals; bytes extra; - bool usePending; + bool fillPending; } struct DataRecord { From 339c75a0a6092d97fd5caf2caf59f47f2897ac60 Mon Sep 17 00:00:00 2001 From: halo3mic Date: Tue, 5 Dec 2023 20:28:35 +0000 Subject: [PATCH 3/3] update default buildArgs --- suave/backends/eth_backend_server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/suave/backends/eth_backend_server.go b/suave/backends/eth_backend_server.go index 87d3102bb..a40ebc8f2 100644 --- a/suave/backends/eth_backend_server.go +++ b/suave/backends/eth_backend_server.go @@ -46,6 +46,8 @@ func (e *EthBackendServer) BuildEthBlock(ctx context.Context, buildArgs *types.B GasLimit: 30000000, Random: head.Root, Withdrawals: nil, + Extra: []byte(""), + FillPending: false, } } @@ -67,6 +69,8 @@ func (e *EthBackendServer) BuildEthBlockFromBundles(ctx context.Context, buildAr GasLimit: 30000000, Random: head.Root, Withdrawals: nil, + Extra: []byte(""), + FillPending: false, } }