Skip to content
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

Feature/set431 global whitelist contracts #1695

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9cf2188
DSO-2331 Add partior workflow
anthony-yeong-partior Aug 15, 2023
67550e9
feat: SET-315 fix generating uuid requiring admin account
rodion-lim-partior Aug 7, 2023
44248fd
Merge pull request #3 from partior-3p/hotfix/set_315_generate_uuid
anthony-yeong-partior Aug 16, 2023
c79bfa6
DSO-2622: Fix CVE-2022-32149
anthony-yeong-partior Dec 5, 2023
8f080ce
DSO-2622: Update go.sum
anthony-yeong-partior Dec 5, 2023
efafb88
DSO-2622: Update go.sum
anthony-yeong-partior Dec 5, 2023
f5c60f1
DSO-2622: Update go.sum
anthony-yeong-partior Dec 5, 2023
b32386a
DSO-2622: Update go.sum
anthony-yeong-partior Dec 5, 2023
c6cfe68
DSO-2622: Remove the vuln
anthony-yeong-partior Dec 5, 2023
de0dc52
DSO-2622: Revert back to minimal vuln fix
anthony-yeong-partior Dec 5, 2023
fa08c74
DSO-2622: Override mod version to fix vul
anthony-yeong-partior Dec 6, 2023
5660243
DSO-2622: Update go.sum
anthony-yeong-partior Dec 6, 2023
c4ca510
Merge pull request #10 from partior-3p/hotfix/DSO-2622_fix-vuln
anthony-yeong-partior Dec 6, 2023
b86263a
fix: memory leak from policy registration (#1660)
rodion-lim-partior Dec 11, 2023
ea07829
Merge pull request #13 from partior-3p/hotfix/SET-389-fix-validator-m…
anthony-yeong-partior Jan 8, 2024
5945cf5
crypto: use btcec/v2 for no-cgo (#24533)
chappjc Mar 16, 2022
8a4b911
feat: SET-436 upgrade dependencies and go compiler to 1.19
rodion-lim-partior Feb 27, 2024
461066f
Fix check for consensus algorithm
Mar 1, 2023
3cc6454
updated Epirus link to Chainlens in readme (#1668)
NickSneo Aug 21, 2023
2666048
QBFT: prevent maximum request timeout overflow (#1665)
hhsel Aug 21, 2023
f3f5c09
QBFT: fix chain fork when emptyblockperiodseconds is enabled (#1669)
antonydenyer Aug 21, 2023
bfd0a76
ETH: fix bug with private transactions not simulated with debug_trace…
rodion-lim-partior Sep 11, 2023
5c25b2b
accounts/abi/bind: parse ABI only once, create metadata struct (#22583)
MariusVanDerWijden Jul 27, 2021
b919fb9
accounts/abi: add basic support for error types (#23161)
MariusVanDerWijden Oct 14, 2021
2dda768
core: SET-385 fix race conditions in txpool (go-ethereum #23474)
rodion-lim-partior Mar 9, 2024
4e0b28d
fix: SET-431 fix bind_test unit test failures
rodion-lim-partior Mar 10, 2024
5a41ba6
feat: SET-431 upgrade ep compiler to 0.8.17
rodion-lim-partior Feb 20, 2024
206d35c
feat: SET-431 add contract whitelist listeners
rodion-lim-partior Feb 20, 2024
1f161e1
feat: SET-431 add initializer and remove constructor
rodion-lim-partior Feb 20, 2024
1bfa389
feat: SET-431 alias initialized event across contracts and fix test
rodion-lim-partior Feb 20, 2024
6840e63
feat: SET-431 add contract key to whitelist lookup
rodion-lim-partior Feb 21, 2024
bb67f50
feat: SET-431 expose contract whitelist function calls in perm interface
rodion-lim-partior Feb 21, 2024
dbdc39f
feat: SET-431 expose whitelist API calls and introduce whitelist back…
rodion-lim-partior Feb 21, 2024
7978cdb
feat: SET-431 switch from contract to proxy storage
rodion-lim-partior Feb 22, 2024
f675aad
feat: SET-431 add contract whitelist to permissions config and initia…
rodion-lim-partior Feb 28, 2024
320f6e0
feat: SET-431 add whitelist revoke event handler, introduce additiona…
rodion-lim-partior Feb 29, 2024
04dde76
feat: SET-431 perform EP acoth bypass during state transition on whit…
rodion-lim-partior Feb 29, 2024
3bf9f34
feat: SET-431 remove contract key lookup and lru cache
rodion-lim-partior Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/partior-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Partior Golang CI
on:
pull_request:
branches: [ main, base/**, release/**, hotfix/** ]
paths-ignore:
- '.github/**'
push:
branches: [ main, base/** ]
paths-ignore:
- '.github/**'
workflow_dispatch:
jobs:
ci-pipeline:
uses: partior-libs/controller-3p-pipelines/.github/workflows/pipeline-template-go-ci-quorum.yaml@main
with:
CONTROLLER-REPO: partior-libs/controller-3p-pipelines
PROJECT-REPO: ${{ github.repository }}
secrets: inherit
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The official docker containers can be found under https://hub.docker.com/u/quoru

The following GoQuorum-related libraries/applications have been created by Third Parties and as such are not specifically endorsed by J.P. Morgan. A big thanks to the developers for improving the tooling around GoQuorum!

* [Quorum Blockchain Explorer](https://github.com/web3labs/epirus-free) - a Blockchain Explorer for GoQuorum which supports viewing private transactions
* [Chainlens Blockchain Explorer](https://github.com/web3labs/chainlens-free) - a Blockchain Explorer for GoQuorum which supports viewing private transactions
* [Quorum-Genesis](https://github.com/davebryson/quorum-genesis) - A simple CL utility for GoQuorum to help populate the genesis file with voters and makers
* [Quorum Maker](https://github.com/synechron-finlabs/quorum-maker/) - a utility to create GoQuorum nodes
* [ERC20 REST service](https://github.com/web3labs/erc20-rest-service) - a GoQuorum-supported RESTful service for creating and managing ERC-20 tokens
Expand Down
55 changes: 23 additions & 32 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ABI struct {
Constructor Method
Methods map[string]Method
Events map[string]Event
Errors map[string]Error

// Additional "special" functions introduced in solidity v0.6.0.
// It's separated from the original default fallback. Each contract
Expand Down Expand Up @@ -157,12 +158,13 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
}
abi.Methods = make(map[string]Method)
abi.Events = make(map[string]Event)
abi.Errors = make(map[string]Error)
for _, field := range fields {
switch field.Type {
case "constructor":
abi.Constructor = NewMethod("", "", Constructor, field.StateMutability, field.Constant, field.Payable, field.Inputs, nil)
case "function":
name := abi.overloadedMethodName(field.Name)
name := overloadedName(field.Name, func(s string) bool { _, ok := abi.Methods[s]; return ok })
abi.Methods[name] = NewMethod(name, field.Name, Function, field.StateMutability, field.Constant, field.Payable, field.Inputs, field.Outputs)
case "fallback":
// New introduced function type in v0.6.0, check more detail
Expand All @@ -182,45 +184,17 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
}
abi.Receive = NewMethod("", "", Receive, field.StateMutability, field.Constant, field.Payable, nil, nil)
case "event":
name := abi.overloadedEventName(field.Name)
name := overloadedName(field.Name, func(s string) bool { _, ok := abi.Events[s]; return ok })
abi.Events[name] = NewEvent(name, field.Name, field.Anonymous, field.Inputs)
case "error":
abi.Errors[field.Name] = NewError(field.Name, field.Inputs)
default:
return fmt.Errorf("abi: could not recognize type %v of field %v", field.Type, field.Name)
}
}
return nil
}

// overloadedMethodName returns the next available name for a given function.
// Needed since solidity allows for function overload.
//
// e.g. if the abi contains Methods send, send1
// overloadedMethodName would return send2 for input send.
func (abi *ABI) overloadedMethodName(rawName string) string {
name := rawName
_, ok := abi.Methods[name]
for idx := 0; ok; idx++ {
name = fmt.Sprintf("%s%d", rawName, idx)
_, ok = abi.Methods[name]
}
return name
}

// overloadedEventName returns the next available name for a given event.
// Needed since solidity allows for event overload.
//
// e.g. if the abi contains events received, received1
// overloadedEventName would return received2 for input received.
func (abi *ABI) overloadedEventName(rawName string) string {
name := rawName
_, ok := abi.Events[name]
for idx := 0; ok; idx++ {
name = fmt.Sprintf("%s%d", rawName, idx)
_, ok = abi.Events[name]
}
return name
}

// MethodById looks up a method by the 4-byte id,
// returns nil if none found.
func (abi *ABI) MethodById(sigdata []byte) (*Method, error) {
Expand Down Expand Up @@ -277,3 +251,20 @@ func UnpackRevert(data []byte) (string, error) {
}
return unpacked[0].(string), nil
}

// overloadedName returns the next available name for a given thing.
// Needed since solidity allows for overloading.
//
// e.g. if the abi contains Methods send, send1
// overloadedName would return send2 for input send.
//
// overloadedName works for methods, events and errors.
func overloadedName(rawName string, isAvail func(string) bool) string {
name := rawName
ok := isAvail(name)
for idx := 0; ok; idx++ {
name = fmt.Sprintf("%s%d", rawName, idx)
ok = isAvail(name)
}
return name
}
14 changes: 14 additions & 0 deletions accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@ func TestOverloadedMethodSignature(t *testing.T) {
check("bar0", "bar(uint256,uint256)", false)
}

func TestCustomErrors(t *testing.T) {
json := `[{ "inputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ],"name": "MyError", "type": "error"} ]`
abi, err := JSON(strings.NewReader(json))
if err != nil {
t.Fatal(err)
}
check := func(name string, expect string) {
if abi.Errors[name].Sig != expect {
t.Fatalf("The signature of overloaded method mismatch, want %s, have %s", expect, abi.Methods[name].Sig)
}
}
check("MyError", "MyError(uint256)")
}

func TestMultiPack(t *testing.T) {
abi, err := JSON(strings.NewReader(jsondata))
if err != nil {
Expand Down
25 changes: 25 additions & 0 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"errors"
"fmt"
"math/big"
"strings"
"sync"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
Expand Down Expand Up @@ -87,6 +89,29 @@ type WatchOpts struct {
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
}

// MetaData collects all metadata for a bound contract.
type MetaData struct {
mu sync.Mutex
Sigs map[string]string
Bin string
ABI string
ab *abi.ABI
}

func (m *MetaData) GetAbi() (*abi.ABI, error) {
m.mu.Lock()
defer m.mu.Unlock()
if m.ab != nil {
return m.ab, nil
}
if parsed, err := abi.JSON(strings.NewReader(m.ABI)); err != nil {
return nil, err
} else {
m.ab = &parsed
}
return m.ab, nil
}

// BoundContract is the base wrapper object that reflects a contract on the
// Ethereum network. It contains a collection of methods that are used by the
// higher level contract bindings to operate.
Expand Down
55 changes: 55 additions & 0 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,61 @@ var bindTests = []struct {
nil,
nil,
},
// Test errors introduced in v0.8.4
{
`NewErrors`,
`
pragma solidity >0.8.4;

contract NewErrors {
error MyError(uint256);
error MyError1(uint256);
error MyError2(uint256, uint256);
error MyError3(uint256 a, uint256 b, uint256 c);
function Error() public pure {
revert MyError3(1,2,3);
}
}
`,
[]string{"0x6080604052348015600f57600080fd5b5060998061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063726c638214602d575b600080fd5b60336035565b005b60405163024876cd60e61b815260016004820152600260248201526003604482015260640160405180910390fdfea264697066735822122093f786a1bc60216540cd999fbb4a6109e0fef20abcff6e9107fb2817ca968f3c64736f6c63430008070033"},
[]string{`[{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"MyError","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"MyError1","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"MyError2","type":"error"},{"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"},{"internalType":"uint256","name":"c","type":"uint256"}],"name":"MyError3","type":"error"},{"inputs":[],"name":"Error","outputs":[],"stateMutability":"pure","type":"function"}]`},
`
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/ethconfig"
`,
`
var (
key, _ = crypto.GenerateKey()
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
)
defer sim.Close()

_, tx, contract, err := DeployNewErrors(user, sim)
if err != nil {
t.Fatal(err)
}
sim.Commit()
_, err = bind.WaitDeployed(nil, sim, tx)
if err != nil {
t.Error(err)
}
if err := contract.Error(new(bind.CallOpts)); err == nil {
t.Fatalf("expected contract to throw error")
}
// TODO (MariusVanDerWijden unpack error using abigen
// once that is implemented
`,
nil,
nil,
nil,
nil,
},
}

// Tests that packages generated by the binder can be successfully compiled and
Expand Down
34 changes: 26 additions & 8 deletions accounts/abi/bind/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ package {{.Package}}
import (
"math/big"
"strings"
"errors"

ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
Expand All @@ -101,6 +102,7 @@ import (

// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
Expand All @@ -120,34 +122,50 @@ var (
{{end}}

{{range $contract := .Contracts}}
// {{.Type}}MetaData contains all meta data concerning the {{.Type}} contract.
var {{.Type}}MetaData = &bind.MetaData{
ABI: "{{.InputABI}}",
{{if $contract.FuncSigs -}}
Sigs: map[string]string{
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}",
{{end}}
},
{{end -}}
{{if .InputBin -}}
Bin: "0x{{.InputBin}}",
{{end}}
}
// {{.Type}}ABI is the input ABI used to generate the binding from.
const {{.Type}}ABI = "{{.InputABI}}"
// Deprecated: Use {{.Type}}MetaData.ABI instead.
var {{.Type}}ABI = {{.Type}}MetaData.ABI

var {{.Type}}ParsedABI, _ = abi.JSON(strings.NewReader({{.Type}}ABI))

{{if $contract.FuncSigs}}
// Deprecated: Use {{.Type}}MetaData.Sigs instead.
// {{.Type}}FuncSigs maps the 4-byte function signature to its string representation.
var {{.Type}}FuncSigs = map[string]string{
{{range $strsig, $binsig := .FuncSigs}}"{{$binsig}}": "{{$strsig}}",
{{end}}
}
var {{.Type}}FuncSigs = {{.Type}}MetaData.Sigs
{{end}}

{{if .InputBin}}
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
var {{.Type}}Bin = "0x{{.InputBin}}"
// Deprecated: Use {{.Type}}MetaData.Bin instead.
var {{.Type}}Bin = {{.Type}}MetaData.Bin

// Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
parsed, err := {{.Type}}MetaData.GetAbi()
if err != nil {
return common.Address{}, nil, nil, err
}
if parsed == nil {
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
}
{{range $pattern, $name := .Libraries}}
{{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend)
{{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1)
{{end}}
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}})
if err != nil {
return common.Address{}, nil, nil, err
}
Expand Down
Loading
Loading