Skip to content

Commit

Permalink
Merge branch 'acp-99-reference-impl-improvements' into acp-99-referen…
Browse files Browse the repository at this point in the history
…ce-impl-multi-contract; remove unused error defs
  • Loading branch information
cam-schultz committed Jan 23, 2025
2 parents 79977f0 + 9c8bb74 commit bb7759c
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 62 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Semgrep
on:
push:
branches-ignore:
- "dependabot/**"
pull_request:
branches:
- "dependabot/**"
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-latest

container:
image: semgrep/semgrep

if: (github.actor != 'dependabot[bot]')

steps:
- uses: actions/checkout@v4
- run: semgrep ci --dry-run --sarif > semgrep.sarif
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN_PUB }}

- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: semgrep.sarif
if: always()
36 changes: 0 additions & 36 deletions .github/workflows/snyk.yml

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

26 changes: 8 additions & 18 deletions contracts/validator-manager/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,12 @@ abstract contract PoSValidatorManager is
error ZeroWeightToValueFactor();
error InvalidUptimeBlockchainID(bytes32 uptimeBlockchainID);

error InvalidValidatorManagerAddress(address validatorManagerAddress);
error InvalidWarpOriginSenderAddress(address senderAddress);
error InvalidValidatorManagerBlockchainID(bytes32 blockchainID);
error InvalidWarpSourceChainID(bytes32 sourceChainID);
error InvalidRegistrationExpiry(uint64 registrationExpiry);
error InvalidInitializationStatus();
error InvalidMaximumChurnPercentage(uint8 maximumChurnPercentage);
error InvalidBLSKeyLength(uint256 length);
error InvalidNodeID(bytes nodeID);
error InvalidConversionID(bytes32 encodedConversionID, bytes32 expectedConversionID);
error InvalidTotalWeight(uint64 weight);
error InvalidValidationID(bytes32 validationID);
error UnexpectedValidationID(bytes32 validationID, bytes32 expectedValidationID);
error InvalidValidatorStatus(ValidatorStatus status);
error InvalidNonce(uint64 nonce);
error InvalidWarpMessage();
error MaxChurnRateExceeded(uint64 churnAmount);
error NodeAlreadyRegistered(bytes nodeID);
error UnexpectedRegistrationStatus(bool validRegistration);
error InvalidPChainOwnerThreshold(uint256 threshold, uint256 addressesLength);
error PChainOwnerAddressesNotSorted();

// solhint-disable ordering
/**
Expand Down Expand Up @@ -359,6 +345,9 @@ abstract contract PoSValidatorManager is
PoSValidatorManagerStorage storage $ = _getPoSValidatorManagerStorage();

$._manager.initiateValidatorRemoval(validationID);

// The validator must be fetched after the removal has been initiated, since the above call modifies
// the validator's state.
Validator memory validator = $._manager.getValidator(validationID);

// Non-PoS validators are required to boostrap the network, but are not eligible for rewards.
Expand Down Expand Up @@ -479,7 +468,7 @@ abstract contract PoSValidatorManager is
(bytes32 uptimeValidationID, uint64 uptime) =
ValidatorMessages.unpackValidationUptimeMessage(warpMessage.payload);
if (validationID != uptimeValidationID) {
revert InvalidValidationID(validationID);
revert UnexpectedValidationID(uptimeValidationID, validationID);
}

if (uptime > $._posValidatorInfo[validationID].uptimeSeconds) {
Expand Down Expand Up @@ -657,8 +646,9 @@ abstract contract PoSValidatorManager is
if (validator.receivedNonce < delegator.startingNonce) {
(bytes32 messageValidationID, uint64 nonce) =
$._manager.completeValidatorWeightUpdate(messageIndex);

if (validationID != messageValidationID) {
revert InvalidValidationID(delegator.validationID);
revert UnexpectedValidationID(messageValidationID, validationID);
}
if (nonce < delegator.startingNonce) {
revert InvalidNonce(nonce);
Expand Down Expand Up @@ -918,7 +908,7 @@ abstract contract PoSValidatorManager is
(bytes32 validationID, uint64 nonce) =
$._manager.completeValidatorWeightUpdate(messageIndex);
if (delegator.validationID != validationID) {
revert InvalidValidationID(validationID);
revert UnexpectedValidationID(validationID, delegator.validationID);
}

// The received nonce should be at least as high as the delegation's ending nonce. This allows a weight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {

vm.warp(DEFAULT_COMPLETION_TIMESTAMP);
vm.expectRevert(
abi.encodeWithSelector(ValidatorManager.InvalidValidationID.selector, validationID)
abi.encodeWithSelector(
PoSValidatorManager.UnexpectedValidationID.selector, bytes32(0), validationID
)
);
posValidatorManager.initiateValidatorRemoval(validationID, true, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
golang.org/x/tools v0.29.0
google.golang.org/protobuf v1.36.2
google.golang.org/protobuf v1.36.3
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down

0 comments on commit bb7759c

Please sign in to comment.