-
Notifications
You must be signed in to change notification settings - Fork 283
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
Add clients information to user's graffiti when producing a block #8107
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
28bc1c8
Add clients information to user's graffiti when producing a block
zilm13 58ec4e7
Fix createTekuVersion import dependency issues
zilm13 799d59c
Decrease waiting time for correct block in test
zilm13 c5241da
Remove extra ClientGraffitiAppendFormat options
zilm13 71b7763
Fix the test
zilm13 a622b5f
Split big tests, to have less assertions in every test case
zilm13 4e4ce61
Merge branch 'master' into graffitti-append
zilm13 8774ac3
Polishing per feedback
zilm13 b11aad9
Rename CLIENT_NAMES -> CLIENT_CODES
zilm13 dcf1e78
Merge branch 'master' into graffitti-append
zilm13 b3543c3
Merge branch 'master' into graffitti-append
zilm13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
...c/acceptance-test/java/tech/pegasys/teku/test/acceptance/BlockProposalAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright Consensys Software Inc., 2022 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.test.acceptance; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.google.common.io.Resources; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Arrays; | ||
import java.util.Locale; | ||
import org.apache.tuweni.bytes.Bytes32; | ||
import org.junit.jupiter.api.Test; | ||
import tech.pegasys.teku.api.schema.bellatrix.SignedBeaconBlockBellatrix; | ||
import tech.pegasys.teku.infrastructure.unsigned.UInt64; | ||
import tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase; | ||
import tech.pegasys.teku.test.acceptance.dsl.GenesisGenerator.InitialStateData; | ||
import tech.pegasys.teku.test.acceptance.dsl.TekuBeaconNode; | ||
import tech.pegasys.teku.test.acceptance.dsl.TekuNodeConfigBuilder; | ||
import tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode; | ||
import tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores; | ||
|
||
public class BlockProposalAcceptanceTest extends AcceptanceTestBase { | ||
private static final URL JWT_FILE = Resources.getResource("auth/ee-jwt-secret.hex"); | ||
|
||
@Test | ||
void shouldHaveCorrectFeeRecipientAndGraffiti() throws Exception { | ||
final String networkName = "swift"; | ||
|
||
final ValidatorKeystores validatorKeystores = | ||
createTekuDepositSender(networkName).generateValidatorKeys(8); | ||
|
||
final InitialStateData genesis = | ||
createGenesisGenerator() | ||
.network(networkName) | ||
.withAltairEpoch(UInt64.ZERO) | ||
.withBellatrixEpoch(UInt64.ZERO) | ||
.validatorKeys(validatorKeystores, validatorKeystores) | ||
.generate(); | ||
|
||
final String defaultFeeRecipient = "0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73"; | ||
final String userGraffiti = "My block \uD83D\uDE80"; // 13 bytes | ||
final TekuBeaconNode beaconNode = | ||
createTekuBeaconNode( | ||
TekuNodeConfigBuilder.createBeaconNode() | ||
.withStubExecutionEngine() | ||
.withJwtSecretFile(JWT_FILE) | ||
.withNetwork(networkName) | ||
.withInitialState(genesis) | ||
.withAltairEpoch(UInt64.ZERO) | ||
.withBellatrixEpoch(UInt64.ZERO) | ||
.withValidatorProposerDefaultFeeRecipient(defaultFeeRecipient) | ||
.build()); | ||
final TekuValidatorNode validatorClient = | ||
createValidatorNode( | ||
TekuNodeConfigBuilder.createValidatorClient() | ||
.withReadOnlyKeystorePath(validatorKeystores) | ||
.withValidatorProposerDefaultFeeRecipient(defaultFeeRecipient) | ||
.withInteropModeDisabled() | ||
.withBeaconNodes(beaconNode) | ||
.withGraffiti(userGraffiti) | ||
.withNetwork("auto") | ||
.build()); | ||
|
||
beaconNode.start(); | ||
validatorClient.start(); | ||
|
||
beaconNode.waitForBlockSatisfying( | ||
block -> { | ||
assertThat(block).isInstanceOf(SignedBeaconBlockBellatrix.class); | ||
final SignedBeaconBlockBellatrix bellatrixBlock = (SignedBeaconBlockBellatrix) block; | ||
assertThat( | ||
bellatrixBlock.getMessage().getBody().executionPayload.feeRecipient.toHexString()) | ||
.isEqualTo(defaultFeeRecipient.toLowerCase(Locale.ROOT)); | ||
final Bytes32 graffiti = bellatrixBlock.getMessage().getBody().graffiti; | ||
final String graffitiMessage = | ||
new String( | ||
Arrays.copyOfRange( | ||
graffiti.toArray(), 0, 32 - graffiti.numberOfTrailingZeroBytes()), | ||
StandardCharsets.UTF_8); | ||
// 13 bytes + 1 byte | ||
assertThat(graffitiMessage).startsWith(userGraffiti + " "); | ||
// 18 bytes left, so 12 bytes client footprint: TKxxxxELxxxx. 20 bytes with full commits | ||
// doesn't fit | ||
assertThat(graffitiMessage).contains("TK"); | ||
// stub execution endpoint. | ||
assertThat(graffitiMessage).endsWith("SB0000"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 0 additions & 117 deletions
117
...or/src/main/java/tech/pegasys/teku/validator/coordinator/DefaultGraffitiProviderImpl.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 minutes is a long timeout for a default...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy-paste
will fix