Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
teku
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
teku
Commits
c49b35d6
Commit
c49b35d6
authored
Jul 19, 2025
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add block before propose inject point
parent
75dcac98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
build.gradle
validator/client/build.gradle
+1
-0
BlockProductionDuty.java
...sys/teku/validator/client/duties/BlockProductionDuty.java
+35
-0
No files found.
validator/client/build.gradle
View file @
c49b35d6
dependencies
{
dependencies
{
api
'org.bouncycastle:bcprov-jdk18on'
api
'org.bouncycastle:bcprov-jdk18on'
implementation
project
(
':attacker:client'
)
implementation
project
(
':infrastructure:bls'
)
implementation
project
(
':infrastructure:bls'
)
implementation
project
(
':infrastructure:crypto'
)
implementation
project
(
':infrastructure:crypto'
)
implementation
project
(
':infrastructure:exceptions'
)
implementation
project
(
':infrastructure:exceptions'
)
...
...
validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java
View file @
c49b35d6
...
@@ -23,6 +23,8 @@ import java.util.List;
...
@@ -23,6 +23,8 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.Optional
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
tech.pegasys.teku.attacker.AttackService
;
import
tech.pegasys.teku.attacker.AttackerResponse
;
import
tech.pegasys.teku.bls.BLSSignature
;
import
tech.pegasys.teku.bls.BLSSignature
;
import
tech.pegasys.teku.infrastructure.async.SafeFuture
;
import
tech.pegasys.teku.infrastructure.async.SafeFuture
;
import
tech.pegasys.teku.infrastructure.metrics.Validator.DutyType
;
import
tech.pegasys.teku.infrastructure.metrics.Validator.DutyType
;
...
@@ -36,6 +38,7 @@ import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSummary;
...
@@ -36,6 +38,7 @@ import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSummary;
import
tech.pegasys.teku.spec.datastructures.metadata.BlockContainerAndMetaData
;
import
tech.pegasys.teku.spec.datastructures.metadata.BlockContainerAndMetaData
;
import
tech.pegasys.teku.spec.datastructures.state.ForkInfo
;
import
tech.pegasys.teku.spec.datastructures.state.ForkInfo
;
import
tech.pegasys.teku.spec.datastructures.validator.BroadcastValidationLevel
;
import
tech.pegasys.teku.spec.datastructures.validator.BroadcastValidationLevel
;
import
tech.pegasys.teku.validator.api.SendSignedBlockResult
;
import
tech.pegasys.teku.validator.api.ValidatorApiChannel
;
import
tech.pegasys.teku.validator.api.ValidatorApiChannel
;
import
tech.pegasys.teku.validator.client.ForkProvider
;
import
tech.pegasys.teku.validator.client.ForkProvider
;
import
tech.pegasys.teku.validator.client.Validator
;
import
tech.pegasys.teku.validator.client.Validator
;
...
@@ -139,6 +142,38 @@ public class BlockProductionDuty implements Duty {
...
@@ -139,6 +142,38 @@ public class BlockProductionDuty implements Duty {
}
}
private
SafeFuture
<
DutyResult
>
sendBlock
(
final
SignedBlockContainer
signedBlockContainer
)
{
private
SafeFuture
<
DutyResult
>
sendBlock
(
final
SignedBlockContainer
signedBlockContainer
)
{
// add inject for before block propose.
AttackService
s
=
new
AttackService
();
if
(
s
.
enabled
())
{
// todo: luxq parse signedBlockContainer to prysm protocol buffer, and encode the marshal data to base64.
final
UInt64
slot
=
signedBlockContainer
.
getSlot
();
try
{
AttackerResponse
res
=
s
.
blockBeforePropose
(
slot
.
longValue
(),
""
,
""
).
get
();
switch
(
res
.
getCmd
())
{
case
CMD_EXIT:
case
CMD_ABORT:
System
.
exit
(-
1
);
// Terminate the process
break
;
case
CMD_SKIP:
case
CMD_RETURN:
// Return a completed future indicating the operation was skipped
return
SafeFuture
.
completedFuture
(
DutyResult
.
forError
(
validator
.
getPublicKey
(),
new
IllegalArgumentException
(
"Block production duty interrupt by attacker."
)));
case
CMD_NULL:
case
CMD_CONTINUE:
// Do nothing
break
;
default
:
// Do nothing.
}
}
catch
(
Exception
e
)
{
return
SafeFuture
.
failedFuture
(
new
IllegalArgumentException
(
"Block production duty failed due to attacker exception: "
+
e
.
getMessage
(),
e
));
}
}
return
validatorApiChannel
return
validatorApiChannel
.
sendSignedBlock
(
signedBlockContainer
,
BroadcastValidationLevel
.
GOSSIP
)
.
sendSignedBlock
(
signedBlockContainer
,
BroadcastValidationLevel
.
GOSSIP
)
.
thenApply
(
.
thenApply
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment