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

Merge branch 'develop' into fix/bindings-deterministic

parents 918ae29e 61cb88ac
3b1129b5bc43ba22a9bcf4e4323c5a9df0023140
......@@ -45,7 +45,7 @@ This tutorial was checked on:
| Go | 1.20 | `sudo apt update` <br> `wget https://go.dev/dl/go1.20.linux-amd64.tar.gz` <br> `tar xvzf go1.20.linux-amd64.tar.gz` <br> `sudo cp go/bin/go /usr/bin/go` <br> `sudo mv go /usr/lib` <br> `echo export GOROOT=/usr/lib/go >> ~/.bashrc`
| Node | 16.19.0 | `curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -` <br> `sudo apt-get install -y nodejs npm`
| yarn | 1.22.19 | `sudo npm install -g yarn`
| Foundry | 0.2.0 | `curl -L https://foundry.paradigm.xyz | bash` <br> `. ~/.bashrc` <br> `foundryup`
| Foundry | 0.2.0 | `yarn install:foundry`
## Build the Source Code
......
......@@ -49,9 +49,8 @@ func (a *Agent) move(claim, parent Claim) error {
if err != nil || move == nil {
return err
}
// TODO(CLI-4123): Don't send duplicate responses
// if a.game.IsDuplicate(move) {
// return nil
// }
if a.game.IsDuplicate(*move) {
return nil
}
return a.responder.Respond(context.TODO(), *move)
}
......@@ -22,6 +22,8 @@ type Game interface {
claim Claim
parent Claim
}
IsDuplicate(claim Claim) bool
}
// Node is a node in the game state tree.
......@@ -33,17 +35,21 @@ type Node struct {
// gameState is a struct that represents the state of a dispute game.
// The game state implements the [Game] interface.
type gameState struct {
root Node
root Node
claims map[ClaimData]Claim
}
// NewGameState returns a new game state.
// The provided [Claim] is used as the root node.
func NewGameState(root Claim) *gameState {
claims := make(map[ClaimData]Claim)
claims[root.ClaimData] = root
return &gameState{
root: Node{
self: root,
children: make([]*Node, 0),
},
claims: claims,
}
}
......@@ -116,10 +122,16 @@ func (g *gameState) Put(claim Claim) error {
// Add the node to the tree.
found.children = append(found.children, &node)
g.claims[claim.ClaimData] = claim
return nil
}
func (g *gameState) IsDuplicate(claim Claim) bool {
_, ok := g.claims[claim.ClaimData]
return ok
}
// recurseTreePairs recursively walks down the tree from the root node
// returning a list of claim and parent pairs.
func (g *gameState) recurseTreePairs(current *Node) []struct {
......
......@@ -35,6 +35,21 @@ func createTestClaims() (Claim, Claim, Claim) {
return top, middle, bottom
}
func TestIsDuplicate(t *testing.T) {
// Setup the game state.
top, middle, bottom := createTestClaims()
g := NewGameState(top)
err := g.Put(middle)
require.NoError(t, err)
// Top + Middle should be duplicates
require.True(t, g.IsDuplicate(top))
require.True(t, g.IsDuplicate(middle))
// Bottom should not be a duplicate
require.False(t, g.IsDuplicate(bottom))
}
// TestGame_Put_RootAlreadyExists tests the [Game.Put] method using a [gameState]
// instance errors when the root claim already exists in state.
func TestGame_Put_RootAlreadyExists(t *testing.T) {
......
......@@ -11,12 +11,14 @@ RUN apt-get update && \
chmod +x ./rustup.sh && \
./rustup.sh -y
# move the foundryrc file to the foundry dir
WORKDIR /opt/foundry
COPY ../../.foundryrc ./.foundryrc
# Only diff from upstream docker image is this clone instead
# of COPY. We select a specific commit to use.
RUN git clone https://github.com/foundry-rs/foundry.git . \
&& git checkout 3b1129b5bc43ba22a9bcf4e4323c5a9df0023140
&& git checkout $(cat .foundryrc)
RUN source $HOME/.profile && \
cargo build --release && \
......
......@@ -39,7 +39,9 @@
"ready": "yarn lint && yarn test",
"prepare": "husky install",
"release": "yarn build && yarn changeset publish",
"update:yarn": "yarn set version 1.x"
"update:yarn": "yarn set version 1.x",
"install:foundry": "curl -L https://foundry.paradigm.xyz | bash && yarn update:foundry",
"update:foundry": "foundryup -C $(cat .foundryrc)"
},
"devDependencies": {
"@babel/eslint-parser": "^7.18.2",
......
......@@ -56,16 +56,17 @@ npm install @eth-optimism/contracts-bedrock
We work on this repository with a combination of [Hardhat](https://hardhat.org) and [Foundry](https://getfoundry.sh/).
1. Install Foundry by following [the instructions located here](https://getfoundry.sh/).
A specific version must be used.
```shell
foundryup -C 3b1129b5bc43ba22a9bcf4e4323c5a9df0023140
```
2. Install node modules with yarn (v1) and Node.js (16+):
```shell
yarn install
```
1. Install node modules with yarn (v1) and Node.js (16+):
```shell
yarn install
```
1. Install the correct version of foundry (defined in the .foundryrc file in the root of this repo.
```shell
yarn install:foundry
```
### Build
......
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