flashbots / pm

Everything there is to know about Flashbots
2.54k stars 277 forks source link

Flashbot bundle is not included because "isSendToMiners" is false? #123

Open Neronjust2017 opened 1 year ago

Neronjust2017 commented 1 year ago

I'm trying to send a flashbot Bundle with several transactions. I use the following code to sign and send a bundle:

 const signedTransactions = await flashbotsProvider.signBundle([
    {
      signer: MyWallet,
      transaction: firstTx
    },
    {
      signer: MyWallet,
      transaction: secondTx
    },
    {
      signer: MyWallet,
      transaction: thirdTx
    }]);
    const targetBlockNumber = block.number; 
    const simulation = await flashbotsProvider.simulate(
      signedTransactions,
      targetBlockNumber + 1
    )

    console.log(simulation);
    console.log("bundleHash: ", simulation.bundleHash);

    for (var i = 1; i <= 10; i++) {

      console.log(">>>>>> ", i);

      const bundleSubmission = await flashbotsProvider.sendRawBundle(
        signedTransactions,
        targetBlockNumber + i
      )
      console.log('bundle submitted, waiting', bundleSubmission.bundleHash)

      const waitResponse = await bundleSubmission.wait()
      console.log(`Wait Response: ${FlashbotsBundleResolution[waitResponse]}`)
      if (
        waitResponse === FlashbotsBundleResolution.BundleIncluded ||
        waitResponse === FlashbotsBundleResolution.AccountNonceTooHigh
      ) {
        console.log('Bundle included!')
        process.exit(0)
      } else {

        console.log(">>>", simulation.bundleHash);

        console.log({
          bundleStats: await flashbotsProvider.getBundleStats(
            simulation.bundleHash,
            targetBlockNumber + 1,
          ),
          userStats: await flashbotsProvider.getUserStats(),
        })
      }
    }

The simulation is successful. However, In order to ensure that the bundle can be included, I for loop 10 times to send a new bundle in case the previous bundle fails. It seems that the bundles are not included because they are not sent to the miners(isSentToMiners is false). Why does this happen?

bundleHash:  0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
>>>>>>  1
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  2
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  3
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  4
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  5
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  6
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  7
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  8
bundle submitted, waiting 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
Wait Response: BlockPassedWithoutInclusion
>>> 0x012ca7ac493afc4bf288bb9cde4b49d521d1c12c01d66705d8fbd3bdfb1c6112
{
  bundleStats: {
    isHighPriority: true, 
    isSentToMiners: false,
    isSimulated: true,    
    simulatedAt: '2023-02-12T08:03:16.241Z',
    submittedAt: '2023-02-12T08:03:16.233Z'
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
bhakiyakalimuthu commented 1 year ago

Hi Thank you for your report. After the merge, the field isSendToMiners will be omitted, meaning it should always be set to false. Please use V2 stats endpoints. so inclusion is not related to this field.

Neronjust2017 commented 1 year ago

Hi Thank you for your report. After the merge, the field isSendToMiners will be omitted, meaning it should always be set to false. Please use V2 stats endpoints. so inclusion is not related to this field.

Hi, thanks for your answer! I tested it again and this time I set the priority gas price to 500Gwei on Goerli to make sure builders will be likely to consider these bundles. I sent bundles in turn to target blocks from 8560814 to 8560816. As you can see, the first bundle was considered and sealed by some builders. According to https://collective.flashbots.net/t/flashbots-bundle-relay-api-upgrades/896, a bundle being sealed indicates a builder built a full block containing that bundle. Since it had been successfully sealed on block 8560814, why did it not be included? Is it the competition between the builders that causes the validators didn't select these blocks? If I further increase gas price, would that increase the probability of being included in the first block? Or because of the network problem, it is too late when builders received the bundle. In this case, reducing the network delay may solve the problem. Looking forward to your opinion. Thanks!

bundleHash:  0x1b3642af122d2ddf89e63a82acbac15844dfc5cb06f853407908ca9d46cd7cee
bundle submitted, waiting 0x1b3642af122d2ddf89e63a82acbac15844dfc5cb06f853407908ca9d46cd7cee
>>>>>>  1
bundle submitted, waiting 0x1b3642af122d2ddf89e63a82acbac15844dfc5cb06f853407908ca9d46cd7cee
Wait Response: BlockPassedWithoutInclusion
{
  BlockNumber: 8560814,
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-26T15:39:45.289Z',
    submittedAt: '2023-02-26T15:39:45.283Z',
    consideredByBuildersAt: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ],
    sealedByBuildersAt: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ]
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  2
bundle submitted, waiting 0x1b3642af122d2ddf89e63a82acbac15844dfc5cb06f853407908ca9d46cd7cee
Wait Response: BlockPassedWithoutInclusion
{
  BlockNumber: 8560815,
  bundleStats: {
    isHighPriority: true,
    isSentToMiners: false,
    isSimulated: true,
    simulatedAt: '2023-02-26T15:39:55.861Z',
    submittedAt: '2023-02-26T15:39:55.856Z',
    consideredByBuildersAt: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object]
    ],
    sealedByBuildersAt: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object]
    ]
  },
  userStats: {
    all_time_gas_simulated: '',
    all_time_miner_payments: '',
    is_high_priority: false,
    last_1d_gas_simulated: '',
    last_1d_miner_payments: '',
    last_7d_gas_simulated: '',
    last_7d_miner_payments: ''
  }
}
>>>>>>  3
bundle submitted, waiting 0x1b3642af122d2ddf89e63a82acbac15844dfc5cb06f853407908ca9d46cd7cee
Wait Response: BundleIncluded
Bundle included!
mikasres commented 3 weeks ago

@Neronjust2017, hi, I am currently facing the same issue, i was wondering if you managed to solve it