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
249eb9c2
Commit
249eb9c2
authored
Jul 17, 2025
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error
parent
76fec17e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
208 deletions
+64
-208
AttackService.java
...c/main/java/tech/pegasys/teku/attacker/AttackService.java
+64
-208
No files found.
attacker/client/src/main/java/tech/pegasys/teku/attacker/AttackService.java
View file @
249eb9c2
package
tech
.
pegasys
.
teku
.
attacker
;
package
tech
.
pegasys
.
teku
.
attacker
;
import
com.googlecode.jsonrpc4j.JsonRpcHttpClient
;
import
com.googlecode.jsonrpc4j.JsonRpcHttpClient
;
import
tech.pegasys.teku.infrastructure.async.SafeFuture
;
import
tech.pegasys.teku.infrastructure.async.SafeFuture
;
public
class
AttackService
{
public
class
AttackService
{
private
static
final
String
BLOCK_MODULE
=
"block"
;
private
static
final
String
BLOCK_MODULE
=
"block"
;
private
static
final
String
ATTEST_MODULE
=
"attest"
;
private
static
final
String
ATTEST_MODULE
=
"attest"
;
/**
private
final
JsonRpcHttpClient
jsonRpcClient
;
* Get new parent root for block.
*
public
AttackService
()
{
* @param slot The slot number
this
.
jsonRpcClient
=
JsonRpcClientUtil
.
getJsonRpcClient
();
* @param pubkey The validator public key
}
* @param parentRoot The parent root
* @return A future that completes with the response
private
SafeFuture
<
AttackerResponse
>
invokeRpc
(
String
method
,
Object
[]
params
)
{
*/
try
{
AttackerResponse
response
=
jsonRpcClient
.
invoke
(
method
,
params
,
AttackerResponse
.
class
);
return
SafeFuture
.
completedFuture
(
response
);
}
catch
(
Exception
e
)
{
return
SafeFuture
.
failedFuture
(
e
);
}
catch
(
Throwable
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
SafeFuture
<
AttackerResponse
>
blockGetNewParentRoot
(
long
slot
,
String
pubkey
,
String
parentRoot
)
{
public
SafeFuture
<
AttackerResponse
>
blockGetNewParentRoot
(
long
slot
,
String
pubkey
,
String
parentRoot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_getNewParentRoot"
,
new
Object
[]{
slot
,
pubkey
,
parentRoot
});
BLOCK_MODULE
+
"_getNewParentRoot"
,
}
new
Object
[]
{
slot
,
pubkey
,
parentRoot
},
AttackerResponse
.
class
);
}
/**
* Delay for receive block.
*
* @param slot The slot number
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
delayForReceiveBlock
(
long
slot
)
{
public
SafeFuture
<
AttackerResponse
>
delayForReceiveBlock
(
long
slot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_delayForReceiveBlock"
,
new
Object
[]{
slot
});
BLOCK_MODULE
+
"_delayForReceiveBlock"
,
}
new
Object
[]
{
slot
},
AttackerResponse
.
class
);
}
/**
* Before block broadcast.
*
* @param slot The slot number
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockBeforeBroadcast
(
long
slot
)
{
public
SafeFuture
<
AttackerResponse
>
blockBeforeBroadcast
(
long
slot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_beforeBroadCast"
,
new
Object
[]{
slot
});
BLOCK_MODULE
+
"_beforeBroadCast"
,
}
new
Object
[]
{
slot
},
AttackerResponse
.
class
);
}
/**
* After block broadcast.
*
* @param slot The slot number
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockAfterBroadcast
(
long
slot
)
{
public
SafeFuture
<
AttackerResponse
>
blockAfterBroadcast
(
long
slot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_afterBroadCast"
,
new
Object
[]{
slot
});
BLOCK_MODULE
+
"_afterBroadCast"
,
}
new
Object
[]
{
slot
},
AttackerResponse
.
class
);
}
/**
* Before sign block.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param blockDataBase64 The block data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockBeforeSign
(
long
slot
,
String
pubkey
,
String
blockDataBase64
)
{
public
SafeFuture
<
AttackerResponse
>
blockBeforeSign
(
long
slot
,
String
pubkey
,
String
blockDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_beforeSign"
,
new
Object
[]{
slot
,
pubkey
,
blockDataBase64
});
BLOCK_MODULE
+
"_beforeSign"
,
}
AttackerResponse
.
class
,
new
Object
[]
{
slot
,
pubkey
,
blockDataBase64
},
AttackerResponse
.
class
);
}
/**
* After sign block.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param signedBlockDataBase64 The signed block data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockAfterSign
(
long
slot
,
String
pubkey
,
String
signedBlockDataBase64
)
{
public
SafeFuture
<
AttackerResponse
>
blockAfterSign
(
long
slot
,
String
pubkey
,
String
signedBlockDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_afterSign"
,
new
Object
[]{
slot
,
pubkey
,
signedBlockDataBase64
});
BLOCK_MODULE
+
"_afterSign"
,
}
new
Object
[]
{
slot
,
pubkey
,
signedBlockDataBase64
},
AttackerResponse
.
class
);
}
/**
* Before propose block.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param signedBlockDataBase64 The signed block data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockBeforePropose
(
long
slot
,
String
pubkey
,
String
signedBlockDataBase64
)
{
public
SafeFuture
<
AttackerResponse
>
blockBeforePropose
(
long
slot
,
String
pubkey
,
String
signedBlockDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_beforePropose"
,
new
Object
[]{
slot
,
pubkey
,
signedBlockDataBase64
});
BLOCK_MODULE
+
"_beforePropose"
,
}
new
Object
[]
{
slot
,
pubkey
,
signedBlockDataBase64
},
AttackerResponse
.
class
);
}
/**
* After propose block.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param signedBlockDataBase64 The signed block data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockAfterPropose
(
long
slot
,
String
pubkey
,
String
signedBlockDataBase64
)
{
public
SafeFuture
<
AttackerResponse
>
blockAfterPropose
(
long
slot
,
String
pubkey
,
String
signedBlockDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
BLOCK_MODULE
+
"_afterPropose"
,
new
Object
[]{
slot
,
pubkey
,
signedBlockDataBase64
});
BLOCK_MODULE
+
"_afterPropose"
,
}
new
Object
[]
{
slot
,
pubkey
,
signedBlockDataBase64
},
AttackerResponse
.
class
);
}
/**
* Before attestation broadcast.
*
* @param slot The slot number
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
attestBeforeBroadcast
(
long
slot
)
{
public
SafeFuture
<
AttackerResponse
>
attestBeforeBroadcast
(
long
slot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
ATTEST_MODULE
+
"_beforeBroadCast"
,
new
Object
[]{
slot
});
ATTEST_MODULE
+
"_beforeBroadCast"
,
}
new
Object
[]
{
slot
},
AttackerResponse
.
class
);
}
/**
* After attestation broadcast.
*
* @param slot The slot number
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
attestAfterBroadcast
(
long
slot
)
{
public
SafeFuture
<
AttackerResponse
>
attestAfterBroadcast
(
long
slot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
return
invokeRpc
(
ATTEST_MODULE
+
"_afterBroadCast"
,
new
Object
[]{
slot
});
ATTEST_MODULE
+
"_afterBroadCast"
,
}
new
Object
[]
{
slot
},
AttackerResponse
.
class
);
public
SafeFuture
<
AttackerResponse
>
attestBeforeSign
(
long
slot
,
String
pubkey
,
String
attestDataBase64
)
{
}
return
invokeRpc
(
ATTEST_MODULE
+
"_beforeSign"
,
new
Object
[]{
slot
,
pubkey
,
attestDataBase64
});
}
/**
* Before signing attestation.
public
SafeFuture
<
AttackerResponse
>
attestAfterSign
(
long
slot
,
String
pubkey
,
String
signedAttestDataBase64
)
{
*
return
invokeRpc
(
ATTEST_MODULE
+
"_afterSign"
,
new
Object
[]{
slot
,
pubkey
,
signedAttestDataBase64
});
* @param slot The slot number
}
* @param pubkey The validator public key
* @param attestDataBase64 The attestation data in base64 encoding
public
SafeFuture
<
AttackerResponse
>
attestBeforePropose
(
long
slot
,
String
pubkey
,
String
signedAttestDataBase64
)
{
* @return A future that completes with the response
return
invokeRpc
(
ATTEST_MODULE
+
"_beforePropose"
,
new
Object
[]{
slot
,
pubkey
,
signedAttestDataBase64
});
*/
}
public
SafeFuture
<
AttackerResponse
>
attestBeforeSign
(
long
slot
,
public
SafeFuture
<
AttackerResponse
>
attestAfterPropose
(
long
slot
,
String
pubkey
,
String
signedAttestDataBase64
)
{
String
pubkey
,
return
invokeRpc
(
ATTEST_MODULE
+
"_afterPropose"
,
new
Object
[]{
slot
,
pubkey
,
signedAttestDataBase64
});
String
attestDataBase64
)
{
}
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
}
ATTEST_MODULE
+
"_beforeSign"
,
\ No newline at end of file
new
Object
[]
{
slot
,
pubkey
,
attestDataBase64
},
AttackerResponse
.
class
);
}
/**
* After signing attestation.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param signedAttestDataBase64 The signed attestation data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
attestAfterSign
(
long
slot
,
String
pubkey
,
String
signedAttestDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
ATTEST_MODULE
+
"_afterSign"
,
new
Object
[]
{
slot
,
pubkey
,
signedAttestDataBase64
},
AttackerResponse
.
class
);
}
/**
* Before proposing attestation.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param signedAttestDataBase64 The signed attestation data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
attestBeforePropose
(
long
slot
,
String
pubkey
,
String
signedAttestDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
ATTEST_MODULE
+
"_beforePropose"
,
new
Object
[]
{
slot
,
pubkey
,
signedAttestDataBase64
},
AttackerResponse
.
class
);
}
/**
* After proposing attestation.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param signedAttestDataBase64 The signed attestation data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
attestAfterPropose
(
long
slot
,
String
pubkey
,
String
signedAttestDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
ATTEST_MODULE
+
"_afterPropose"
,
new
Object
[]
{
slot
,
pubkey
,
signedAttestDataBase64
},
AttackerResponse
.
class
);
}
}
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