Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add support for block validation (flashbots_validateBuilderSubmissionV3) #7335

Merged
merged 134 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
d33add6
add init code for block validation
rjnrohit Aug 16, 2024
9eb6f70
format files
rjnrohit Aug 16, 2024
ae4357f
verify blobs
rjnrohit Aug 27, 2024
346330d
create block processor
rjnrohit Sep 2, 2024
b802039
add modal validate payload
rjnrohit Sep 4, 2024
6ad5909
format files
rjnrohit Sep 4, 2024
3cf82fe
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Sep 4, 2024
256da82
add hook step
rjnrohit Sep 5, 2024
a749b8e
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Sep 5, 2024
09b46b4
add config
rjnrohit Sep 5, 2024
621e297
format files
rjnrohit Sep 5, 2024
ffc25f0
address PR comments
rjnrohit Sep 12, 2024
1bebf60
Hookup BlockValidation plugin in Nethermind.Runner
LukaszRozmej Sep 12, 2024
570dce0
Update Fast Sync configuration in Nethermind repository (#7401)
core-repository-dispatch-app[bot] Sep 8, 2024
bec7a5d
Feature/geth like system tx (#7252)
LukaszRozmej Sep 9, 2024
8b8cd01
Heuristic tx censorship detection (#7259)
Arindam2407 Sep 10, 2024
69e36dd
Refactor `TxValidator` (#7386)
emlautarom1 Sep 10, 2024
17533eb
Moved BlockProductionTimeout to config, increased BlockProductionTime…
MarekM25 Sep 10, 2024
c1f9455
Reduce memory use during Archive Sync (#7407)
benaadams Sep 11, 2024
5aebe9b
Update Supported Networks in Readme (#7412)
MarekM25 Sep 11, 2024
37b9fb4
Change Windows native Allocator (#7418)
benaadams Sep 11, 2024
4a17264
Fast address equals (#7417)
benaadams Sep 11, 2024
413a5b3
Reduce backlog threshold for GC (#7415)
benaadams Sep 11, 2024
bb3753d
Bump unstable to 1.29.0 (#7416)
kamilchodola Sep 11, 2024
4373e5a
enable flashBots module
rjnrohit Sep 12, 2024
a73b41a
format files
rjnrohit Sep 12, 2024
cfe14f2
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Sep 12, 2024
71e03eb
rename blockValidation -> flashbots
rjnrohit Sep 13, 2024
9f1bf85
rename params
rjnrohit Sep 13, 2024
d203d5e
revert holesky.cfg
rjnrohit Sep 13, 2024
1d7c272
add json required
rjnrohit Sep 19, 2024
2e4775c
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Sep 19, 2024
0c15eea
fix parameter serialization
rjnrohit Sep 23, 2024
ea60068
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Sep 23, 2024
558a425
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Sep 24, 2024
4eeeb9f
Add initial tests
rjnrohit Sep 26, 2024
c739854
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Oct 10, 2024
3bbce1f
format files
rjnrohit Oct 10, 2024
82d4747
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Oct 11, 2024
b9b2008
dummy
rjnrohit Oct 24, 2024
214b5f0
dummy
rjnrohit Oct 24, 2024
175a692
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Oct 28, 2024
a3b0550
fix balance check
rjnrohit Oct 30, 2024
b585e52
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Nov 6, 2024
a0361cf
fix small errors
rjnrohit Nov 11, 2024
2e75139
format files
rjnrohit Nov 11, 2024
a4bf424
Merge remote-tracking branch 'origin' into feature/flashbots_endpoints
rjnrohit Nov 11, 2024
14850e5
dummy
rjnrohit Nov 21, 2024
ee73d09
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Dec 10, 2024
65a969f
remove default account
rjnrohit Dec 17, 2024
568dd5d
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Dec 17, 2024
3ce68ee
dummy commit
rjnrohit Dec 19, 2024
6a9762d
add prewarmer
rjnrohit Dec 23, 2024
6640aca
revert dummy changes
rjnrohit Dec 23, 2024
b73c96b
remove using
rjnrohit Dec 23, 2024
b569844
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Dec 23, 2024
50414ee
change flashbots test
rjnrohit Dec 30, 2024
71c4aa8
Auto-update fast sync settings (#7957)
core-repository-dispatch-app[bot] Dec 23, 2024
eb62a45
Add GasLimit to NewPayoad log (#7955)
benaadams Dec 23, 2024
31cfaea
Reduce guard checks and interface calls when using ArrayPoolList (#7960)
benaadams Dec 23, 2024
e965565
Update Nethermind.Numerics.Int256 package (#7965)
rubo Dec 23, 2024
cd000fe
Refactor/move prewarm out of tx env base (#7963)
asdacap Dec 23, 2024
f8ed427
Set minimum state pivot to be at least the block after (#7949)
asdacap Dec 24, 2024
1a81d76
Refactor/remove tx processing env base (#7967)
asdacap Dec 27, 2024
cba9d1d
Make clique test a bit more resilient (#7969)
asdacap Dec 28, 2024
3b170fe
Refactor/isolate overrideable world state (#7968)
asdacap Dec 28, 2024
67fd2bc
Share stack pool between threads (#7972)
benaadams Dec 30, 2024
bbfc2cd
Auto-update fast sync settings (#7979)
core-repository-dispatch-app[bot] Dec 30, 2024
8eba3ac
Fix spammy log during snap sync (#7977)
asdacap Dec 30, 2024
8e6388b
Change for 7702 in devnet 5 (#7980)
ak88 Dec 30, 2024
5c6299f
Reduce parallel prewarming overwork (#7983)
benaadams Dec 31, 2024
14cfa0e
Reuse thread state when prewarming addresses in parallel (#7984)
benaadams Dec 31, 2024
a437a69
Update CodeQL actions to v3 (#7966)
rubo Dec 31, 2024
4aa70aa
Update file header (#7988)
rubo Jan 1, 2025
85e4c3b
Add schema to configs (#7493)
flcl42 Jan 1, 2025
f6cd53d
Reduce per tx execution allocations (#7990)
benaadams Jan 2, 2025
9c720ce
Optimism CL P2P (#7297)
deffrian Jan 2, 2025
abd10ff
New sys address for eip 2935 (#7982)
ak88 Jan 2, 2025
0d82497
Use system processor for SkipValidation txs (#7995)
benaadams Jan 2, 2025
0cfedec
Updated addresses for devnet 5 (#7994)
ak88 Jan 2, 2025
08b1389
Dont charge double account access gas for ext op (#7993)
ak88 Jan 2, 2025
7c81d7f
Faster Keccak Xor (#7998)
benaadams Jan 3, 2025
a7fd114
Revamp README and guidelines (#7996)
rubo Jan 3, 2025
f6277ba
Add Holocene timestamps for OP and Base (mainnet) (#8002)
emlautarom1 Jan 3, 2025
43ab75d
Recovering trie node message should be less severe (#8004)
benaadams Jan 4, 2025
95ec369
v2 Implement EIP-7623: Increase calldata cost (#7859)
tanishqjasoria Jan 4, 2025
e50539b
Back Bloom with inline array rather than byte[] (#8009)
benaadams Jan 5, 2025
9a07a4a
Back signature by Vector512 rather than byte[] (#8008)
benaadams Jan 6, 2025
396cbf1
Auto-update fast sync settings (#8006)
core-repository-dispatch-app[bot] Jan 6, 2025
b0d9bb1
Fix ChargeAccountAccessGas logic (#7997)
smartprogrammer93 Jan 6, 2025
2d76875
Bls precompiles: update gas costs (#7890)
Marchhill Jan 6, 2025
910e471
Bls precompiles: remove MUL (#7932)
Marchhill Jan 6, 2025
76eb8c0
Move prewarming as early as possible (#8001)
benaadams Jan 6, 2025
8df3c94
Feature/verifytrie admin rpc (#7962)
asdacap Jan 7, 2025
73aff9b
fix s and r values in AuthorizationListForRpc (#8013)
smartprogrammer93 Jan 7, 2025
34da23e
Add filter for max transaction size (#7925)
marcindsobczak Jan 7, 2025
1320ca3
Fix/unspent gas 7623 master (#8017)
Marchhill Jan 7, 2025
6e5bef3
update ring buffer size for eip-2935 (#8018)
tanishqjasoria Jan 7, 2025
54eb0a5
Update Nethermind.Numerics.Int256 (#8012)
rubo Jan 7, 2025
0574723
Fix empty value handling of configuration options (#8010)
rubo Jan 7, 2025
95b7d23
Ssz encoding generator (#7299)
flcl42 Jan 7, 2025
1424688
Revert removed admin_prune method in interface (#8026)
kamilchodola Jan 8, 2025
a04df32
Add eest to hive simulators (#8028)
MarekM25 Jan 8, 2025
cf42250
fix memory expansion to support up to uint.max instead of int.max (#8…
smartprogrammer93 Jan 9, 2025
e809703
Move `Test` projects to proper solution folder (#8032)
emlautarom1 Jan 9, 2025
5542082
Change more children derivation on snap sync (#8034)
damian-orzechowski Jan 9, 2025
b50c5d9
Add TxLookupLimit 0 for all missing archive nodes configs (#8039)
kamilchodola Jan 10, 2025
bb2e4a7
address few PR comments
rjnrohit Jan 11, 2025
337c6ca
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Jan 11, 2025
3c3c117
Add endpoint to support rBuilder payload (#8160)
rjnrohit Feb 6, 2025
7d92d68
change casing of the parameters
rjnrohit Feb 6, 2025
2d11e6a
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Feb 6, 2025
54791c3
apply rubo suggestions
rjnrohit Feb 6, 2025
554a229
revert bench precompiles
rjnrohit Feb 6, 2025
a3ea5b8
revert tests submodule
rjnrohit Feb 6, 2025
73317a4
add tests
rjnrohit Feb 6, 2025
8b50899
add tests
rjnrohit Feb 6, 2025
f453326
RExecutionPayloadV3 Json bugfix
mralj Feb 8, 2025
87e0ad8
remove redundant endpoint
rjnrohit Feb 11, 2025
dd3e944
Merge remote-tracking branch 'origin/feature/flashbots_endpoints' int…
rjnrohit Feb 11, 2025
4f9ad44
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Feb 11, 2025
75bf15e
fix withdrawals error
rjnrohit Feb 12, 2025
a5d9966
Merge remote-tracking branch 'origin/master' into feature/flashbots_e…
rjnrohit Feb 12, 2025
1236dce
add flashbots solution
rjnrohit Feb 12, 2025
66a7726
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Feb 13, 2025
cf01575
validation bugfixes
mralj Feb 13, 2025
700872b
update solution
rjnrohit Feb 13, 2025
fed4ed2
fix fail cases
rjnrohit Feb 14, 2025
5787334
remove sln file
rjnrohit Feb 14, 2025
3d983cb
format files
rjnrohit Feb 14, 2025
ad62444
add filter logging json RPC endpoint
rjnrohit Feb 17, 2025
ef29584
fix failing tests
rjnrohit Feb 17, 2025
42e1af3
refactor tests
rjnrohit Feb 17, 2025
15ae8bf
Merge branch 'master' into feature/flashbots_endpoints
rjnrohit Feb 17, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/nethermind-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- Nethermind.EthStats.Test
- Nethermind.Evm.Test
- Nethermind.Facade.Test
- Nethermind.Flashbots.Test
- Nethermind.HealthChecks.Test
- Nethermind.Hive.Test
- Nethermind.JsonRpc.Test
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Api/Extensions/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace Nethermind.Api.Extensions;

public class PluginConfig : IPluginConfig
{
public string[] PluginOrder { get; set; } = { "Clique", "Aura", "Ethash", "Optimism", "Shutter", "Taiko", "AuRaMerge", "Merge", "MEV", "HealthChecks", "Hive" };
public string[] PluginOrder { get; set; } = { "Clique", "Aura", "Ethash", "Optimism", "Shutter", "Taiko", "AuRaMerge", "Merge", "Flashbots", "MEV", "HealthChecks", "Hive" };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Threading.Tasks;
using Nethermind.Core;
using Nethermind.Crypto;
using Nethermind.Flashbots.Handlers;
using Nethermind.Flashbots.Modules.Flashbots;
using Nethermind.Int256;
using NUnit.Framework;
using Nethermind.Merge.Plugin.Test;
using Nethermind.Specs.Forks;
using Nethermind.Specs;
using Nethermind.Consensus.Processing;
using Nethermind.Core.Specs;
using Nethermind.Core.Extensions;

namespace Nethermind.Flashbots.Test;

public partial class FlashbotsModuleTests
{
TestKeyAndAddress? TestKeysAndAddress;

[SetUp]
public void SetUp()
{
TestKeysAndAddress = new TestKeyAndAddress();
}

internal class TestKeyAndAddress
{
public PrivateKey PrivateKey = new PrivateKey("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291");
public Address TestAddr;

public PrivateKey TestValidatorKey = new PrivateKey("28c3cd61b687fdd03488e167a5d84f50269df2a4c29a2cfb1390903aa775c5d0");
public Address TestValidatorAddr;

public PrivateKey TestBuilderKey = new PrivateKey("0bfbbbc68fefd990e61ba645efb84e0a62e94d5fff02c9b1da8eb45fea32b4e0");
public Address TestBuilderAddr;

public UInt256 TestBalance = UInt256.Parse("2000000000000000000");
public byte[] logCode = Bytes.FromHexString("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00");

public UInt256 BaseInitialFee = 1000000000;
public TestKeyAndAddress()
{
TestAddr = PrivateKey.Address;
TestValidatorAddr = TestValidatorKey.Address;
TestBuilderAddr = TestBuilderKey.Address;
}
}

public ReadOnlyTxProcessingEnvFactory CreateReadOnlyTxProcessingEnvFactory(EngineModuleTests.MergeTestBlockchain chain)
{
ReadOnlyTxProcessingEnvFactory readOnlyTxProcessingEnvFactory = new(
chain.WorldStateManager,
chain.BlockTree,
chain.SpecProvider,
chain.LogManager
);
return readOnlyTxProcessingEnvFactory;
}

protected static async Task<EngineModuleTests.MergeTestBlockchain> CreateBlockChain(
IReleaseSpec? releaseSpec = null)
=> await new EngineModuleTests.MergeTestBlockchain().Build(new TestSingleReleaseSpecProvider(releaseSpec ?? London.Instance));

private IFlashbotsRpcModule CreateFlashbotsModule(EngineModuleTests.MergeTestBlockchain chain, ReadOnlyTxProcessingEnvFactory readOnlyTxProcessingEnvFactory)
{
return new FlashbotsRpcModule(
new ValidateSubmissionHandler(
chain.HeaderValidator,
chain.BlockTree,
chain.BlockValidator,
readOnlyTxProcessingEnvFactory,
chain.LogManager,
chain.SpecProvider,
new FlashbotsConfig()
)
);
}
}
116 changes: 116 additions & 0 deletions src/Nethermind/Nethermind.Flashbots.Test/FlashbotsModuleTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using System.Threading.Tasks;
using FluentAssertions;
using Nethermind.Consensus.Processing;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Core.Extensions;
using Nethermind.Core.Specs;
using Nethermind.Core.Test.Builders;
using Nethermind.Flashbots.Data;
using Nethermind.Flashbots.Modules.Flashbots;
using Nethermind.Int256;
using Nethermind.JsonRpc;
using Nethermind.JsonRpc.Test;
using Nethermind.Merge.Plugin.Data;
using Nethermind.Merge.Plugin.Test;
using Nethermind.Specs.Forks;
using Nethermind.State;
using NUnit.Framework;

namespace Nethermind.Flashbots.Test;

public partial class FlashbotsModuleTests
{
private static readonly DateTime Timestamp = DateTimeOffset.FromUnixTimeSeconds(1000).UtcDateTime;
private ITimestamper Timestamper { get; } = new ManualTimestamper(Timestamp);

[Test]
public virtual async Task TestValidateBuilderSubmissionV3()
{
using EngineModuleTests.MergeTestBlockchain chain = await CreateBlockChain(releaseSpec: Cancun.Instance);
ReadOnlyTxProcessingEnvFactory readOnlyTxProcessingEnvFactory = CreateReadOnlyTxProcessingEnvFactory(chain);
IFlashbotsRpcModule rpc = CreateFlashbotsModule(chain, readOnlyTxProcessingEnvFactory);

Block block = CreateBlock(chain);

GetPayloadV3Result expectedPayload = new(block, UInt256.Zero, new BlobsBundleV1(block));

BuilderBlockValidationRequest BlockRequest = new(
new BidTrace(
0, block.Header.ParentHash,
block.Header.Hash,
TestKeysAndAddress.TestBuilderKey.PublicKey,
TestKeysAndAddress.TestValidatorKey.PublicKey,
TestKeysAndAddress.TestBuilderAddr,
block.Header.GasLimit,
block.Header.GasUsed,
new UInt256(132912184722469)
),
new RExecutionPayloadV3(ExecutionPayloadV3.Create(block)),
expectedPayload.BlobsBundle,
[],
block.Header.GasLimit,
new Hash256("0x0000000000000000000000000000000000000000000000000000000000000042")
);

ResultWrapper<FlashbotsResult> result = await rpc.flashbots_validateBuilderSubmissionV3(BlockRequest);
result.Should().NotBeNull();

Assert.That(result.Result.Error, Is.EqualTo("No proposer payment receipt"));
Assert.That(result.Data.Status, Is.EqualTo(FlashbotsStatus.Invalid));

string response = await RpcTest.TestSerializedRequest(rpc, "flashbots_validateBuilderSubmissionV3", BlockRequest);
JsonRpcSuccessResponse? jsonResponse = chain.JsonSerializer.Deserialize<JsonRpcSuccessResponse>(response);
jsonResponse.Should().NotBeNull();
}

private Block CreateBlock(EngineModuleTests.MergeTestBlockchain chain)
{
BlockHeader currentHeader = chain.BlockTree.Head.Header;
IWorldState State = chain.State;
State.CreateAccount(TestKeysAndAddress.TestAddr, TestKeysAndAddress.TestBalance);
UInt256 nonce = State.GetNonce(TestKeysAndAddress.TestAddr);

Withdrawal[] withdrawals = [
Build.A.Withdrawal.WithIndex(0).WithValidatorIndex(1).WithAmount(100).WithRecipient(TestKeysAndAddress.TestAddr).TestObject,
Build.A.Withdrawal.WithIndex(1).WithValidatorIndex(1).WithAmount(100).WithRecipient(TestKeysAndAddress.TestAddr).TestObject
];

Hash256 prevRandao = Keccak.Zero;

Hash256 expectedBlockHash = new("0x479f7c9b7389e9ff3f443b99c3cd4b90f9b7feef5f41d714edb59de6b3e7ac02");
string stateRoot = "0xa272b2f949e4a0e411c9b45542bd5d0ef3c311b5f26c4ed6b7a8d4f605a91154";

return new(
new(
currentHeader.Hash,
Keccak.OfAnEmptySequenceRlp,
TestKeysAndAddress.TestAddr,
UInt256.Zero,
1,
chain.BlockTree.Head!.GasLimit,
currentHeader.Timestamp + 12,
Bytes.FromHexString("0x4e65746865726d696e64") // Nethermind
)
{
BlobGasUsed = 0,
ExcessBlobGas = 0,
BaseFeePerGas = 0,
Bloom = Bloom.Empty,
GasUsed = 0,
Hash = expectedBlockHash,
MixHash = prevRandao,
ParentBeaconBlockRoot = Keccak.Zero,
ReceiptsRoot = chain.BlockTree.Head!.ReceiptsRoot!,
StateRoot = new(stateRoot),
},
[],
Array.Empty<BlockHeader>(),
withdrawals
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>annotations</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NSubstitute" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Nethermind.JsonRpc.Test\Nethermind.JsonRpc.Test.csproj" />
<ProjectReference Include="..\Nethermind.Consensus\Nethermind.Consensus.csproj" />
<ProjectReference Include="..\Nethermind.Core.Test\Nethermind.Core.Test.csproj" />
<ProjectReference Include="..\Nethermind.Merge.Plugin.Test\Nethermind.Merge.Plugin.Test.csproj" />
<ProjectReference Include="..\Nethermind.Flashbots\Nethermind.Flashbots.csproj" />
</ItemGroup>

</Project>
62 changes: 62 additions & 0 deletions src/Nethermind/Nethermind.Flashbots/Data/BidTrace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Int256;

namespace Nethermind.Flashbots.Data;

using System.Text.Json.Serialization;

public class BidTrace
{
[JsonPropertyName("slot")]
public ulong Slot { get; set; }

[JsonPropertyName("parent_hash")]
public Hash256 ParentHash { get; set; }

[JsonPropertyName("block_hash")]
public Hash256 BlockHash { get; set; }

[JsonPropertyName("builder_public_key")]
public PublicKey BuilderPublicKey { get; set; }

[JsonPropertyName("proposer_public_key")]
public PublicKey ProposerPublicKey { get; set; }

[JsonPropertyName("proposer_fee_recipient")]
public Address ProposerFeeRecipient { get; set; }

[JsonPropertyName("gas_limit")]
public long GasLimit { get; set; }

[JsonPropertyName("gas_used")]
public long GasUsed { get; set; }

[JsonPropertyName("value")]
public UInt256 Value { get; set; }

public BidTrace(
ulong slot,
Hash256 parentHash,
Hash256 blockHash,
PublicKey builderPublicKey,
PublicKey proposerPublicKey,
Address proposerFeeRecipient,
long gasLimit,
long gasUsed,
UInt256 value)
{
Slot = slot;
ParentHash = parentHash;
BlockHash = blockHash;
BuilderPublicKey = builderPublicKey;
ProposerPublicKey = proposerPublicKey;
ProposerFeeRecipient = proposerFeeRecipient;
GasLimit = gasLimit;
GasUsed = gasUsed;
Value = value;
}
}
47 changes: 47 additions & 0 deletions src/Nethermind/Nethermind.Flashbots/Data/BlockValidationResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System.Text.Json.Serialization;
using Nethermind.JsonRpc;

namespace Nethermind.Flashbots.Data;

/// <summary>
/// Represents the result of a block validation.
/// </summary>
public class FlashbotsResult
{

public static ResultWrapper<FlashbotsResult> Invalid(string error)
{
return ResultWrapper<FlashbotsResult>.Fail(error, new FlashbotsResult
{
Status = FlashbotsStatus.Invalid,
ValidationError = error
});
}

public static ResultWrapper<FlashbotsResult> Valid()
{
return ResultWrapper<FlashbotsResult>.Success(new FlashbotsResult
{
Status = FlashbotsStatus.Valid
});
}

public static ResultWrapper<FlashbotsResult> Error(string error)
{
return ResultWrapper<FlashbotsResult>.Fail(error);
}

/// <summary>
/// The status of the validation of the builder submissions
/// </summary>
public string Status { get; set; } = FlashbotsStatus.Invalid;

/// <summary>
/// Message providing additional details on the validation error if the payload is classified as <see cref="ValidationStatus.Invalid"/>.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public string? ValidationError { get; set; }
}
17 changes: 17 additions & 0 deletions src/Nethermind/Nethermind.Flashbots/Data/BlockValidationStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

namespace Nethermind.Flashbots.Data;

public static class FlashbotsStatus
{
/// <summary>
/// The submissions are invalid.
/// </summary>
public const string Invalid = "Invalid";

/// <summary>
/// The submissions are valid.
/// </summary>
public const string Valid = "Valid";
}
Loading