Skip to content

Commit 2b3d24e

Browse files
authored
add delayedrefund field and parse uuids in bundles params (#57)
1. parse UUID in bundles to return errors to users early * note: we modify semantics of unique key but its not a problem since this is only used internally to distinguish bundles in memory 2. add `delayedRefund` field
1 parent d7890b2 commit 2b3d24e

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

rpctypes/types.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,19 @@ type EthSendBundleArgs struct {
4848
MinTimestamp *uint64 `json:"minTimestamp,omitempty"`
4949
MaxTimestamp *uint64 `json:"maxTimestamp,omitempty"`
5050
RevertingTxHashes []common.Hash `json:"revertingTxHashes,omitempty"`
51-
ReplacementUUID *string `json:"replacementUuid,omitempty"`
51+
ReplacementUUID *uuid.UUID `json:"replacementUuid,omitempty"`
5252
Version *string `json:"version,omitempty"`
5353

5454
ReplacementNonce *uint64 `json:"replacementNonce,omitempty"`
5555
SigningAddress *common.Address `json:"signingAddress,omitempty"` // may or may not be respected depending on the context
5656
RefundIdentity *common.Address `json:"refundIdentity,omitempty"` // metadata field to improve redistribution ux
5757

5858
DroppingTxHashes []common.Hash `json:"droppingTxHashes,omitempty"`
59-
UUID *string `json:"uuid,omitempty"`
59+
UUID *uuid.UUID `json:"uuid,omitempty"`
6060
RefundPercent *uint64 `json:"refundPercent,omitempty"`
6161
RefundRecipient *common.Address `json:"refundRecipient,omitempty"`
6262
RefundTxHashes []string `json:"refundTxHashes,omitempty"`
63+
DelayedRefund *bool `json:"delayedRefund,omitempty"` // if set to true refund will be paid out of block
6364
}
6465

6566
const (
@@ -106,7 +107,7 @@ type MevBundleMetadata struct {
106107

107108
type MevSendBundleArgs struct {
108109
Version string `json:"version"`
109-
ReplacementUUID string `json:"replacementUuid,omitempty"`
110+
ReplacementUUID *uuid.UUID `json:"replacementUuid,omitempty"`
110111
Inclusion MevBundleInclusion `json:"inclusion"`
111112
// when empty its considered cancel
112113
Body []MevBundleBody `json:"body"`
@@ -184,7 +185,7 @@ func (b *EthSendBundleArgs) UniqueKey() uuid.UUID {
184185
_, _ = hash.Write(txHash.Bytes())
185186
}
186187
if b.ReplacementUUID != nil {
187-
_, _ = hash.Write([]byte(*b.ReplacementUUID))
188+
_, _ = hash.Write((*b.ReplacementUUID)[:])
188189
}
189190
if b.ReplacementNonce != nil {
190191
_ = binary.Write(hash, binary.LittleEndian, *b.ReplacementNonce)
@@ -371,7 +372,9 @@ func (b *MevSendBundleArgs) UniqueKey() uuid.UUID {
371372
}
372373

373374
func uniqueKeyMevSendBundle(b *MevSendBundleArgs, hash hash.Hash) {
374-
hash.Write([]byte(b.ReplacementUUID))
375+
if b.ReplacementUUID != nil {
376+
hash.Write(b.ReplacementUUID[:])
377+
}
375378
_ = binary.Write(hash, binary.LittleEndian, b.Inclusion.BlockNumber)
376379
_ = binary.Write(hash, binary.LittleEndian, b.Inclusion.MaxBlock)
377380
for _, body := range b.Body {
@@ -394,7 +397,7 @@ func uniqueKeyMevSendBundle(b *MevSendBundleArgs, hash hash.Hash) {
394397
func (b *MevSendBundleArgs) Validate() (common.Hash, error) {
395398
// only cancell call can be without txs
396399
// cancell call must have ReplacementUUID set
397-
if len(b.Body) == 0 && b.ReplacementUUID == "" {
400+
if len(b.Body) == 0 && b.ReplacementUUID == nil {
398401
return common.Hash{}, ErrBundleNoTxs
399402
}
400403
return hashMevSendBundle(0, b)

rpctypes/types_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ func TestEthSendBundleArgsValidate(t *testing.T) {
7878
}`),
7979
ExpectedHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
8080
ExpectedUUID: "35718fe4-5d24-51c8-93bf-9c961d7c3ea3",
81-
ExpectedUniqueKey: "1655edd0-29a6-5372-a19b-1ddedda14b20",
81+
ExpectedUniqueKey: "62b35666-4162-51a4-b2dc-fb42aed171ac",
8282
},
8383
{
8484
Payload: []byte(`{
8585
"replacementUuid": "35718fe4-5d24-51c8-93bf-9c961d7c3ea3"
8686
}`),
8787
ExpectedHash: "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
8888
ExpectedUUID: "35718fe4-5d24-51c8-93bf-9c961d7c3ea3",
89-
ExpectedUniqueKey: "3c718cb9-3f6c-5dc0-9d99-264dafc0b4e9",
89+
ExpectedUniqueKey: "7a362520-e7de-526a-8281-ed2e4cdbfccb",
9090
},
9191
{
9292
Payload: []byte(` {

0 commit comments

Comments
 (0)