rebased from trinity/master with EventBridge modifications