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
21ef8765
Commit
21ef8765
authored
Jul 17, 2025
by
panchengzhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jsonprc4j attack
parent
ac83284e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
254 additions
and
0 deletions
+254
-0
AttackService.java
.../main/java/tech/pegasys/teku/attacker2/AttackService.java
+228
-0
JsonRpcClientUtil.java
...n/java/tech/pegasys/teku/attacker2/JsonRpcClientUtil.java
+26
-0
No files found.
attacker/client/src/main/java/tech/pegasys/teku/attacker2/AttackService.java
0 → 100644
View file @
21ef8765
package
tech
.
pegasys
.
teku
.
attacker2
;
import
com.googlecode.jsonrpc4j.JsonRpcHttpClient
;
import
tech.pegasys.teku.attacker.client.*
;
import
tech.pegasys.teku.infrastructure.async.SafeFuture
;
public
class
AttackService
{
private
static
final
String
BLOCK_MODULE
=
"block"
;
private
static
final
String
ATTEST_MODULE
=
"attest"
;
/**
* Get new parent root for block.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param parentRoot The parent root
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
blockGetNewParentRoot
(
long
slot
,
String
pubkey
,
String
parentRoot
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
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
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
ATTEST_MODULE
+
"_afterBroadCast"
,
new
Object
[]
{
slot
},
AttackerResponse
.
class
);
}
/**
* Before signing attestation.
*
* @param slot The slot number
* @param pubkey The validator public key
* @param attestDataBase64 The attestation data in base64 encoding
* @return A future that completes with the response
*/
public
SafeFuture
<
AttackerResponse
>
attestBeforeSign
(
long
slot
,
String
pubkey
,
String
attestDataBase64
)
{
return
JsonRpcClientUtil
.
getJsonRpcClient
().
invoke
(
ATTEST_MODULE
+
"_beforeSign"
,
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
);
}
}
attacker/client/src/main/java/tech/pegasys/teku/attacker2/JsonRpcClientUtil.java
0 → 100644
View file @
21ef8765
package
tech
.
pegasys
.
teku
.
attacker2
;
import
com.googlecode.jsonrpc4j.JsonRpcHttpClient
;
import
java.net.URI
;
public
class
JsonRpcClientUtil
{
private
JsonRpcClientUtil
(){
}
public
static
JsonRpcHttpClient
getJsonRpcClient
(){
return
JsonRpcHttpClientSingleton
.
singleton
();
}
private
static
class
JsonRpcHttpClientSingleton
{
private
static
JsonRpcHttpClient
singleton
(){
JsonRpcHttpClient
client
=
null
;
try
{
client
=
new
JsonRpcHttpClient
(
URI
.
create
(
System
.
getenv
(
"ATTACKER_SERVICE_URL"
)).
toURL
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
client
;
}
}
}
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