Commit 9f4170a5 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into docker/use-correct-forge

parents cbbf82ea ed305842
This diff is collapsed.
...@@ -94,6 +94,17 @@ func (a *Agent) step(claim Claim, game Game) error { ...@@ -94,6 +94,17 @@ func (a *Agent) step(claim Claim, game Game) error {
if claim.Depth() != a.maxDepth { if claim.Depth() != a.maxDepth {
return nil return nil
} }
if game.AgreeWithClaimLevel(claim) {
a.log.Warn("Agree with leaf claim, skipping step", "claim_depth", claim.Depth(), "maxDepth", a.maxDepth)
return nil
}
if claim.Countered {
a.log.Info("Claim already stepped on", "claim_depth", claim.Depth(), "maxDepth", a.maxDepth)
return nil
}
a.log.Info("Attempting step", "claim_depth", claim.Depth(), "maxDepth", a.maxDepth) a.log.Info("Attempting step", "claim_depth", claim.Depth(), "maxDepth", a.maxDepth)
step, err := a.solver.AttemptStep(claim) step, err := a.solver.AttemptStep(claim)
if err != nil { if err != nil {
......
...@@ -56,6 +56,8 @@ func (l *loader) fetchClaim(ctx context.Context, arrIndex uint64) (Claim, error) ...@@ -56,6 +56,8 @@ func (l *loader) fetchClaim(ctx context.Context, arrIndex uint64) (Claim, error)
Value: fetchedClaim.Claim, Value: fetchedClaim.Claim,
Position: NewPositionFromGIndex(fetchedClaim.Position.Uint64()), Position: NewPositionFromGIndex(fetchedClaim.Position.Uint64()),
}, },
Countered: fetchedClaim.Countered,
Clock: fetchedClaim.Clock.Uint64(),
ContractIndex: int(arrIndex), ContractIndex: int(arrIndex),
ParentContractIndex: int(fetchedClaim.ParentIndex), ParentContractIndex: int(fetchedClaim.ParentIndex),
} }
......
...@@ -42,14 +42,20 @@ func newMockClaimFetcher() *mockClaimFetcher { ...@@ -42,14 +42,20 @@ func newMockClaimFetcher() *mockClaimFetcher {
{ {
Claim: [32]byte{0x00}, Claim: [32]byte{0x00},
Position: big.NewInt(0), Position: big.NewInt(0),
Countered: false,
Clock: big.NewInt(0),
}, },
{ {
Claim: [32]byte{0x01}, Claim: [32]byte{0x01},
Position: big.NewInt(0), Position: big.NewInt(0),
Countered: false,
Clock: big.NewInt(0),
}, },
{ {
Claim: [32]byte{0x02}, Claim: [32]byte{0x02},
Position: big.NewInt(0), Position: big.NewInt(0),
Countered: false,
Clock: big.NewInt(0),
}, },
}, },
} }
...@@ -101,6 +107,8 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) { ...@@ -101,6 +107,8 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) {
Value: expectedClaims[0].Claim, Value: expectedClaims[0].Claim,
Position: NewPositionFromGIndex(expectedClaims[0].Position.Uint64()), Position: NewPositionFromGIndex(expectedClaims[0].Position.Uint64()),
}, },
Countered: false,
Clock: uint64(0),
ContractIndex: 0, ContractIndex: 0,
}, },
{ {
...@@ -112,6 +120,8 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) { ...@@ -112,6 +120,8 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) {
Value: expectedClaims[0].Claim, Value: expectedClaims[0].Claim,
Position: NewPositionFromGIndex(expectedClaims[1].Position.Uint64()), Position: NewPositionFromGIndex(expectedClaims[1].Position.Uint64()),
}, },
Countered: false,
Clock: uint64(0),
ContractIndex: 1, ContractIndex: 1,
}, },
{ {
...@@ -123,6 +133,8 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) { ...@@ -123,6 +133,8 @@ func TestLoader_FetchClaims_Succeeds(t *testing.T) {
Value: expectedClaims[0].Claim, Value: expectedClaims[0].Claim,
Position: NewPositionFromGIndex(expectedClaims[2].Position.Uint64()), Position: NewPositionFromGIndex(expectedClaims[2].Position.Uint64()),
}, },
Countered: false,
Clock: uint64(0),
ContractIndex: 2, ContractIndex: 2,
}, },
}, claims) }, claims)
......
...@@ -49,6 +49,12 @@ func (c *ClaimData) ValueBytes() [32]byte { ...@@ -49,6 +49,12 @@ func (c *ClaimData) ValueBytes() [32]byte {
// and the Parent field is empty & meaningless. // and the Parent field is empty & meaningless.
type Claim struct { type Claim struct {
ClaimData ClaimData
// WARN: Countered is a mutable field in the FaultDisputeGame contract
// and rely on it for determining whether to step on leaf claims.
// When caching is implemented for the Challenger, this will need
// to be changed/removed to avoid invalid/stale contract state.
Countered bool
Clock uint64
Parent ClaimData Parent ClaimData
// Location of the claim & it's parent inside the contract. Does not exist // Location of the claim & it's parent inside the contract. Does not exist
// for claims that have not made it to the contract. // for claims that have not made it to the contract.
......
...@@ -65,9 +65,6 @@ type Config struct { ...@@ -65,9 +65,6 @@ type Config struct {
DisableP2P bool DisableP2P bool
NoDiscovery bool NoDiscovery bool
// Enable P2P-based alt-syncing method (req-resp protocol, not gossip)
AltSync bool
ScoringParams *ScoringParams ScoringParams *ScoringParams
// Whether to ban peers based on their [PeerScoring] score. Should be negative. // Whether to ban peers based on their [PeerScoring] score. Should be negative.
......
...@@ -420,6 +420,11 @@ func (eq *EngineQueue) tryNextUnsafePayload(ctx context.Context) error { ...@@ -420,6 +420,11 @@ func (eq *EngineQueue) tryNextUnsafePayload(ctx context.Context) error {
eq.unsafePayloads.Pop() eq.unsafePayloads.Pop()
return nil return nil
} }
if uint64(first.BlockNumber) <= eq.unsafeHead.Number {
eq.log.Info("skipping unsafe payload, since it is older than unsafe head", "unsafe", eq.unsafeHead.ID(), "unsafe_payload", first.ID())
eq.unsafePayloads.Pop()
return nil
}
// Ensure that the unsafe payload builds upon the current unsafe head // Ensure that the unsafe payload builds upon the current unsafe head
// TODO: once we support snap-sync we can remove this condition, and handle the "SYNCING" status of the execution engine. // TODO: once we support snap-sync we can remove this condition, and handle the "SYNCING" status of the execution engine.
......
...@@ -1107,3 +1107,88 @@ func TestResetLoop(t *testing.T) { ...@@ -1107,3 +1107,88 @@ func TestResetLoop(t *testing.T) {
l1F.AssertExpectations(t) l1F.AssertExpectations(t)
eng.AssertExpectations(t) eng.AssertExpectations(t)
} }
func TestEngineQueue_StepPopOlderUnsafe(t *testing.T) {
logger := testlog.Logger(t, log.LvlInfo)
eng := &testutils.MockEngine{}
l1F := &testutils.MockL1Source{}
rng := rand.New(rand.NewSource(1234))
refA := testutils.RandomBlockRef(rng)
refA0 := eth.L2BlockRef{
Hash: testutils.RandomHash(rng),
Number: 0,
ParentHash: common.Hash{},
Time: refA.Time,
L1Origin: refA.ID(),
SequenceNumber: 0,
}
gasLimit := eth.Uint64Quantity(20_000_000)
cfg := &rollup.Config{
Genesis: rollup.Genesis{
L1: refA.ID(),
L2: refA0.ID(),
L2Time: refA0.Time,
SystemConfig: eth.SystemConfig{
BatcherAddr: common.Address{42},
Overhead: [32]byte{123},
Scalar: [32]byte{42},
GasLimit: 20_000_000,
},
},
BlockTime: 1,
SeqWindowSize: 2,
}
refA1 := eth.L2BlockRef{
Hash: testutils.RandomHash(rng),
Number: refA0.Number + 1,
ParentHash: refA0.Hash,
Time: refA0.Time + cfg.BlockTime,
L1Origin: refA.ID(),
SequenceNumber: 1,
}
refA2 := eth.L2BlockRef{
Hash: testutils.RandomHash(rng),
Number: refA1.Number + 1,
ParentHash: refA1.Hash,
Time: refA1.Time + cfg.BlockTime,
L1Origin: refA.ID(),
SequenceNumber: 2,
}
payloadA1 := &eth.ExecutionPayload{
ParentHash: refA1.ParentHash,
FeeRecipient: common.Address{},
StateRoot: eth.Bytes32{},
ReceiptsRoot: eth.Bytes32{},
LogsBloom: eth.Bytes256{},
PrevRandao: eth.Bytes32{},
BlockNumber: eth.Uint64Quantity(refA1.Number),
GasLimit: gasLimit,
GasUsed: 0,
Timestamp: eth.Uint64Quantity(refA1.Time),
ExtraData: nil,
BaseFeePerGas: *uint256.NewInt(7),
BlockHash: refA1.Hash,
Transactions: []eth.Data{},
}
prev := &fakeAttributesQueue{origin: refA}
eq := NewEngineQueue(logger, cfg, eng, metrics.NoopMetrics, prev, l1F)
eq.unsafeHead = refA2
eq.safeHead = refA0
eq.finalized = refA0
eq.AddUnsafePayload(payloadA1)
err := eq.Step(context.Background())
require.NoError(t, err)
require.Nil(t, eq.unsafePayloads.Peek(), "should pop the unsafe payload because it is too old")
fmt.Println(eq.unsafePayloads.Peek())
l1F.AssertExpectations(t)
eng.AssertExpectations(t)
}
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
}, },
"dependencies": { "dependencies": {
"@changesets/cli": "^2.26.0", "@changesets/cli": "^2.26.0",
"@codechecks/client": "^0.1.11", "@codechecks/client": "^0.1.11"
"@ethersproject/abstract-provider": "^5.7.0"
} }
} }
...@@ -35,7 +35,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ...@@ -35,7 +35,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
_; _;
} }
/// @custom:semver 1.0.1 /// @custom:semver 1.0.2
/// @param _bridge Address of the L2 standard bridge. /// @param _bridge Address of the L2 standard bridge.
/// @param _remoteToken Address of the corresponding L1 token. /// @param _remoteToken Address of the corresponding L1 token.
/// @param _name ERC20 name. /// @param _name ERC20 name.
...@@ -45,7 +45,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ...@@ -45,7 +45,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
address _remoteToken, address _remoteToken,
string memory _name, string memory _name,
string memory _symbol string memory _symbol
) ERC20(_name, _symbol) Semver(1, 0, 1) { ) ERC20(_name, _symbol) Semver(1, 0, 2) {
REMOTE_TOKEN = _remoteToken; REMOTE_TOKEN = _remoteToken;
BRIDGE = _bridge; BRIDGE = _bridge;
} }
...@@ -79,7 +79,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ...@@ -79,7 +79,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
/// @notice ERC165 interface check function. /// @notice ERC165 interface check function.
/// @param _interfaceId Interface ID to check. /// @param _interfaceId Interface ID to check.
/// @return Whether or not the interface is supported by this contract. /// @return Whether or not the interface is supported by this contract.
function supportsInterface(bytes4 _interfaceId) external pure returns (bool) { function supportsInterface(bytes4 _interfaceId) external pure virtual returns (bool) {
bytes4 iface1 = type(IERC165).interfaceId; bytes4 iface1 = type(IERC165).interfaceId;
// Interface corresponding to the legacy L2StandardERC20. // Interface corresponding to the legacy L2StandardERC20.
bytes4 iface2 = type(ILegacyMintableERC20).interfaceId; bytes4 iface2 = type(ILegacyMintableERC20).interfaceId;
......
...@@ -14,9 +14,6 @@ importers: ...@@ -14,9 +14,6 @@ importers:
'@codechecks/client': '@codechecks/client':
specifier: ^0.1.11 specifier: ^0.1.11
version: 0.1.11(typescript@4.9.3) version: 0.1.11(typescript@4.9.3)
'@ethersproject/abstract-provider':
specifier: ^5.7.0
version: 5.7.0
devDependencies: devDependencies:
'@babel/eslint-parser': '@babel/eslint-parser':
specifier: ^7.18.2 specifier: ^7.18.2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment