-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9677e51
commit fed06f7
Showing
16 changed files
with
140 additions
and
23 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -56,6 +56,9 @@ jobs: | |
repository: 0xPolygon/kurtosis-cdk | ||
ref: v0.2.9 | ||
path: "ext/kurtosis-cdk" | ||
|
||
- name: Setup Bats and bats libs | ||
uses: bats-core/[email protected] | ||
|
||
- name: Test | ||
run: make test-e2e-${{ matrix.e2e-group }} | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package types | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMarshalArgUint64(t *testing.T) { | ||
var value ArgUint64 | ||
value = 1 | ||
a, err := json.Marshal(value) | ||
require.NoError(t, err) | ||
require.Equal(t, "\"0x1\"", string(a)) | ||
} | ||
|
||
func TestUnMarshalArgUint64(t *testing.T) { | ||
var value ArgUint64 | ||
value = 1 | ||
err := json.Unmarshal([]byte("\"0x1\""), &value) | ||
require.NoError(t, err) | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package rpcsync | ||
|
||
type Config struct { | ||
Enabled bool `mapstructure:"Enabled"` | ||
Port int `mapstructure:"Port"` | ||
MaxRequestsPerIPAndSecond float64 `mapstructure:"MaxRequestsPerIPAndSecond"` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package rpcsync | ||
|
||
import ( | ||
jRPC "github.com/0xPolygon/cdk-rpc/rpc" | ||
"github.com/0xPolygonHermez/zkevm-synchronizer-l1/log" | ||
) | ||
|
||
func StartRPC(cfg Config, sync interface{}, state interface{}) { | ||
if !cfg.Enabled { | ||
log.Info("RPC server is disabled") | ||
return | ||
} | ||
cfgRPC := jRPC.Config{ | ||
Port: cfg.Port, | ||
MaxRequestsPerIPAndSecond: cfg.MaxRequestsPerIPAndSecond, | ||
} | ||
|
||
serverCfg := buildRPCServiceEndPoints(sync, state) | ||
|
||
server := jRPC.NewServer(cfgRPC, serverCfg) | ||
log.Infof("RPC server started on port %d (MaxRequestsPerIPAndSecond=%f)", cfg.Port, cfg.MaxRequestsPerIPAndSecond) | ||
go func() { | ||
if err := server.Start(); err != nil { | ||
log.Fatal(err) | ||
} | ||
}() | ||
} | ||
|
||
func addSyncerEndpoint(sync interface{}, endPoints []jRPC.Service) []jRPC.Service { | ||
syncImpl, ok := sync.(SyncInterface) | ||
if !ok { | ||
log.Fatal("State must implement Sync") | ||
} | ||
endPoints = append(endPoints, jRPC.Service{ | ||
Name: "sync", | ||
Service: &SyncEndpoints{ | ||
Sync: syncImpl, | ||
}, | ||
}) | ||
return endPoints | ||
} |
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,25 @@ | ||
package rpcsync | ||
|
||
import ( | ||
"github.com/0xPolygon/cdk-rpc/rpc" | ||
zkevm_synchronizer_l1 "github.com/0xPolygonHermez/zkevm-synchronizer-l1" | ||
) | ||
|
||
type SyncInterface interface { | ||
// IsSynced returns true if the synchronizer is synced or false if it's not | ||
IsSynced() bool | ||
} | ||
|
||
type SyncEndpoints struct { | ||
Sync SyncInterface | ||
} | ||
|
||
// curl -X POST http://localhost:8025/ -H "Con -application/json" -d '{"method":"sync_version", "params":[], "id":1}' | ||
func (b *SyncEndpoints) Version() (interface{}, rpc.Error) { | ||
return zkevm_synchronizer_l1.Version, nil | ||
} | ||
|
||
// curl -X POST http://localhost:1025/ -H "Con -application/json" -d '{"method":"sync_isSynced", "params":[], "id":1}' | ||
func (b *SyncEndpoints) IsSynced() (interface{}, rpc.Error) { | ||
return b.Sync.IsSynced(), nil | ||
} |
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